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

Add uninstall hook for the kube-stack chart #1305

Merged
merged 28 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/kube-stack-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
kubectl wait --timeout=5m --for=condition=available deployment cert-manager-webhook -n cert-manager

- name: Run chart-testing (install)
run: ct install --charts charts/opentelemetry-kube-stack
run: ct install --charts charts/opentelemetry-kube-stack --namespace oks-test
2 changes: 1 addition & 1 deletion charts/opentelemetry-kube-stack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: opentelemetry-kube-stack
version: 0.1.2
version: 0.1.3
description: |
OpenTelemetry Quickstart chart for Kubernetes.
Installs an operator and collector for an easy way to get started with Kubernetes observability.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: OpAMPBridge
metadata:
name: example
labels:
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: example-cluster-stats
namespace: default
labels:
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
opentelemetry.io/opamp-reporting: "true"
Expand Down Expand Up @@ -189,7 +189,7 @@ metadata:
name: example-daemon
namespace: default
labels:
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
opentelemetry.io/opamp-reporting: "true"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: delete-resources-sa
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: delete-resources-role
rules:
- apiGroups:
- opentelemetry.io
resources:
- instrumentations
- opampbridges
- opentelemetrycollectors
verbs:
- get
- list
- delete
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: delete-resources-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: delete-resources-role
subjects:
- kind: ServiceAccount
name: delete-resources-sa
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: opentelemetry-kube-stack-pre-delete-job
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
spec:
template:
spec:
restartPolicy: Never
serviceAccountName: delete-resources-sa
containers:
- name: delete-resources
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
kubectl delete instrumentations,opampbridges,opentelemetrycollectors \
-l helm.sh/chart=opentelemetry-kube-stack-0.1.3
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kind: Instrumentation
metadata:
name: example
labels:
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
clusterName: demo
opentelemetry-operator:
enabled: true
collectors:
daemon:
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: example-daemon
namespace: default
labels:
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: default
labels:
app: opentelemetry-kube-stack-apiserver
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
app: opentelemetry-kube-stack-kube-controller-manager
jobLabel: kube-controller-manager
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
namespace: kube-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: default
labels:
app: opentelemetry-kube-stack-kube-controller-manager
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
app: opentelemetry-kube-stack-kube-dns
jobLabel: kube-dns
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
namespace: kube-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: default
labels:
app: opentelemetry-kube-stack-kube-dns
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
app: opentelemetry-kube-stack-kube-etcd
jobLabel: kube-etcd
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
namespace: kube-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: default
labels:
app: opentelemetry-kube-stack-kube-etcd
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
app: opentelemetry-kube-stack-kube-proxy
jobLabel: kube-proxy
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
namespace: kube-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: default
labels:
app: opentelemetry-kube-stack-kube-proxy
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
labels:
app: opentelemetry-kube-stack-kube-scheduler
jobLabel: kube-scheduler
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
namespace: kube-system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
namespace: default
labels:
app: opentelemetry-kube-stack-kube-scheduler
helm.sh/chart: opentelemetry-kube-stack-0.1.2
helm.sh/chart: opentelemetry-kube-stack-0.1.3
app.kubernetes.io/version: "0.105.0"
app.kubernetes.io/managed-by: Helm
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: delete-resources-sa
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: delete-resources-role
rules:
- apiGroups:
- opentelemetry.io
resources:
- instrumentations
- opampbridges
- opentelemetrycollectors
verbs:
- get
- list
- delete
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: delete-resources-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: delete-resources-role
subjects:
- kind: ServiceAccount
name: delete-resources-sa
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: opentelemetry-kube-stack-pre-delete-job
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
spec:
template:
spec:
restartPolicy: Never
serviceAccountName: delete-resources-sa
containers:
- name: delete-resources
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
kubectl delete instrumentations,opampbridges,opentelemetrycollectors \
-l helm.sh/chart=opentelemetry-kube-stack-0.1.3
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
clusterName: demo
opentelemetry-operator:
enabled: true
collectors:
daemon:
enabled: true
Expand Down
56 changes: 56 additions & 0 deletions charts/opentelemetry-kube-stack/templates/hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{- if .Values.cleanupJob.enabled }}
apiVersion: v1
kind: ServiceAccount
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved
metadata:
name: delete-resources-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: delete-resources-role
rules:
- apiGroups:
- opentelemetry.io
resources:
- instrumentations
- opampbridges
- opentelemetrycollectors
verbs:
- get
- list
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: delete-resources-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: delete-resources-role
subjects:
- kind: ServiceAccount
name: delete-resources-sa
---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "opentelemetry-kube-stack.name" . }}-pre-delete-job
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
spec:
template:
spec:
restartPolicy: Never
serviceAccountName: delete-resources-sa
containers:
- name: delete-resources
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
kubectl delete instrumentations,opampbridges,opentelemetrycollectors \
-l helm.sh/chart={{ include "opentelemetry-kube-stack.chart" . }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/opentelemetry-kube-stack/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,14 @@
}
},
"properties": {
"cleanupJob": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
}
}
},
"crds": {
"type": "object",
"properties": {
Expand Down
7 changes: 5 additions & 2 deletions charts/opentelemetry-kube-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ clusterName: ""
# Extra environment variables to add to each collector, bridge and instrumentation
extraEnvs: []

# Enables a cleanup job to make sure the CRs are uninstalled before the operator
cleanupJob:
enabled: true
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved

# Should the CRDs be installed by this chart.
crds:
# Should the CRDs be installed
Expand All @@ -17,8 +21,7 @@ crds:
# Top level field related to the OpenTelemetry Operator
opentelemetry-operator:
# Field indicating whether the operator is enabled or not
# This is disabled for now while the chart is under development
enabled: false
enabled: true
manager:
collectorImage:
repository: otel/opentelemetry-collector-k8s
Expand Down
Loading