Skip to content

Commit 7c7c5b3

Browse files
feat: pods can have hostPorts without hostNetwork
1 parent 90089b6 commit 7c7c5b3

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

docs/tutorials/kops-dns-controller.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ The DNS record mappings try to "do the right thing", but what this means is diff
2121

2222
### Pods
2323

24-
For the external annotation, ExternalDNS will map a HostNetwork=true Pod to the external IPs of the Node.
24+
For the external annotation, ExternalDNS will map a Pod to the external IPs of the Node.
2525

26-
For the internal annotation, ExternalDNS will map a HostNetwork=true Pod to the internal IPs of the Node.
27-
28-
ExternalDNS ignore Pods that are not HostNetwork=true
26+
For the internal annotation, ExternalDNS will map a Pod to the internal IPs of the Node.
2927

3028
Annotations added to Pods will always result in an A record being created.
3129

source/pod.go

-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
"sigs.k8s.io/external-dns/endpoint"
2323

24-
log "github.com/sirupsen/logrus"
2524
corev1 "k8s.io/api/core/v1"
2625
"k8s.io/apimachinery/pkg/labels"
2726
kubeinformers "k8s.io/client-go/informers"
@@ -84,11 +83,6 @@ func (ps *podSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
8483

8584
endpointMap := make(map[endpoint.EndpointKey][]string)
8685
for _, pod := range pods {
87-
if !pod.Spec.HostNetwork {
88-
log.Debugf("skipping pod %s. hostNetwork=false", pod.Name)
89-
continue
90-
}
91-
9286
targets := getTargetsFromTargetAnnotation(pod.Annotations)
9387

9488
if domainAnnotation, ok := pod.Annotations[internalHostnameAnnotationKey]; ok {

source/pod_test.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,14 @@ func TestPodSource(t *testing.T) {
459459
},
460460
},
461461
{
462-
"pods with hostNetwore=false should be ignored",
462+
"pods with hostNetwore=false should not be ignored",
463463
"",
464464
"",
465465
[]*endpoint.Endpoint{
466466
{DNSName: "a.foo.example.org", Targets: endpoint.Targets{"54.10.11.1"}, RecordType: endpoint.RecordTypeA},
467467
{DNSName: "internal.a.foo.example.org", Targets: endpoint.Targets{"10.0.1.1"}, RecordType: endpoint.RecordTypeA},
468+
{DNSName: "b.foo.example.org", Targets: endpoint.Targets{"54.10.11.2"}, RecordType: endpoint.RecordTypeA},
469+
{DNSName: "internal.b.foo.example.org", Targets: endpoint.Targets{"10.0.1.2"}, RecordType: endpoint.RecordTypeA},
468470
},
469471
false,
470472
[]*corev1.Node{
@@ -514,16 +516,16 @@ func TestPodSource(t *testing.T) {
514516
Name: "my-pod2",
515517
Namespace: "kube-system",
516518
Annotations: map[string]string{
517-
internalHostnameAnnotationKey: "internal.a.foo.example.org",
518-
hostnameAnnotationKey: "a.foo.example.org",
519+
internalHostnameAnnotationKey: "internal.b.foo.example.org",
520+
hostnameAnnotationKey: "b.foo.example.org",
519521
},
520522
},
521523
Spec: corev1.PodSpec{
522524
HostNetwork: false,
523525
NodeName: "my-node2",
524526
},
525527
Status: corev1.PodStatus{
526-
PodIP: "100.0.1.2",
528+
PodIP: "10.0.1.2",
527529
},
528530
},
529531
},

0 commit comments

Comments
 (0)