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

feat(chart): prevent CRDs from being recycled #458

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions chart/charts/crds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ A Helm chart that collects CustomResourceDefinitions (CRDs) from Mayastor.

## Values

| Key | Description | Default |
|:----|:------------|:--------|
| csi.​volumeSnapshots.​enabled | Install Volume Snapshot CRDs | `true` |
| jaeger.​enabled | Install Jaeger CRDs | `true` |
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| csi.volumeSnapshots.annotations | object | `{}` | Annotations to be added to all CRDs |
| csi.volumeSnapshots.enabled | bool | `true` | Install Volume Snapshot CRDs |
| csi.volumeSnapshots.keep | bool | `true` | Keep CRDs on chart uninstall |
| jaeger.annotations | object | `{}` | Annotations to be added to all CRDs |
| jaeger.enabled | bool | `true` | Install Jaeger CRDs |
| jaeger.keep | bool | `true` | Keep CRDs on chart uninstall |

21 changes: 20 additions & 1 deletion chart/charts/crds/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,23 @@
{{- end -}}

{{- $output -}}
{{- end -}}
{{- end -}}

{{/*
Adds extra annotations to CRDs. This targets two scenarios: preventing CRD recycling in case
the chart is removed; and adding custom annotations.
NOTE: This function assumes the element `metadata.annotations` already exists.

Usage:
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
*/}}

{{- define "crds.extraAnnotations" -}}
{{- if .keep -}}
helm.sh/resource-policy: keep
{{ end }}
{{- with .annotations }}
{{- toYaml . }}
{{- end }}
{{- end -}}

1 change: 1 addition & 0 deletions chart/charts/crds/templates/csi-volume-snapshot-class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshotclasses.snapshot.storage.k8s.io
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshotcontents.snapshot.storage.k8s.io
spec:
Expand Down
1 change: 1 addition & 0 deletions chart/charts/crds/templates/csi-volume-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ metadata:
annotations:
tiagolobocastro marked this conversation as resolved.
Show resolved Hide resolved
api-approved.kubernetes.io: https://github.com/kubernetes-csi/external-snapshotter/pull/814
controller-gen.kubebuilder.io/version: v0.11.3
{{- include "crds.extraAnnotations" .Values.csi.volumeSnapshots | nindent 4 }}
creationTimestamp: null
name: volumesnapshots.snapshot.storage.k8s.io
spec:
Expand Down
4 changes: 4 additions & 0 deletions chart/charts/crds/templates/jaeger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: jaegers.jaegertracing.io
{{- if or (.Values.jaeger.keep) (.Values.jaeger.annotations) }}
annotations:
{{- include "crds.extraAnnotations" .Values.jaeger | nindent 4 }}
{{- end }}
labels:
app: jaeger-operator
spec:
Expand Down
13 changes: 13 additions & 0 deletions chart/charts/crds/values.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
jaeger:
# -- Install Jaeger CRDs
enabled: true
# -- Keep CRDs on chart uninstall
keep: true
# -- Annotations to be added to all CRDs
annotations: {}
# Example for Argo CD to prevent CRDs from being recycled
# argocd.argoproj.io/sync-options: Prune=false

csi:
volumeSnapshots:
# -- Install Volume Snapshot CRDs
enabled: true
# -- Keep CRDs on chart uninstall
keep: true
# -- Annotations to be added to all CRDs
annotations: {}
# Example for Argo CD to prevent CRDs from being recycled
# argocd.argoproj.io/sync-options: Prune=false

Loading