From ee6f2e654adc271992249d3b827f2a47a4649df0 Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Tue, 22 Jul 2025 17:18:50 +0530 Subject: [PATCH] helm: add helm support for new csi-operator This commit test csi-operator helm chart as a dependencies with rook-ceph operator helm chart. With these changes csi-operator will be installed as a part of rook-ceph operator helm chart. Signed-off-by: subhamkrai --- .gitignore | 6 +++ Documentation/Helm-Charts/operator-chart.md | 4 ++ Makefile | 3 +- build/makelib/helm.mk | 37 +++++++++++++++++++ deploy/charts/rook-ceph/Chart.yaml | 11 ++++-- deploy/charts/rook-ceph/templates/NOTES.txt | 6 ++- .../charts/rook-ceph/templates/configmap.yaml | 1 + deploy/charts/rook-ceph/values.yaml | 9 +++++ 8 files changed, 71 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2744899ea..959562f56 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,12 @@ /_output +deploy/charts/rook-ceph/charts/ceph-csi-operator-* +deploy/charts/rook-ceph/charts/library-* +deploy/charts/rook-ceph-cluster/charts/library-* +deploy/charts/rook-ceph/Chart.lock +deploy/charts/rook-ceph-cluster/Chart.lock + /tests/integration/rook-test/ # OLM related stuff diff --git a/Documentation/Helm-Charts/operator-chart.md b/Documentation/Helm-Charts/operator-chart.md index 2079f5169..5a9411f03 100644 --- a/Documentation/Helm-Charts/operator-chart.md +++ b/Documentation/Helm-Charts/operator-chart.md @@ -46,6 +46,9 @@ The following table lists the configurable parameters of the rook-operator chart |-----------|-------------|---------| | `allowLoopDevices` | If true, loop devices are allowed to be used for osds in test clusters | `false` | | `annotations` | Pod annotations | `{}` | +| `ceph-csi-operator.controllerManager.manager.env.csiServiceAccountPrefix` | | `"ceph-csi-"` | +| `ceph-csi-operator.fullnameOverride` | | `"ceph-csi"` | +| `ceph-csi-operator.nameOverride` | | `"ceph-csi"` | | `cephCommandsTimeoutSeconds` | The timeout for ceph commands in seconds | `"15"` | | `containerSecurityContext` | Set the container security context for the operator | `{"capabilities":{"drop":["ALL"]},"runAsGroup":2016,"runAsNonRoot":true,"runAsUser":2016}` | | `crds.enabled` | Whether the helm chart should create and update the CRDs. If false, the CRDs must be managed independently with deploy/examples/crds.yaml. **WARNING** Only set during first deployment. If later disabled the cluster may be DESTROYED. If the CRDs are deleted in this case, see [the disaster recovery guide](https://rook.io/docs/rook/latest/Troubleshooting/disaster-recovery/#restoring-crds-after-deletion) to restore them. | `true` | @@ -126,6 +129,7 @@ The following table lists the configurable parameters of the rook-operator chart | `csi.registrar.tag` | Registrar image tag | `"v2.13.0"` | | `csi.resizer.repository` | Kubernetes CSI resizer image repository | `"registry.k8s.io/sig-storage/csi-resizer"` | | `csi.resizer.tag` | Resizer image tag | `"v1.13.2"` | +| `csi.rookUseCsiOperator` | | `false` | | `csi.serviceMonitor.enabled` | Enable ServiceMonitor for Ceph CSI drivers | `false` | | `csi.serviceMonitor.interval` | Service monitor scrape interval | `"10s"` | | `csi.serviceMonitor.labels` | ServiceMonitor additional labels | `{}` | diff --git a/Makefile b/Makefile index 3f366d440..e42790e25 100644 --- a/Makefile +++ b/Makefile @@ -205,6 +205,7 @@ mod.check: go.mod.check ## Check if any go modules changed. mod.update: go.mod.update ## Update all go modules. clean: ## Remove all files that are created by building. + @$(MAKE) helm.dependency.clean @$(MAKE) go.mod.clean @$(MAKE) -C images clean @rm -fr $(OUTPUT_DIR) $(WORK_DIR) @@ -222,7 +223,7 @@ crds: $(CONTROLLER_GEN) $(YQ) @GOBIN=$(GOBIN) build/crds/generate-crd-docs.sh gen.rbac: gen-rbac -gen-rbac: $(HELM) $(YQ) ## Generate RBAC from Helm charts +gen-rbac: $(HELM) $(YQ) helm.dependency.build ## Generate RBAC from Helm charts @# output only stdout to the file; stderr for debugging should keep going to stderr HELM=$(HELM) ./build/rbac/gen-common.sh HELM=$(HELM) ./build/rbac/gen-nfs-rbac.sh diff --git a/build/makelib/helm.mk b/build/makelib/helm.mk index f8fe68416..b69b73a16 100644 --- a/build/makelib/helm.mk +++ b/build/makelib/helm.mk @@ -38,6 +38,11 @@ $(HELM): define helm.chart $(HELM_OUTPUT_DIR)/$(1)-$(VERSION).tgz: $(HELM) $(HELM_OUTPUT_DIR) $(shell find $(HELM_CHARTS_DIR)/$(1) -type f) @echo === helm package $(1) + @if [ ! -f $(HELM_CHARTS_DIR)/$(1)/charts/ceph-csi-operator-*.tgz ]; then \ + echo "=== helm repo add (dependencies missing)"; \ + $(HELM) repo add ceph-csi-operator https://ceph.github.io/ceph-csi-operator --force-update; \ + $(MAKE) helm.dependency.update.$(1); \ + fi @rm -rf $(OUTPUT_DIR)/$(1) @cp -aL $(HELM_CHARTS_DIR)/$(1) $(OUTPUT_DIR) @$(SED_IN_PLACE) 's|master|$(VERSION)|g' $(OUTPUT_DIR)/$(1)/values.yaml @@ -53,6 +58,38 @@ $(HELM_INDEX): $(HELM) $(HELM_OUTPUT_DIR) helm.build: $(HELM_INDEX) +# Update helm chart dependencies +define helm.dependency.update +helm.dependency.update.$(1): $(HELM) + @echo === updating helm dependencies for $(1) + @cd $(HELM_CHARTS_DIR)/$(1) && $(HELM) dependency update +helm.dependency.update: helm.dependency.update.$(1) +endef +$(foreach p,$(HELM_CHARTS),$(eval $(call helm.dependency.update,$(p)))) + +# Build helm chart dependencies +define helm.dependency.build +helm.dependency.build.$(1): $(HELM) + @echo === building helm dependencies for $(1) + @cd $(HELM_CHARTS_DIR)/$(1) && $(HELM) dependency build +helm.dependency.build: helm.dependency.build.$(1) +endef +$(foreach p,$(HELM_CHARTS),$(eval $(call helm.dependency.build,$(p)))) + +# Clean up helm dependency artifacts from source directories +define helm.dependency.clean +helm.dependency.clean.$(1): + @echo === cleaning up dependency artifacts for $(1) + @rm -f $(HELM_CHARTS_DIR)/$(1)/charts/*.tgz +helm.dependency.clean: helm.dependency.clean.$(1) +endef +$(foreach p,$(HELM_CHARTS),$(eval $(call helm.dependency.clean,$(p)))) + +.PHONY: helm.dependency.update helm.dependency.build helm.dependency.clean +helm.dependency.update: ## Update helm chart dependencies for all charts +helm.dependency.build: ## Build helm chart dependencies for all charts +helm.dependency.clean: ## Clean up helm dependency artifacts (.tgz files) from source directories + # ==================================================================================== # Makefile helper functions for helm-docs: https://github.com/norwoodj/helm-docs # diff --git a/deploy/charts/rook-ceph/Chart.yaml b/deploy/charts/rook-ceph/Chart.yaml index 9479b8674..aa02baef2 100644 --- a/deploy/charts/rook-ceph/Chart.yaml +++ b/deploy/charts/rook-ceph/Chart.yaml @@ -7,6 +7,11 @@ icon: https://rook.io/images/rook-logo.svg sources: - https://github.com/rook/rook dependencies: -- name: library - version: "0.0.1" - repository: "file://../library" + - name: library + version: "0.0.1" + repository: "file://../library" + - name: ceph-csi-operator + version: 0.4.0 + repository: https://ceph.github.io/ceph-csi-operator + alias: ceph-csi-operator + condition: csi.rookUseCsiOperator diff --git a/deploy/charts/rook-ceph/templates/NOTES.txt b/deploy/charts/rook-ceph/templates/NOTES.txt index 60a3dbabd..9eeb4a8ca 100644 --- a/deploy/charts/rook-ceph/templates/NOTES.txt +++ b/deploy/charts/rook-ceph/templates/NOTES.txt @@ -1,5 +1,4 @@ -The Rook Operator has been installed. Check its status by running: - kubectl --namespace {{ .Release.Namespace }} get pods -l "app=rook-ceph-operator" +The Rook Operator has been installed. Visit https://rook.io/docs/rook/latest for instructions on how to create and configure Rook clusters @@ -9,3 +8,6 @@ Important Notes: - The sample manifests assume you also installed the rook-ceph operator in the `rook-ceph` namespace. - The helm chart includes all the RBAC required to create a CephCluster CRD in the same namespace. - Any disk devices you add to the cluster in the 'CephCluster' must be empty (no filesystem and no partitions). +{{- if .Values.csi.rookUseCsiOperator }} +- The CSI operator will manage the CSI driver lifecycle for RBD, CephFS, and NFS drivers. +{{- end }} diff --git a/deploy/charts/rook-ceph/templates/configmap.yaml b/deploy/charts/rook-ceph/templates/configmap.yaml index 0b050537b..0aa7a7563 100644 --- a/deploy/charts/rook-ceph/templates/configmap.yaml +++ b/deploy/charts/rook-ceph/templates/configmap.yaml @@ -31,6 +31,7 @@ data: {{- end }} {{- if .Values.csi }} + ROOK_USE_CSI_OPERATOR: {{ .Values.csi.rookUseCsiOperator | quote }} ROOK_CSI_ENABLE_RBD: {{ .Values.csi.enableRbdDriver | quote }} ROOK_CSI_ENABLE_CEPHFS: {{ .Values.csi.enableCephfsDriver | quote }} ROOK_CSI_DISABLE_DRIVER: {{ .Values.csi.disableCsiDriver | quote }} diff --git a/deploy/charts/rook-ceph/values.yaml b/deploy/charts/rook-ceph/values.yaml index 1c689864b..521d6039b 100644 --- a/deploy/charts/rook-ceph/values.yaml +++ b/deploy/charts/rook-ceph/values.yaml @@ -77,9 +77,18 @@ containerSecurityContext: # -- If true, loop devices are allowed to be used for osds in test clusters allowLoopDevices: false +ceph-csi-operator: + nameOverride: ceph-csi + fullnameOverride: ceph-csi + controllerManager: + manager: + env: + csiServiceAccountPrefix: "ceph-csi-" + # Settings for whether to disable the drivers or other daemons if they are not # needed csi: + rookUseCsiOperator: false # -- Enable Ceph CSI RBD driver enableRbdDriver: true # -- Enable Ceph CSI CephFS driver