Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

Rabbitmq deployment using helm umbrella chart and rabbitmq operator with kubernetes

I am trying to deploy to a kubernetes cluster an umbrella chart that contains the rabbitmq operator + rabbitmq. So in total 2 sub-charts.

The operator sub-chart first deploys the CRD needed "kind: RabbitmqCluster" for the rabbitmq sub-chart and everything is installed correctly when I install the umbrella chart. I see 2 containers, the operator and an instance of rabbitmq.

The problem arises when I want to uninstall the umbrella chart (helm uninstall...), the rabbit operator is removed (since it has a "kind: Deployment") but not the rabbitmq instance that it has created. To do so, I need to manually run kubectl delete rabbitmqcluster name of instance.

Is there a way to do so when the helm uninstall is run or am I barking up the wrong tree?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

One way to solve this is to use an annotation using a helm hook to transform a job into a pre-delete operation.

Then in the spec part of the job, one can run kubectl commands if needed using a public image or whatever you like:

containers:
      - name: kubectl
        image: "k8s.gcr.io/hyperkube:v1.12.1"
        imagePullPolicy: "IfNotPresent"
        command:
        - /bin/sh
        - -c
        - >
            kubectl delete rabbitmqcluster {{ .Release.Name }}-rabbitmq -n {{ .Release.Namespace }};
            sleep 10;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...