Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions source/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ func (ps *podSource) addInternalHostnameAnnotationEndpoints(endpointMap map[endp
domainList := annotations.SplitHostnameAnnotation(domainAnnotation)
for _, domain := range domainList {
if len(targets) == 0 {
if pod.Status.PodIP == "" {
continue
}
addToEndpointMap(endpointMap, pod, domain, endpoint.SuitableType(pod.Status.PodIP), pod.Status.PodIP)
} else {
addTargetsToEndpointMap(endpointMap, pod, targets, domain)
Expand All @@ -212,6 +215,9 @@ func (ps *podSource) addKopsDNSControllerEndpoints(endpointMap map[endpoint.Endp
if domainAnnotation, ok := pod.Annotations[kopsDNSControllerInternalHostnameAnnotationKey]; ok {
domainList := annotations.SplitHostnameAnnotation(domainAnnotation)
for _, domain := range domainList {
if pod.Status.PodIP == "" {
continue
}
addToEndpointMap(endpointMap, pod, domain, endpoint.SuitableType(pod.Status.PodIP), pod.Status.PodIP)
}
}
Expand All @@ -227,6 +233,9 @@ func (ps *podSource) addPodSourceDomainEndpoints(endpointMap map[endpoint.Endpoi
if ps.podSourceDomain != "" {
domain := pod.Name + "." + ps.podSourceDomain
if len(targets) == 0 {
if pod.Status.PodIP == "" {
return
}
addToEndpointMap(endpointMap, pod, domain, endpoint.SuitableType(pod.Status.PodIP), pod.Status.PodIP)
}
addTargetsToEndpointMap(endpointMap, pod, targets, domain)
Expand Down
53 changes: 53 additions & 0 deletions source/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,59 @@ func TestPodSource(t *testing.T) {
},
},
},
{
"kops-dns-controller internal-hostname pod without a PodIP is skipped",
"",
"kops-dns-controller",
true,
"",
[]*endpoint.Endpoint{},
false,
nodesFixturesIPv4(),
[]*corev1.Pod{
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-pod1",
Namespace: "kube-system",
Annotations: map[string]string{
kopsDNSControllerInternalHostnameAnnotationKey: "internal.a.foo.example.org",
},
},
Spec: corev1.PodSpec{
HostNetwork: true,
NodeName: "my-node1",
},
Status: corev1.PodStatus{
PodIP: "",
},
},
},
},
{
"pod-source-domain pod without a PodIP is skipped",
"",
"",
true,
"pod.example.org",
[]*endpoint.Endpoint{},
false,
nodesFixturesIPv4(),
[]*corev1.Pod{
{
ObjectMeta: metav1.ObjectMeta{
Name: "my-pod1",
Namespace: "kube-system",
},
Spec: corev1.PodSpec{
HostNetwork: true,
NodeName: "my-node1",
},
Status: corev1.PodStatus{
PodIP: "",
},
},
},
},
} {
t.Run(tc.title, func(t *testing.T) {
kubernetes := fake.NewClientset()
Expand Down