---
apiVersion: v1
kind: Service
metadata:
  name: headless-service-normal-service
spec:
  selector:
    app: headless-service-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  name: headless-service-headless-service
spec:
  clusterIP: None  # This marks this service out as a headless service
  selector:
    app: headless-service-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 3000
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: headless-service-deployment
  labels:
    app: headless-service-app
spec:
  replicas: 2
  selector:
    matchLabels:
      app: headless-service-app
  template:
    metadata:
      labels:
        app: headless-service-app
    spec:
      containers:
        - command:
            - sleep
            - "3600"
          image: busybox
          name: headless-service-app
          ports:
            - containerPort: 3000
---
# This pod allows us to do the DNS lookup
# https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/
apiVersion: v1
kind: Pod
metadata:
  name: headless-service-dnsutils-pod
spec:
  containers:
    - command:
        - sleep
        - "3600"
      image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3
      name: dnsutils
