Skip to content

Commit

Permalink
feat(helm-chart): seperate CRDs into subchart
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Gaiser <[email protected]>
  • Loading branch information
sebastiangaiser committed Dec 4, 2023
1 parent b4347c3 commit 61bee0b
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ manager: codegen fmt vet ## Build manager binary
manifests: ${CONTROLLER_GEN} ## Generate manifests e.g. CRD, RBAC etc.
cd pkg/sdk && $(CONTROLLER_GEN) $(CRD_OPTIONS) webhook paths="./..." output:crd:artifacts:config=../../config/crd/bases output:webhook:artifacts:config=../../config/webhook
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./controllers/..." output:rbac:artifacts:config=./config/rbac
cp config/crd/bases/* charts/logging-operator/crds/
cp config/crd/bases/* charts/logging-operator/charts/crds/templates/
echo "{{- if .Values.rbac.enabled }}" > ./charts/logging-operator/templates/clusterrole.yaml
cat config/rbac/role.yaml | sed -e 's@manager-role@{{ template "logging-operator.fullname" . }}@' | sed -e '/creationTimestamp/d' | cat >> ./charts/logging-operator/templates/clusterrole.yaml
echo "{{- end }}" >> ./charts/logging-operator/templates/clusterrole.yaml
Expand Down
4 changes: 4 additions & 0 deletions charts/logging-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ home: https://kube-logging.github.io
sources:
- https://github.com/kube-logging/logging-operator
- https://github.com/kube-logging/helm-charts/tree/main/charts/logging-operator
dependencies:
- name: crds
condition: crds.enabled
version: 0.0.0
4 changes: 3 additions & 1 deletion charts/logging-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ This chart bootstraps a [Logging Operator](https://github.com/kube-logging/loggi

## Installing CRDs

Use `createCustomResource=false` with Helm v3 to avoid trying to create CRDs from the `crds` folder and from templates at the same time.
Use `createCustomResource=false` (deprecated) with Helm v3 to avoid trying to create CRDs from the `crds` folder and from templates at the same time.
The prefered way is to install the crds via the subchart.
This could be disabled by setting `crds.enabled=false`.

## Values

Expand Down
7 changes: 7 additions & 0 deletions charts/logging-operator/charts/crds/Charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
type: application
name: crds
version: 0.0.0
appVersion: latest
description: Logging-operator CRDs.
home: https://kube-logging.github.io
2 changes: 1 addition & 1 deletion charts/logging-operator/templates/crds.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.createCustomResource -}}
{{- range $path, $bytes := .Files.Glob "crds/*.yaml" }}
{{- range $path, $bytes := .Files.Glob "charts/crds/templates/*.yaml" }}
{{ $.Files.Get $path }}
---
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/logging-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ annotations: {}
# -- Deploy CRDs used by Logging Operator.
createCustomResource: false

# -- Deploy CRDs as subchart.
crds:
enabled: true

http:
# -- HTTP listen port number.
port: 8080
Expand Down

0 comments on commit 61bee0b

Please sign in to comment.