Skip to content

Commit a6bd2a4

Browse files
authored
refactor:crd deployment (#952)
* refactor: moved CRDs into the crds folder This follow the rational expressed by the helm authors: - <https://github.com/helm/community/blob/main/hips/hip-0011.md> TLDR: modifying a CRD (update, deletion) should be a manual process because the ramifications are quite complex (CR deletion for example). CRD deployment can be skipped using the --skip-crds option. Some related issues: - <helm/helm#5871> - <helm/helm#7735> - <helm/helm#10585> * chore(helm): remove the deployCrd value This can be done at helm level using the --skip-crds option since the CRDs have been moved to the crds folder. * refactor: cleanup RBAC rules While it's possible to have multiple apiGroups and resources, the list made would not apply on OpenShift. The generated lists would contain invalid entries such as networking items in the apps group and all the combinations possible. * fix: overwrite CRD rather than adding to it The original code appends to the file rather than overwriting its content.
1 parent 6e8a890 commit a6bd2a4

8 files changed

Lines changed: 21 additions & 25 deletions

File tree

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ all: build
9090
# More info on the awk command:
9191
# http://linuxcommand.org/lc3_adv_awk.php
9292

93-
HELM_CRD_TEMPLATE ?= helm-chart/amalthea-sessions/templates/amaltheasession-crd.yaml
93+
HELM_CRD_TEMPLATE ?= helm-chart/amalthea-sessions/crds/amaltheasession.yaml
9494

9595
.PHONY: help
9696
help: ## Display this help.
@@ -101,10 +101,8 @@ help: ## Display this help.
101101
.PHONY: manifests
102102
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
103103
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
104-
echo "{{- if .Values.deployCrd -}}" > $(HELM_CRD_TEMPLATE)
105-
echo "# This manifest is auto-generated from the makefile do not edit manually." >> $(HELM_CRD_TEMPLATE)
104+
echo "# This manifest is auto-generated from the makefile do not edit manually." > $(HELM_CRD_TEMPLATE)
106105
cat config/crd/bases/*yaml >> $(HELM_CRD_TEMPLATE)
107-
echo "{{- end }}" >> $(HELM_CRD_TEMPLATE)
108106

109107
.PHONY: generate
110108
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.

helm-chart/amalthea-sessions/templates/amaltheasession-crd.yaml renamed to helm-chart/amalthea-sessions/crds/amaltheasession.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{- if .Values.deployCrd -}}
21
# This manifest is auto-generated from the makefile do not edit manually.
32
---
43
apiVersion: apiextensions.k8s.io/v1
@@ -6493,4 +6492,3 @@ spec:
64936492
storage: true
64946493
subresources:
64956494
status: {}
6496-
{{- end }}

helm-chart/amalthea-sessions/templates/manager-rbac.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,20 @@ rules:
4747
resources: [pods]
4848
verbs: [get, list, watch]
4949
# Amalthea: child resources we produce
50-
# Note that we do not patch/update/delete them ever.
5150
- apiGroups:
5251
- ""
53-
- apps
54-
- networking.k8s.io
5552
resources:
56-
- statefulsets
5753
- persistentvolumeclaims
5854
- services
55+
verbs: [create, get, list, watch]
56+
- apiGroups:
57+
- apps
58+
resources:
59+
- statefulsets
60+
verbs: [create, get, list, watch]
61+
- apiGroups:
62+
- networking.k8s.io
63+
resources:
5964
- ingresses
6065
verbs: [create, get, list, watch, patch, update]
6166
# Required for hibernating sessions

helm-chart/amalthea-sessions/values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ controllerManager:
2525
kubernetesClusterDomain: cluster.local
2626
# If set to true then the operator will watch and operate in all namespaces
2727
clusterScoped: false
28-
# Whether to install the CRD
29-
deployCrd: true
3028
# Whether to install the dependencies or not
3129
deploy:
3230
csiRclone: false

helm-chart/amalthea/templates/crd.yaml renamed to helm-chart/amalthea/crds/jupyterserver.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{{- if .Values.deployCrd -}}
21
# This manifest is auto-generated from controller/crds/jupyter_server.yaml, do not modify.
32
apiVersion: apiextensions.k8s.io/v1
43
kind: CustomResourceDefinition
@@ -307,4 +306,3 @@ spec:
307306
default:
308307
children: {}
309308
mainPod: {}
310-
{{- end }}

helm-chart/amalthea/templates/rbac/_rbac_rules.tpl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,22 @@
2626
# Note that we do not patch/update/delete them ever.
2727
- apiGroups:
2828
- ""
29-
- apps
30-
- networking.k8s.io
3129
resources:
32-
- statefulsets
3330
- persistentvolumeclaims
3431
- services
35-
- ingresses
3632
- secrets
3733
- configmaps
3834
verbs: [create, get, list, watch]
35+
- apiGroups:
36+
- apps
37+
resources:
38+
- statefulsets
39+
verbs: [create, get, list, watch]
40+
- apiGroups:
41+
- networking.k8s.io
42+
resources:
43+
- ingresses
44+
verbs: [create, get, list, watch]
3945

4046
# Required for hibernating sessions
4147
- apiGroups: ["apps"]

helm-chart/amalthea/values.schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@
6666
},
6767
"type": "object"
6868
},
69-
"deployCrd": {
70-
"description": "Should the helm chart apply the k8s CRD.",
71-
"type": "boolean"
72-
},
7369
"networkPolicies": {
7470
"description": "Enable and configure network policies for the controller and jupyter servers.",
7571
"type": "object",
@@ -436,7 +432,6 @@
436432
},
437433
"required": [
438434
"scope",
439-
"deployCrd",
440435
"networkPolicies",
441436
"kopf",
442437
"extraChildResources",

helm-chart/amalthea/values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ scope:
3535
# will only operate in the namespace where the helm chart is deployed.
3636
# namespaces: ["default"]
3737

38-
deployCrd: true # whether to deploy the jupyterserver CRD
39-
4038
networkPolicies:
4139
# # Enable sensible, default network policies. Note that until cluster-wide
4240
# # network policies are available in Kubernetes (https://github.com/kubernetes/enhancements/issues/2091),

0 commit comments

Comments
 (0)