/kind bug
What happened
When a headless service is created to point to pods which share a single hostname, (which happens, for example, when the hostname field was set in the template of a deployment/replicaset)
- Only one A record is returned for the service DNS name
- A pod DNS name is generated based on this host name, which points to a single pod
What was expected to happen
- Return A records for all available endpoints on the service DNS name
- Not sure what the correct behaviour should be for the pod dns name, either also return multiple A records, or don't create at all.
Seems this has to do with the following code:
https://github.com/kubernetes/dns/blob/master/pkg/dns/dns.go#L490
Then the endpointName will be equal for any pod in the service which has the same hostname, so the entry in subCache will be overwritten.
How to reproduce
Apply the following spec:
apiVersion: v1
kind: List
items:
- apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: depl-1
spec:
replicas: 2
template:
metadata:
labels:
app: depl-1
spec:
hostname: depl-1-host
subdomain: depl-1-service
containers:
- name: test
args:
- bash
stdin: true
tty: true
image: debian:jessie
- apiVersion: v1
kind: Service
metadata:
name: depl-1-service
spec:
clusterIP: None
selector:
app: depl-1
ports:
- port: 5000
Resolving the hostnames gives back but a single A record.
# host depl-1-host.depl-1-service.default.svc.cluster.local
depl-1-host.depl-1-service.default.svc.cluster.local has address 10.56.0.140
# host depl-1-service.default.svc.cluster.local
depl-1-service.default.svc.cluster.local has address 10.56.0.140
PTR records ARE being created for all the pods, all resolving back to the single hostname. This is expected behaviour.
/kind bug
What happened
When a headless service is created to point to pods which share a single hostname, (which happens, for example, when the hostname field was set in the template of a deployment/replicaset)
What was expected to happen
Seems this has to do with the following code:
https://github.com/kubernetes/dns/blob/master/pkg/dns/dns.go#L490
Then the endpointName will be equal for any pod in the service which has the same hostname, so the entry in subCache will be overwritten.
How to reproduce
Apply the following spec:
Resolving the hostnames gives back but a single A record.
PTR records ARE being created for all the pods, all resolving back to the single hostname. This is expected behaviour.