Skip to content

Commit

Permalink
[operator] Allow custom labels and annotations (#1067)
Browse files Browse the repository at this point in the history
* [operator] Add the ability to add `additionalLabels`

This already existed in the `opentelemetry-collector` chart, now it
is available in the `opentelemetry-operator` as well.

These labels can be useful in environments where additional labels
are recommended or required.

* [operator] Allow adding custom annotations to various objects

Similar to `additionalLabels`, but for annotations.  This is somewhat
inspired by `cert-manager`s Helm chart [1], which allows custom annotations
on essentially all Kubernetes objects.

E.g. there could be internal annotations in certain environments that
are recommended or required

[1]: https://artifacthub.io/packages/helm/cert-manager/cert-manager

* [operator] Bump chart version for custom labels and annotations support
  • Loading branch information
heyLu authored Mar 25, 2024
1 parent 30763a7 commit 0b52cf3
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 20 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.52.0
version: 0.52.1
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 @@ -6,11 +6,12 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: webhook
name: example-opentelemetry-operator-mutation
webhooks:
Expand Down Expand Up @@ -90,11 +91,12 @@ metadata:
annotations:
cert-manager.io/inject-ca-from: default/example-opentelemetry-operator-serving-cert
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: webhook
name: example-opentelemetry-operator-validation
webhooks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: webhook
name: example-opentelemetry-operator-serving-cert
namespace: default
Expand All @@ -29,11 +30,12 @@ apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: webhook
name: example-opentelemetry-operator-selfsigned-issuer
namespace: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-manager
rules:
Expand Down Expand Up @@ -213,11 +214,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-metrics
rules:
Expand All @@ -231,11 +233,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-proxy
rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-manager
roleRef:
Expand All @@ -25,11 +26,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-proxy
roleRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator
namespace: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-leader-election
namespace: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-leader-election
namespace: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ apiVersion: v1
kind: Service
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator
namespace: default
Expand All @@ -31,11 +32,12 @@ apiVersion: v1
kind: Service
metadata:
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
name: example-opentelemetry-operator-webhook
namespace: default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ metadata:
name: opentelemetry-operator
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ metadata:
name: "example-opentelemetry-operator-cert-manager"
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: webhook
annotations:
"helm.sh/hook": test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ metadata:
name: "example-opentelemetry-operator-metrics"
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
annotations:
"helm.sh/hook": test
Expand Down Expand Up @@ -43,11 +44,12 @@ metadata:
name: "example-opentelemetry-operator-webhook"
namespace: default
labels:
helm.sh/chart: opentelemetry-operator-0.52.0
helm.sh/chart: opentelemetry-operator-0.52.1
app.kubernetes.io/name: opentelemetry-operator
app.kubernetes.io/version: "0.96.0"
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/instance: example

app.kubernetes.io/component: controller-manager
annotations:
"helm.sh/hook": test
Expand Down
7 changes: 7 additions & 0 deletions charts/opentelemetry-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{ include "opentelemetry-operator.additionalLabels" . }}
{{- end }}

{{/*
Expand Down Expand Up @@ -73,6 +74,12 @@ Create the name of the service account to use
{{- end }}
{{- end }}

{{- define "opentelemetry-operator.additionalLabels" -}}
{{- if .Values.additionalLabels }}
{{- tpl (.Values.additionalLabels | toYaml) . }}
{{- end }}
{{- end }}

{{/*
Create an ordered name of the MutatingWebhookConfiguration
*/}}
Expand Down
4 changes: 4 additions & 0 deletions charts/opentelemetry-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
{{- with .Values.manager.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "opentelemetry-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: controller-manager
Expand Down
8 changes: 8 additions & 0 deletions charts/opentelemetry-operator/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apiVersion: v1
kind: Service
metadata:
{{- with .Values.manager.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "opentelemetry-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: controller-manager
Expand All @@ -27,6 +31,10 @@ spec:
apiVersion: v1
kind: Service
metadata:
{{- with .Values.admissionWebhooks.serviceAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "opentelemetry-operator.labels" . | nindent 4 }}
app.kubernetes.io/component: controller-manager
Expand Down
38 changes: 37 additions & 1 deletion charts/opentelemetry-operator/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"hostNetwork",
"priorityClassName",
"securityContext",
"testFramework"
"testFramework",
"additionalLabels"
],
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -125,6 +126,8 @@
"env",
"serviceAccount",
"serviceMonitor",
"deploymentAnnotations",
"serviceAnnotations",
"podAnnotations",
"podLabels",
"prometheusRule",
Expand Down Expand Up @@ -726,6 +729,22 @@
}]
}]
},
"deploymentAnnotations": {
"type": "object",
"default": {},
"title": "The deploymentAnnotations Schema",
"required": [],
"properties": {},
"examples": [{}]
},
"serviceAnnotations": {
"type": "object",
"default": {},
"title": "The serviceAnnotations Schema",
"required": [],
"properties": {},
"examples": [{}]
},
"podAnnotations": {
"type": "object",
"default": {},
Expand Down Expand Up @@ -1275,6 +1294,7 @@
"cert_file",
"key_file",
"ca_file",
"serviceAnnotations",
"secretAnnotations",
"secretLabels"
],
Expand Down Expand Up @@ -1474,6 +1494,14 @@
""
]
},
"serviceAnnotations": {
"type": "object",
"default": {},
"title": "The serviceAnnotations Schema",
"required": [],
"properties": {},
"examples": [{}]
},
"secretAnnotations": {
"type": "object",
"default": {},
Expand Down Expand Up @@ -1713,6 +1741,14 @@
"tag": "latest"
}
}]
},
"additionalLabels": {
"type": "object",
"default": {},
"title": "The additionalLabels Schema",
"required": [],
"properties": {},
"examples": [{}]
}
},
"examples": [{
Expand Down
Loading

0 comments on commit 0b52cf3

Please sign in to comment.