Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add external DNS endpoint CRD #2762

Merged
merged 6 commits into from
Jun 22, 2022
Merged

Add external DNS endpoint CRD #2762

merged 6 commits into from
Jun 22, 2022

Conversation

jjngx
Copy link
Contributor

@jjngx jjngx commented Jun 16, 2022

Proposed changes

This PR introduces ExternalDNS CRD including examples and tests.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation (README in examples)
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Testing

➜  kubernetes-ingress git:(dnsendpoint-crd) make test
go test -tags=aws -shuffle=on -race ./...
ok  	github.com/nginxinc/kubernetes-ingress/cmd/nginx-ingress	1.867s
ok  	github.com/nginxinc/kubernetes-ingress/internal/certmanager	4.629s
?   	github.com/nginxinc/kubernetes-ingress/internal/certmanager/test_files	[no test files]
ok  	github.com/nginxinc/kubernetes-ingress/internal/configs	0.927s
ok  	github.com/nginxinc/kubernetes-ingress/internal/configs/version1	0.575s
ok  	github.com/nginxinc/kubernetes-ingress/internal/configs/version2	0.509s
ok  	github.com/nginxinc/kubernetes-ingress/internal/k8s	0.975s
ok  	github.com/nginxinc/kubernetes-ingress/internal/k8s/appprotect	0.410s
ok  	github.com/nginxinc/kubernetes-ingress/internal/k8s/appprotectcommon	0.320s
ok  	github.com/nginxinc/kubernetes-ingress/internal/k8s/appprotectdos	0.582s
ok  	github.com/nginxinc/kubernetes-ingress/internal/k8s/secrets	0.545s
?   	github.com/nginxinc/kubernetes-ingress/internal/metrics	[no test files]
ok  	github.com/nginxinc/kubernetes-ingress/internal/metrics/collectors	0.873s
ok  	github.com/nginxinc/kubernetes-ingress/internal/nginx	0.919s
?   	github.com/nginxinc/kubernetes-ingress/pkg/apis/configuration	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/apis/configuration/v1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/apis/configuration/v1alpha1	[no test files]
ok  	github.com/nginxinc/kubernetes-ingress/pkg/apis/configuration/validation	0.741s
?   	github.com/nginxinc/kubernetes-ingress/pkg/apis/dos	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/apis/dos/v1beta1	[no test files]
ok  	github.com/nginxinc/kubernetes-ingress/pkg/apis/dos/validation	0.646s
?   	github.com/nginxinc/kubernetes-ingress/pkg/apis/externaldns	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/apis/externaldns/v1	[no test files]
ok  	github.com/nginxinc/kubernetes-ingress/pkg/apis/externaldns/validation	0.596s
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/fake	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/scheme	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/configuration/v1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/configuration/v1/fake	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/configuration/v1alpha1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/configuration/v1alpha1/fake	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/dos/v1beta1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/clientset/versioned/typed/dos/v1beta1/fake	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions/configuration	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions/configuration/v1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions/configuration/v1alpha1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions/dos	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions/dos/v1beta1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/informers/externalversions/internalinterfaces	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/listers/configuration/v1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/listers/configuration/v1alpha1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/pkg/client/listers/dos/v1beta1	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/tests/test-servers/tcp	[no test files]
?   	github.com/nginxinc/kubernetes-ingress/tests/test-servers/udp	[no test files]

With gotestdox targeting new package:

➜  kubernetes-ingress git:(dnsendpoint-crd) gotestdox pkg/apis/externaldns/validation/*.go
command-line-arguments:
 ✔ Validate DNS endpoint with single valid endpoint (0.00s)
 ✔ Validate DNS endpoint with multiple valid endpoints (0.00s)
 ✔ Validate DNS endpoint with multiple valid endpoints and multiple targets (0.00s)
 ✔ Validate DNS endpoint (0.00s)
 ✔ ValidateDNSEndpoint returns error on not supported DNS record type (0.00s)
 ✔ ValidateDNSEndpoint returns error on bogus target hostname (0.00s)
 ✔ ValidateDNSEndpoint returns error on duplicated target (0.00s)
 ✔ ValidateDNSEndpoint returns error on bogus ttl record (0.00s)
 ✔ ValidateDNSEndpoint returns error on bogus dns name (0.00s)
 ✔ ValidateDNSEndpoint returns error on empty dns name (0.00s)
 ✔ ValidateDNSEndpoint returns error on bogus target name (0.00s)
 ✔ ValidateDNSEndpoint returns error on empty target name (0.00s)
 ✔ ValidateDNSEndpoint returns error on bogus target name# 01 (0.00s)
 ✔ ValidateDNSEndpoint returns error on empty slice of endpoints (0.00s)
 ✔ ValidateDNSEndpoint returns error on (0.00s)

With local kind cluster:

➜  kubernetes-ingress git:(dnsendpoint-crd) kubectl create -f deployments/common/crds/externaldns.nginx.org_dnsendpoints.yaml
customresourcedefinition.apiextensions.k8s.io/dnsendpoints.externaldns.nginx.org created
➜  kubernetes-ingress git:(externaldns) ✗ kubectl create -f dnstest.yaml
dnsendpoint.externaldns.nginx.org/dnsundertest created

where dnstest.yaml:

apiVersion: externaldns.nginx.org/v1
kind: DNSEndpoint
metadata:
  name: dnsundertest
spec:
  endpoints:
  - dnsName: example.co.uk
    recordTTL: 3600
    recordType: A
    targets:
    - 192.168.99.216
  - dnsName: example.ie
    recordTTL: 1800
    recordType: A
    targets:
    - 192.168.2.3
➜  kubernetes-ingress git:(dnsendpoint-crd) kubectl get dnsendpoints
NAME           AGE
dnsundertest   4m25s
➜  kubernetes-ingress git:(dnsendpoint-crd) kubectl describe dnsendpoints dnsundertest
Name:         dnsundertest
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:  externaldns.nginx.org/v1
Kind:         DNSEndpoint
Metadata:
  Creation Timestamp:  2022-06-16T12:45:15Z
  Generation:          1
  Managed Fields:
    API Version:  externaldns.nginx.org/v1
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        .:
        f:endpoints:
    Manager:         kubectl-create
    Operation:       Update
    Time:            2022-06-16T12:45:15Z
  Resource Version:  1548492
  UID:               50330dea-0108-4a67-892d-cc46c5e52d1c
Spec:
  Endpoints:
    Dns Name:     example.co.uk
    Record TTL:   3600
    Record Type:  A
    Targets:
      192.168.99.216
    Dns Name:     example.ie
    Record TTL:   1800
    Record Type:  A
    Targets:
      192.168.2.3
Events:  <none>

@jjngx jjngx added enhancement Pull requests for new features/feature enhancements go Pull requests that update Go code labels Jun 16, 2022
@github-actions github-actions bot added dependencies Pull requests that update a dependency file documentation Pull requests/issues for documentation labels Jun 16, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2022

Codecov Report

Merging #2762 (65d69eb) into main (56c756d) will increase coverage by 0.04%.
The diff coverage is 95.52%.

❗ Current head 65d69eb differs from pull request most recent head 32b5c5e. Consider uploading reports for the commit 32b5c5e to get more accurate results

@@            Coverage Diff             @@
##             main    #2762      +/-   ##
==========================================
+ Coverage   53.84%   53.88%   +0.04%     
==========================================
  Files          52       53       +1     
  Lines       14936    14929       -7     
==========================================
+ Hits         8042     8045       +3     
+ Misses       6627     6619       -8     
+ Partials      267      265       -2     
Impacted Files Coverage Δ
pkg/apis/externaldns/validation/externaldns.go 95.52% <95.52%> (ø)
internal/k8s/utils.go 11.76% <0.00%> (-2.53%) ⬇️
internal/k8s/controller.go 11.37% <0.00%> (+<0.01%) ⬆️
internal/k8s/configuration.go 95.86% <0.00%> (+0.10%) ⬆️
...ternal/k8s/appprotect/app_protect_configuration.go 86.74% <0.00%> (+0.57%) ⬆️
internal/k8s/validation.go 99.22% <0.00%> (+1.42%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Contributor

@ciarams87 ciarams87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make update-codegen needs to be ran to generate the client code

Edit:

The hack/update-codegen file needs to be updated on line 36 to generate this code from
"configuration:v1alpha1,v1 dos:v1beta1" \ to
"configuration:v1alpha1,v1 dos:v1beta1 externaldns:v1" \

@jjngx jjngx dismissed ciarams87’s stale review June 22, 2022 11:26

change complete

@jjngx jjngx merged commit e0590e5 into main Jun 22, 2022
@jjngx jjngx deleted the dnsendpoint-crd branch June 22, 2022 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file documentation Pull requests/issues for documentation enhancement Pull requests for new features/feature enhancements go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants