Skip to content

Commit

Permalink
Use kops dns controller instead of just dns controller where it makes…
Browse files Browse the repository at this point in the history
… sense

Co-authored-by: Nick Jüttner <nick@juni.io>
  • Loading branch information
2 people authored and Ole Markus With committed Jun 23, 2021
1 parent 73469a0 commit 05973fc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ Here's a rough outline on what is to come (subject to change):

### v0.6

- [ ] Ability to replace Kops' [DNS Controller](https://github.com/kubernetes/kops/tree/HEAD/dns-controller) (This could also directly become `v1.0`)
- [ ] Ability to replace kOps' [DNS Controller](https://github.com/kubernetes/kops/tree/HEAD/dns-controller) (This could also directly become `v1.0`)
- [x] Support for OVH

### v1.0

- [ ] Ability to replace Kops' [DNS Controller](https://github.com/kubernetes/kops/tree/HEAD/dns-controller)
- [ ] Ability to replace kOps' [DNS Controller](https://github.com/kubernetes/kops/tree/HEAD/dns-controller)
- [x] Add support for pod source
- [x] Add support for DNS Controller annotations for pod and service sources
- [ ] Add support for kOps gossip provider
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/externaldns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (cfg *Config) ParseFlags(args []string) error {
app.Flag("combine-fqdn-annotation", "Combine FQDN template and Annotations instead of overwriting").BoolVar(&cfg.CombineFQDNAndAnnotation)
app.Flag("ignore-hostname-annotation", "Ignore hostname annotation when generating DNS names, valid only when using fqdn-template is set (optional, default: false)").BoolVar(&cfg.IgnoreHostnameAnnotation)
app.Flag("ignore-ingress-tls-spec", "Ignore tls spec section in ingresses resources, applicable only for ingress sources (optional, default: false)").BoolVar(&cfg.IgnoreIngressTLSSpec)
app.Flag("compatibility", "Process annotation semantics from legacy implementations (optional, options: mate, molecule)").Default(defaultConfig.Compatibility).EnumVar(&cfg.Compatibility, "", "mate", "molecule", "dns-controller")
app.Flag("compatibility", "Process annotation semantics from legacy implementations (optional, options: mate, molecule, kops-dns-controller)").Default(defaultConfig.Compatibility).EnumVar(&cfg.Compatibility, "", "mate", "molecule", "kops-dns-controller")
app.Flag("publish-internal-services", "Allow external-dns to publish DNS records for ClusterIP services (optional)").BoolVar(&cfg.PublishInternal)
app.Flag("publish-host-ip", "Allow external-dns to publish host-ip for headless services (optional)").BoolVar(&cfg.PublishHostIP)
app.Flag("always-publish-not-ready-addresses", "Always publish also not ready addresses for headless services (optional)").BoolVar(&cfg.AlwaysPublishNotReadyAddresses)
Expand Down
18 changes: 9 additions & 9 deletions source/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
const (
mateAnnotationKey = "zalando.org/dnsname"
moleculeAnnotationKey = "domainName"
// dnsControllerHostnameAnnotationKey is the annotation used for defining the desired hostname when DNS controller compatibility mode
dnsControllerHostnameAnnotationKey = "dns.alpha.kubernetes.io/external"
// dnsControllerInternalHostnameAnnotationKey is the annotation used for defining the desired hostname when DNS controller compatibility mode
dnsControllerInternalHostnameAnnotationKey = "dns.alpha.kubernetes.io/internal"
// kopsDnsControllerHostnameAnnotationKey is the annotation used for defining the desired hostname when kOps DNS controller compatibility mode
kopsDnsControllerHostnameAnnotationKey = "dns.alpha.kubernetes.io/external"
// kopsDnsControllerInternalHostnameAnnotationKey is the annotation used for defining the desired hostname when kOps DNS controller compatibility mode
kopsDnsControllerInternalHostnameAnnotationKey = "dns.alpha.kubernetes.io/internal"
)

// legacyEndpointsFromService tries to retrieve Endpoints from Services
Expand All @@ -42,7 +42,7 @@ func legacyEndpointsFromService(svc *v1.Service, sc *serviceSource) ([]*endpoint
return legacyEndpointsFromMateService(svc), nil
case "molecule":
return legacyEndpointsFromMoleculeService(svc), nil
case "dns-controller":
case "kops-dns-controller":
return legacyEndpointsFromDNSControllerService(svc, sc)
}

Expand Down Expand Up @@ -126,8 +126,8 @@ func legacyEndpointsFromDNSControllerNodePortService(svc *v1.Service, sc *servic
var endpoints []*endpoint.Endpoint

// Get the desired hostname of the service from the annotations.
hostnameAnnotation, isExternal := svc.Annotations[dnsControllerHostnameAnnotationKey]
internalHostnameAnnotation, isInternal := svc.Annotations[dnsControllerInternalHostnameAnnotationKey]
hostnameAnnotation, isExternal := svc.Annotations[kopsDnsControllerHostnameAnnotationKey]
internalHostnameAnnotation, isInternal := svc.Annotations[kopsDnsControllerInternalHostnameAnnotationKey]

if !isExternal && !isInternal {
return nil, nil
Expand Down Expand Up @@ -175,8 +175,8 @@ func legacyEndpointsFromDNSControllerLoadBalancerService(svc *v1.Service) []*end
var endpoints []*endpoint.Endpoint

// Get the desired hostname of the service from the annotations.
hostnameAnnotation, hasExternal := svc.Annotations[dnsControllerHostnameAnnotationKey]
internalHostnameAnnotation, hasInternal := svc.Annotations[dnsControllerInternalHostnameAnnotationKey]
hostnameAnnotation, hasExternal := svc.Annotations[kopsDnsControllerHostnameAnnotationKey]
internalHostnameAnnotation, hasInternal := svc.Annotations[kopsDnsControllerInternalHostnameAnnotationKey]

if !hasExternal && !hasInternal {
return nil
Expand Down
6 changes: 3 additions & 3 deletions source/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func (ps *podSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error
}
}

if ps.compatibility == "dns-controller" {
if domain, ok := pod.Annotations[dnsControllerInternalHostnameAnnotationKey]; ok {
if ps.compatibility == "kops-dns-controller" {
if domain, ok := pod.Annotations[kopsDnsControllerInternalHostnameAnnotationKey]; ok {
if _, ok := domains[domain]; !ok {
domains[domain] = []string{}
}
domains[domain] = append(domains[domain], pod.Status.PodIP)
}

if domain, ok := pod.Annotations[dnsControllerHostnameAnnotationKey]; ok {
if domain, ok := pod.Annotations[kopsDnsControllerHostnameAnnotationKey]; ok {
if _, ok := domains[domain]; !ok {
domains[domain] = []string{}
}
Expand Down
10 changes: 5 additions & 5 deletions source/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestPodSource(t *testing.T) {
{
"create records based on pod's external and internal IPs using DNS Controller annotations",
"",
"dns-controller",
"kops-dns-controller",
[]*endpoint.Endpoint{
{DNSName: "a.foo.example.org", Targets: endpoint.Targets{"54.10.11.1", "54.10.11.2"}, RecordType: endpoint.RecordTypeA},
{DNSName: "internal.a.foo.example.org", Targets: endpoint.Targets{"10.0.1.1", "10.0.1.2"}, RecordType: endpoint.RecordTypeA},
Expand Down Expand Up @@ -147,8 +147,8 @@ func TestPodSource(t *testing.T) {
Name: "my-pod1",
Namespace: "kube-system",
Annotations: map[string]string{
dnsControllerInternalHostnameAnnotationKey: "internal.a.foo.example.org",
dnsControllerHostnameAnnotationKey: "a.foo.example.org",
kopsDnsControllerInternalHostnameAnnotationKey: "internal.a.foo.example.org",
kopsDnsControllerHostnameAnnotationKey: "a.foo.example.org",
},
},
Spec: corev1.PodSpec{
Expand All @@ -164,8 +164,8 @@ func TestPodSource(t *testing.T) {
Name: "my-pod2",
Namespace: "kube-system",
Annotations: map[string]string{
dnsControllerInternalHostnameAnnotationKey: "internal.a.foo.example.org",
dnsControllerHostnameAnnotationKey: "a.foo.example.org",
kopsDnsControllerInternalHostnameAnnotationKey: "internal.a.foo.example.org",
kopsDnsControllerHostnameAnnotationKey: "a.foo.example.org",
},
},
Spec: corev1.PodSpec{
Expand Down
34 changes: 17 additions & 17 deletions source/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func testServiceSourceEndpoints(t *testing.T) {
false,
},
{
"our controller type is dns-controller",
"our controller type is kops dns controller",
"",
"",
"testing",
Expand Down Expand Up @@ -875,13 +875,13 @@ func testServiceSourceEndpoints(t *testing.T) {
"testing",
"foo",
v1.ServiceTypeLoadBalancer,
"dns-controller",
"kops-dns-controller",
"",
false,
false,
map[string]string{},
map[string]string{
dnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org",
kopsDnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org",
},
"",
[]string{},
Expand All @@ -899,14 +899,14 @@ func testServiceSourceEndpoints(t *testing.T) {
"testing",
"foo",
v1.ServiceTypeLoadBalancer,
"dns-controller",
"kops-dns-controller",
"",
false,
false,
map[string]string{},
map[string]string{
dnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
dnsControllerHostnameAnnotationKey: "foo.example.org., bar.example.org",
kopsDnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
kopsDnsControllerHostnameAnnotationKey: "foo.example.org., bar.example.org",
},
"",
[]string{},
Expand Down Expand Up @@ -2049,12 +2049,12 @@ func TestServiceSourceNodePortServices(t *testing.T) {
"foo",
v1.ServiceTypeNodePort,
v1.ServiceExternalTrafficPolicyTypeCluster,
"dns-controller",
"kops-dns-controller",
"",
false,
map[string]string{},
map[string]string{
dnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
kopsDnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
},
nil,
[]*endpoint.Endpoint{
Expand Down Expand Up @@ -2101,12 +2101,12 @@ func TestServiceSourceNodePortServices(t *testing.T) {
"foo",
v1.ServiceTypeNodePort,
v1.ServiceExternalTrafficPolicyTypeCluster,
"dns-controller",
"kops-dns-controller",
"",
false,
map[string]string{},
map[string]string{
dnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
kopsDnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
},
nil,
[]*endpoint.Endpoint{
Expand Down Expand Up @@ -2153,12 +2153,12 @@ func TestServiceSourceNodePortServices(t *testing.T) {
"foo",
v1.ServiceTypeNodePort,
v1.ServiceExternalTrafficPolicyTypeCluster,
"dns-controller",
"kops-dns-controller",
"",
false,
map[string]string{},
map[string]string{
dnsControllerHostnameAnnotationKey: "foo.example.org., bar.example.org",
kopsDnsControllerHostnameAnnotationKey: "foo.example.org., bar.example.org",
},
nil,
[]*endpoint.Endpoint{
Expand Down Expand Up @@ -2198,20 +2198,20 @@ func TestServiceSourceNodePortServices(t *testing.T) {
[]v1.PodPhase{},
},
{
"node port services annotated with both dns-controller annotations return an empty set of addons",
"node port services annotated with both kops dns controller annotations return an empty set of addons",
"",
"",
"testing",
"foo",
v1.ServiceTypeNodePort,
v1.ServiceExternalTrafficPolicyTypeCluster,
"dns-controller",
"kops-dns-controller",
"",
false,
map[string]string{},
map[string]string{
dnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
dnsControllerHostnameAnnotationKey: "foo.example.org., bar.example.org",
kopsDnsControllerInternalHostnameAnnotationKey: "internal.foo.example.org., internal.bar.example.org",
kopsDnsControllerHostnameAnnotationKey: "foo.example.org., bar.example.org",
},
nil,
[]*endpoint.Endpoint{},
Expand Down Expand Up @@ -2958,7 +2958,7 @@ func TestHeadlessServicesHostIP(t *testing.T) {
require.NoError(t, err)

address := v1.EndpointAddress{
IP: "4.3.2.1",
IP: "4.3.2.1",
TargetRef: tc.targetRefs[i],
}
if tc.podsReady[i] {
Expand Down

0 comments on commit 05973fc

Please sign in to comment.