Skip to content

Commit 355c665

Browse files
committed
Fix kubernetes-sigs#2640: Optionaly add CRD manifest for DNSEndpoint to helm deliverables
Since DNSEndpoint can be used as one of the sources for external-dns, it would be handy to be able to deploy its definition file together with the main deployment. More info: - piggy-backing on the make crd to create such template file under charts/external-dns/templates/ - by default it's the same as before and the CRD is not deployed using helm chart - to enable the CRD deployment, one has to set helm value deployCrd=true Signed-off-by: Jirka Kremser <[email protected]>
1 parent b1ccdfe commit 355c665

File tree

5 files changed

+126
-8
lines changed

5 files changed

+126
-8
lines changed

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ lint: licensecheck go-lint
7373
# generates CRD using controller-gen
7474
crd: controller-gen
7575
${CONTROLLER_GEN} crd:crdVersions=v1 paths="./endpoint/..." output:crd:stdout > docs/contributing/crd-source/crd-manifest.yaml
76+
@echo -n "{{- if .Values.deployCrd }}" > charts/external-dns/templates/crd.yaml
77+
cat docs/contributing/crd-source/crd-manifest.yaml >> charts/external-dns/templates/crd.yaml
78+
@echo "{{- end }}" >> charts/external-dns/templates/crd.yaml
7679

7780
# The verify target runs tasks similar to the CI tasks, but without code coverage
7881
.PHONY: verify test
+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{{- if .Values.deployCrd }}
2+
---
3+
apiVersion: apiextensions.k8s.io/v1
4+
kind: CustomResourceDefinition
5+
metadata:
6+
annotations:
7+
controller-gen.kubebuilder.io/version: v0.7.0
8+
creationTimestamp: null
9+
name: dnsendpoints.externaldns.k8s.io
10+
spec:
11+
group: externaldns.k8s.io
12+
names:
13+
kind: DNSEndpoint
14+
listKind: DNSEndpointList
15+
plural: dnsendpoints
16+
singular: dnsendpoint
17+
scope: Namespaced
18+
versions:
19+
- name: v1alpha1
20+
schema:
21+
openAPIV3Schema:
22+
properties:
23+
apiVersion:
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
27+
type: string
28+
kind:
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
type: string
33+
metadata:
34+
type: object
35+
spec:
36+
description: DNSEndpointSpec defines the desired state of DNSEndpoint
37+
properties:
38+
endpoints:
39+
items:
40+
description: Endpoint is a high-level way of a connection between
41+
a service and an IP
42+
properties:
43+
dnsName:
44+
description: The hostname of the DNS record
45+
type: string
46+
labels:
47+
additionalProperties:
48+
type: string
49+
description: Labels stores labels defined for the Endpoint
50+
type: object
51+
providerSpecific:
52+
description: ProviderSpecific stores provider specific config
53+
items:
54+
description: ProviderSpecificProperty holds the name and value
55+
of a configuration which is specific to individual DNS providers
56+
properties:
57+
name:
58+
type: string
59+
value:
60+
type: string
61+
type: object
62+
type: array
63+
recordTTL:
64+
description: TTL for the record
65+
format: int64
66+
type: integer
67+
recordType:
68+
description: RecordType type of record, e.g. CNAME, A, SRV,
69+
TXT etc
70+
type: string
71+
setIdentifier:
72+
description: Identifier to distinguish multiple records with
73+
the same name and type (e.g. Route53 records with routing
74+
policies other than 'simple')
75+
type: string
76+
targets:
77+
description: The targets the DNS record points to
78+
items:
79+
type: string
80+
type: array
81+
type: object
82+
type: array
83+
type: object
84+
status:
85+
description: DNSEndpointStatus defines the observed state of DNSEndpoint
86+
properties:
87+
observedGeneration:
88+
description: The generation observed by the external-dns controller.
89+
format: int64
90+
type: integer
91+
type: object
92+
type: object
93+
served: true
94+
storage: true
95+
subresources:
96+
status: {}
97+
status:
98+
acceptedNames:
99+
kind: ""
100+
plural: ""
101+
conditions: []
102+
storedVersions: []
103+
{{- end }}

charts/external-dns/values.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ serviceAccount:
2121
# If not set and create is true, a name is generated using the fullname template
2222
name: ""
2323

24+
# Specifies whether the custom resource definition of DNSEndpoint should be deployed
25+
deployCrd: false
26+
2427
rbac:
2528
# Specifies whether RBAC resources should be created
2629
create: true

docs/contributing/crd-source.md

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Apply this to register the CRD
8888
$ kubectl apply --validate=false -f docs/contributing/crd-source/crd-manifest.yaml
8989
customresourcedefinition.apiextensions.k8s.io "dnsendpoints.externaldns.k8s.io" created
9090
```
91+
Or alternatively deploy the external-dns helm chart with value `deployCrd=true`.
9192

9293
Then you can create the dns-endpoint yaml similar to [dnsendpoint-example](crd-source/dnsendpoint-example.yaml)
9394

docs/contributing/crd-source/crd-manifest.yaml

+16-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ apiVersion: apiextensions.k8s.io/v1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.5.0
8-
api-approved.kubernetes.io: "https://github.com/kubernetes-sigs/external-dns/pull/2007"
7+
controller-gen.kubebuilder.io/version: v0.7.0
98
creationTimestamp: null
109
name: dnsendpoints.externaldns.k8s.io
1110
spec:
@@ -22,10 +21,14 @@ spec:
2221
openAPIV3Schema:
2322
properties:
2423
apiVersion:
25-
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
2627
type: string
2728
kind:
28-
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
2932
type: string
3033
metadata:
3134
type: object
@@ -34,7 +37,8 @@ spec:
3437
properties:
3538
endpoints:
3639
items:
37-
description: Endpoint is a high-level way of a connection between a service and an IP
40+
description: Endpoint is a high-level way of a connection between
41+
a service and an IP
3842
properties:
3943
dnsName:
4044
description: The hostname of the DNS record
@@ -47,7 +51,8 @@ spec:
4751
providerSpecific:
4852
description: ProviderSpecific stores provider specific config
4953
items:
50-
description: ProviderSpecificProperty holds the name and value of a configuration which is specific to individual DNS providers
54+
description: ProviderSpecificProperty holds the name and value
55+
of a configuration which is specific to individual DNS providers
5156
properties:
5257
name:
5358
type: string
@@ -60,10 +65,13 @@ spec:
6065
format: int64
6166
type: integer
6267
recordType:
63-
description: RecordType type of record, e.g. CNAME, A, SRV, TXT etc
68+
description: RecordType type of record, e.g. CNAME, A, SRV,
69+
TXT etc
6470
type: string
6571
setIdentifier:
66-
description: Identifier to distinguish multiple records with the same name and type (e.g. Route53 records with routing policies other than 'simple')
72+
description: Identifier to distinguish multiple records with
73+
the same name and type (e.g. Route53 records with routing
74+
policies other than 'simple')
6775
type: string
6876
targets:
6977
description: The targets the DNS record points to

0 commit comments

Comments
 (0)