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

<pre><code>kubectl config delete-cluster &lt;cluster-name&gt; 

kubectl config delete-context &lt;Cluster-context&gt;  
</code></pre>

<p>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.</p>

<p>When I run the command "kubectl config view", I found the following result,</p>

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

<p>Still my Spring Boot micro service is deploying in cluster with updated changes.</p>

<p>I created the Kubernetes cluster using kubespray tool that I got reference from Github:</p>

<p><a href="https://github.com/kubernetes-incubator/kubespray.git" rel="nofollow noreferrer">https://github.com/kubernetes-incubator/kubespray.git</a></p>

<p>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.</p>

Mr.DevEng
<p>If you setup your cluster using Kubespray, you ran whole installation using ansible, so to delete cluster you have to use it too.</p>

<p>But you can also reset the entire cluster for fresh installation:</p>

<pre><code>$  ansible-playbook -i inventory/mycluster/hosts.ini reset.yml
</code></pre>

<p>Remember to keep  the “hosts.ini” updated properly.</p>

<p>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:</p>

<pre><code> $ ansible-playbook -i inventory/mycluster/hosts.ini remove-node.yml
</code></pre>

<p>KubeSpray documentation: <a href="https://github.com/kubernetes-sigs/kubespray/blob/master/docs/getting-started.md" rel="noreferrer">kubespray</a>.</p>

<p>Useful articles: <a href="https://dzone.com/articles/kubespray-10-simple-steps-for-installing-a-product" rel="noreferrer">kubespray-steps</a>, <a href="https://shadow-soft.com/kubernetes-ansible-kubespray/" rel="noreferrer">kubespray-ansible</a>.</p>
