Home > Blockchain >  DNS lookup on Headless service doesn't return any IP addresses
DNS lookup on Headless service doesn't return any IP addresses

Time:03-22

I'm runnning a cluster in Kubernetes with minikube and VirtualBox.

This is my headless service

apiVersion: v1
kind: Service
metadata:
  labels:
    service: test
  name: test-group-ping
spec:
  clusterIP: None
  ports:
    - port: 4444
      name: ping
      protocol: TCP
      targetPort: 4444
  selector:
    service: test
  sessionAffinity: None
  type: ClusterIP

This is how I deployed the pods

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 3
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
      - name: test
        image: image
        env:
        - name: KC_PROXY
          value: "edge"
        - name: PROXY_ADDRESS_FORWARDING
          value: "true"
        ports:
          - containerPort: 8080
          - containerPort: 4444
          - containerPort: 8888
        readinessProbe:
            httpGet:
              path: "/test"
              port: 8080
            initialDelaySeconds: 600
            periodSeconds: 30

I have another Load Balancer for the pods

When I use kubectl get services , I get test-group-ping as an headless service

test-group-ping   ClusterIP      None             <none>          4444/TCP     8h


kubectl describe service test-group-ping
Name:              test-group-ping
Namespace:         default
Labels:            service=test
Annotations:       <none>
Selector:          service=test
Type:              ClusterIP
IP Family Policy:  SingleStack
IP Families:       IPv4
IP:                None
IPs:               None
Port:              ping  4444/TCP
TargetPort:        4444/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>

I need the DNS query for this headless service

I tried test-group-ping.default.svc.cluster.local, but when I tried to do a DNS lookup on this, it doesn't return any IP addresses of the pod

 % dig  search test-group-ping.default.svc.cluster.local


; <<>> DiG 9.10.6 <<>>  search test-group-ping.default.svc.cluster.local
;; global options:  cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 8544
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;test-group-ping.default.svc.cluster.local. IN A

;; AUTHORITY SECTION:
.           10800   IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2022032100 1800 900 604800 86400

;; Query time: 140 msec
;; SERVER: 2600:1702:8c0:e100::1#53(2600:1702:8c0:e100::1)
;; WHEN: Mon Mar 21 10:33:50 CDT 2022
;; MSG SIZE  rcvd: 151

;; Query time: 140 msec
;; SERVER: 2600:1702:8c0:e100::1#53(2600:1702:8c0:e100::1)
;; WHEN: Mon Mar 21 10:33:50 CDT 2022
;; MSG SIZE  rcvd: 151

CodePudding user response:

Your Service selector service: test does not match with the Pod label app: test.

  • Related