To delete a Building Block there at least 2 ways to delete a building block from your cluster.
The first approach is an automatic deletion process as described in the
The automatic way section.
As a second solution you can also manually delete each building block. You have more control with this deletion process. This is described in
The manual way.
The following 3 steps will delete your building block.
First figure out the details about your building block you would like to delete. With the following
mkactl command we can find out the exact name and the version of the building block.
Use the mkactl command to get an overview of your building blocks.
mkactl block list NAME VERSION kube-prometheus-stack 24.1.0
To delete a building block you can proceed with the following steps :
kubectl delete ns -n <namespace>command to delete the building block from you metakube cluster.
Let's assume you have your kubernetes configuration in the default location check your deployed Building Block(s) with the following command sequence.
kubectl get ns NAME STATUS AGE cloud-init-settings Active 4d7h default Active 4d7h kube-node-lease Active 4d7h kube-public Active 4d7h kube-system Active 4d7h syseleven-kube-prometheus-stack Active 20s
Now we would like to delete the
syseleven-kube-prometheus-stack from our cluster.
in our example it would be :
docker run --rm -v ~/.kube/config:/kube/config --env KUBECONFIG=/kube/config --entrypoint /bin/bash registry.code.syseleven.de/syseleven/building-blocks/helmfiles/kube-prometheus-stack:24.1.0 -c "bash ./.gitlab/remove_bb.sh"
In general : The sequence for all Building Blocks would be the following command line where BB_NAME is the name of the Building Block and BB_VERSION would be the version you retrieve from the
mkactl block list command.
docker run --rm -v ~/.kube/config:/kube/config --env KUBECONFIG=/kube/config --entrypoint /bin/bash registry.code.syseleven.de/syseleven/building-blocks/helmfiles/<BB_NAME>:<BB_VERSION> -c "bash ./.gitlab/remove_bb.sh"
You should see the following process.
Try to delete all helm charts in syseleven-kube-prometheus-stack. release "kube-prometheus-stack-extension" uninstalled release "kube-prometheus-stack" uninstalled Try to delete namespace: syseleven-kube-prometheus-stack. namespace "syseleven-kube-prometheus-stack" deleted
You have successfully deleted your Building Block from your metakube cluster.
The Building Block still has its deployment information within your control repository. To prevent an accidental deployment of your deleted building block you need to disable or delete it from your pipeline definition.
This pipeline definition resides in you control repository.
Here we have an example of 2 Building Blocks, kube-prometheus-stack and elasticsearch, in our .gitlab-ci.yml.
stages: - diff - deploy include: - /kube-prometheus-stack/.gitlab-ci.yml - /elasticsearch/.gitlab-ci.yml
Check out the .gitlab-ci.yml or alternatively you can use the gitlab editor as shown in the picture below.
You can delete the corresponding line or comment it by putting a # in front of the deleted building block. The deployment information for this deactivated or deleted building block still resides in your control repo.
This can ba mandatory as in regulated environment an audit can request a redeployment within a certain timeframe e.g 6 month recoverability requirement.