Skip to content

Commit

Permalink
Add support for setting additional annotations on the CRDs
Browse files Browse the repository at this point in the history
This is especially useful since CRDs are now installed through templates.
Because of this change that was introduced in 0.57.0, now running
`helm uninstall` of the operator chart will delete the CRDs as well,
which is a destructive operation.

The workaround is to leverage the special helm.sh/resource-policy=keep
annotation, see https://helm.sh/docs/howto/charts_tips_and_tricks/#tell-helm-not-to-uninstall-a-resource

One currently open issue though, is that the annotation needs to be set
by Helm itself, see helm/helm#10890
So running kubectl annotate on the CRDs as a post-install step doesn't work.
  • Loading branch information
Aurélien Baumann committed Oct 30, 2024
1 parent 4a60374 commit 7910236
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 19 deletions.
2 changes: 1 addition & 1 deletion charts/opentelemetry-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: opentelemetry-operator
version: 0.71.2
version: 0.72.0
description: OpenTelemetry Operator Helm chart for Kubernetes
type: application
home: https://opentelemetry.io/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: {{ include "opentelemetry-operator.webhookCertAnnotation" . }}
controller-gen.kubebuilder.io/version: v0.16.1
{{- range $key, $value := .Values.crds.additionalAnnotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: {{ include "opentelemetry-operator.webhookCertAnnotation" . }}
controller-gen.kubebuilder.io/version: v0.16.1
{{- range $key, $value := .Values.crds.additionalAnnotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
{{- range $key, $value := .Values.crds.additionalAnnotations }}
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
{{- end }}
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down Expand Up @@ -91,7 +91,7 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.16.1
helm.sh/resource-policy: "keep"
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
Expand Down Expand Up @@ -1772,6 +1773,7 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert
controller-gen.kubebuilder.io/version: v0.16.1
helm.sh/resource-policy: "keep"
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
Expand Down Expand Up @@ -11011,6 +11013,7 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
helm.sh/resource-policy: "keep"
creationTimestamp: null
labels:
app.kubernetes.io/name: opentelemetry-operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand All @@ -30,7 +30,7 @@ apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down Expand Up @@ -223,7 +223,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand All @@ -242,7 +242,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand All @@ -26,7 +26,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v1
kind: Service
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down Expand Up @@ -32,7 +32,7 @@ apiVersion: v1
kind: Service
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: opentelemetry-operator
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: "example-opentelemetry-operator-cert-manager"
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: "example-opentelemetry-operator-metrics"
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down Expand Up @@ -44,7 +44,7 @@ metadata:
name: "example-opentelemetry-operator-webhook"
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.71.2
helm.sh/chart: opentelemetry-operator-0.72.0
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.110.0"
app.kubernetes.io/managed-by: Helm
Expand Down
4 changes: 4 additions & 0 deletions charts/opentelemetry-operator/examples/default/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
manager:
collectorImage:
repository: "otel/opentelemetry-collector-k8s"

crds:
additionalAnnotations:
helm.sh/resource-policy: keep
8 changes: 8 additions & 0 deletions charts/opentelemetry-operator/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,14 @@
"examples": [
true
]
},
"additionalAnnotations": {
"type": "object",
"default": {},
"title": "The serviceAnnotations Schema",
"required": [],
"properties": {},
"examples": [{}]
}
},
"examples": [{
Expand Down
2 changes: 2 additions & 0 deletions charts/opentelemetry-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ admissionWebhooks:
## See https://github.com/open-telemetry/opentelemetry-helm-charts/blob/main/charts/opentelemetry-operator/UPGRADING.md#0560-to-0570 for more details.
crds:
create: true
# Add annotations to the CRDs
additionalAnnotations: {}

## Create the provided Roles and RoleBindings
##
Expand Down

0 comments on commit 7910236

Please sign in to comment.