Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm: Template CRDs directly to get standard k8s labels #2516

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ these files (`pkg/k8s/`), you need to run code generation:

```shell
make crds
make -C install/kubernetes tetragon/crds-yaml
make -C install/kubernetes tetragon/templates/crds
```

## Making changes to Helm chart
Expand Down
19 changes: 12 additions & 7 deletions install/kubernetes/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CRDS := $(REPO_ROOT)/pkg/k8s/apis/cilium.io/client/crds/v1alpha1
HELM ?= docker run --rm -v ./$(TETRAGON_CHART):/apps $(HELM_IMAGE)

.PHONY: all
all: deps $(TETRAGON_CHART)/crds-yaml lint docs
all: deps $(TETRAGON_CHART)/templates/crds lint docs

.PHONY: deps
deps:
Expand All @@ -32,11 +32,16 @@ docs:
./export-doc.sh $(REPO_ROOT)/docs/content/en/docs/reference/helm-chart.md

# NB: Helm has an "official" way to install CRDs which requires simply putting
# them in the crds directory. This method doesn't prevents accidental deletion
# them in the top-level crds directory. This method prevents accidental deletion
# of custom resources, because it doesn't delete CRDs when the chart is
# uninstalled. However, it doesn't support CRD upgrades, which is why we opt to
# install CRDs alongside other resources. This means we can't put them in the
# crds directory, so we name in crds-yaml instead.
.PHONY: $(TETRAGON_CHART)/crds-yaml
$(TETRAGON_CHART)/crds-yaml: $(CRDS)
cp -rf $(CRDS)/. $(TETRAGON_CHART)/crds-yaml
# install CRDs alongside other resources.
.PHONY: $(TETRAGON_CHART)/templates/crds
$(TETRAGON_CHART)/templates/crds: $(CRDS)
mkdir -p $@
for file in $(CRDS)/*.yaml; do \
template_file="$@/$$(basename $$file)"; \
echo "{{- if eq .Values.crds.installMethod \"helm\" }}" > "$$template_file"; \
cat "$$file" >> "$$template_file"; \
echo "{{- end }}" >> "$$template_file"; \
done
6 changes: 0 additions & 6 deletions install/kubernetes/tetragon/templates/crds.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.crds.installMethod "helm" }}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -93,3 +94,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.crds.installMethod "helm" }}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -2027,3 +2028,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq .Values.crds.installMethod "helm" }}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down Expand Up @@ -2027,3 +2028,4 @@ status:
plural: ""
conditions: []
storedVersions: []
{{- end }}
Loading