Kubernetes cluster not deleting

8/27/2019

I am trying to delete the entire kubernetes that created for my CI/CD pipeline R&D. So for deleting the cluster and everything I run the following command,

kubectl config delete-cluster <cluster-name> 

kubectl config delete-context <Cluster-context>  

For making sure that the clustee is deleted, I build the jenkins pipeline job again. So I found that it is deploying with updated changes.

When I run the command "kubectl config view", I found the following result,

docker@mildevdcr01:~$ kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: kubernetes-admin@cluster.local
kind: Config
preferences: {}
users: []
docker@mildevdcr01:~$

Still my Spring Boot micro service is deploying in cluster with updated changes.

I created the Kubernetes cluster using kubespray tool that I got reference from Github:

https://github.com/kubernetes-incubator/kubespray.git

What do I need to do for the deletion of everything that I created for this Kubernetes cluster? I need to remove everything including master node.

-- Jacob
kubernetes

2 Answers

8/27/2019

Okay so for a kubespray CI/CD pipeline it's a little more complicated then just deleting the cluster context. You have to actively delete other items on each node and perform a reset.yml for ETCD.

Sometimes just running the reset.yml is enough for your pipeline so it resets the cluster back to the initial state but if this is not enough then you have to delete docker, kubelet, repositories, /etc/kubernetes and many other directories on the nodes to get a clean deployment. In this case it's almost always easier to just provision new nodes in your pipeline using terraform and vsphere(vra) API.

-- Raja
Source: StackOverflow

8/28/2019

If you setup your cluster using Kubespray, you ran whole installation using ansible, so to delete cluster you have to use it too.

But you can also reset the entire cluster for fresh installation:

$  ansible-playbook -i inventory/mycluster/hosts.ini reset.yml

Remember to keep the “hosts.ini” updated properly.

You can remove node by node from your cluster simply adding specific node do section [kube-node] in inventory/mycluster/hosts.ini file (your hosts file) and run command:

 $ ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml

KubeSpray documentation: kubespray.

Useful articles: kubespray-steps, kubespray-ansible.

-- MaggieO
Source: StackOverflow