-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the operator chart to deploy CRDs separately
- Loading branch information
Showing
20 changed files
with
161 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
examples/chart/teleport-cluster/charts/teleport-operator/templates/crds.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{{- /* This template iterates over every CRD in the `operator-crds/` directory | ||
and creates them if needed. It also adds common labels, like any other | ||
Helm-deployed resource. | ||
|
||
We cannot rely on the "crds/" Helm directory as Helm's startegy is "fire and forget". | ||
We have no way to update the CRDs after the initial deployment. As Teleport keeps | ||
adding new field to existing CRs, we need a deployment strategy that supports | ||
updating CRDs. | ||
|
||
The obvious solution would be to have a separate chart for CRs but we wanted to | ||
have everything functional in a single "helm install", hence the rube goldberg | ||
mechanism to try to guess what to do with the CRDs (see the implementation of | ||
shouldInstallCRDs in _helpers.yaml for more details). */ -}} | ||
{{- if eq (include "teleport-cluster.operator.shouldInstallCRDs" . ) "true" -}} | ||
{{ $currentScope := .}} | ||
{{ range $path, $_ := .Files.Glob "operator-crds/*" }} | ||
{{- with $currentScope}} | ||
{{- $crd := (.Files.Get $path | fromYaml) -}} | ||
{{- $injectedCRD := mustMergeOverwrite $crd (include "teleport-cluster.operator.crdOverrides" $currentScope | fromYaml) -}} | ||
{{- toYaml $injectedCRD -}} | ||
{{- end }} | ||
--- | ||
{{ end }} | ||
{{- end -}} |
44 changes: 44 additions & 0 deletions
44
examples/chart/teleport-cluster/charts/teleport-operator/tests/crds_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
suite: Operator CRDs | ||
templates: | ||
- crds.yaml | ||
tests: | ||
- it: creates no CRDs when installCRDs is "never" | ||
set: | ||
installCRDs: "never" | ||
enabled: true | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
- it: creates CRDs when installCRDs is "always" | ||
set: | ||
installCRDs: "always" | ||
enabled: false | ||
asserts: | ||
- containsDocument: | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
name: teleportrolesv7.resources.teleport.dev | ||
- it: labels CRDs | ||
set: | ||
installCRDs: "always" | ||
enabled: false | ||
asserts: | ||
- equal: | ||
path: metadata.labels.[teleport.dev/release] | ||
value: NAMESPACE_RELEASE-NAME | ||
- it: creates CRDs when installCRDs is "dynamic" and operator enabled | ||
set: | ||
installCRDs: "dynamic" | ||
enabled: true | ||
asserts: | ||
- containsDocument: | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
name: teleportrolesv7.resources.teleport.dev | ||
- it: creates no CRDs when installCRDs is "dynamic" and operator disabled (and no existing CRD) | ||
set: | ||
installCRDs: "dynamic" | ||
enabled: false | ||
asserts: | ||
- hasDocuments: | ||
count: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters