apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-demo
spec:
  replicas: 2
  selector:
    matchLabels:
      run: nginx-demo
  template:
    metadata:
      labels:
        run: nginx-demo
    spec:
      containers:
      - name: nginx-demo
        image: nginx
        ports:
        - containerPort: 80

---
apiVersion: v1
kind: Service
metadata:
  labels:
    run: nginx-demo
  name: nginx-demo
  annotations:
    haproxy.org/check: "enabled"
    haproxy.org/forwarded-for: "enabled"
    haproxy.org/load-balance: "roundrobin"
spec:
  selector:
    run: nginx-demo
  ports:
  - name: port-1
    port: 8080
    protocol: TCP
    targetPort: 80

---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: web-ingress
  namespace: default
spec:
  rules:
  - host: nowhere.milky.way
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx-demo
          servicePort: 8080
