Skip to content

Commit

Permalink
Add uninstall hook for the kube-stack chart (#1305)
Browse files Browse the repository at this point in the history
* add uninstall hook

* update values

* set manual name

* Update hooks

* comment

* plz

* print the config

* use normal helm

* more

* bump ci version

* oops

* oop

* undo

* down another

* down another

* down another

* down another

* idk maybe

* matrix

* whoops

* Add exclude

* fix the matrix

* revert matrix change

* version

* oops
  • Loading branch information
jaronoff97 authored Aug 20, 2024
1 parent c206e7b commit 96fc70a
Show file tree
Hide file tree
Showing 25 changed files with 231 additions and 26 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/kube-stack-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ jobs:
kubectl wait --timeout=5m --for=condition=available deployment cert-manager -n cert-manager
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
- name: Run Helm Install
run: |
helm dep build charts/opentelemetry-kube-stack
helm install opentelemetry-kube-stack charts/opentelemetry-kube-stack
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: ./.github/actions/setup
with:
create-kind-cluster: "false"
helm-version: v3.11.3
helm-version: "v3.11.3"

- name: Run chart-testing (lint)
run: "ct lint --target-branch main
Expand Down
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,65 @@
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: delete-resources-sa
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: delete-resources-role
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
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
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
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,65 @@
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: delete-resources-sa
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
---
# Source: opentelemetry-kube-stack/templates/hooks.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: delete-resources-role
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
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
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
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
63 changes: 63 additions & 0 deletions charts/opentelemetry-kube-stack/templates/hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{- if .Values.cleanupJob.enabled }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: delete-resources-sa
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: delete-resources-role
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
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
annotations:
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
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
Loading

0 comments on commit 96fc70a

Please sign in to comment.