Jump to content

How to Clear Kubernetes Cache


Recommended Posts

Kubernetes is a well-liked and universally used container orchestration system. It is basically utilized to create, deploy, and manage applications and software. Sometimes, the Kubernetes cluster does not start due to some problem in configurations and some unknown reason. In such situations, users may be required to clear the Kubernetes cache or remove Kubernetes components.

This article will illustrate:

How to Clear Cache of Cluster by Removing the “cache” Directory?

Occasionally, users may face difficulty in starting or creating a new Kubernetes cluster. To resolve this problem, the user must clear the Kubernetes cache.

To clear the Kubernetes cache, look at the given steps.

Step 1: Open the “.kube” Directory

To clear the Kubernetes cache, first, open the “.kube” directory by navigating to the “C:\Users\<User-name>” directory:

word-image-408428-1.png

Step 2: Clear Kubernetes Cache

The “.kube” folder contains the cache folder that stores the Kubernetes cache. Open the “cache” directory:

word-image-408428-2.png

This directory will contain two folders, the “discovery” directory and “http”. The discovery directory is utilized to store the “kubectl api-resource” request for each Kubernetes cluster. In contrast, the “http” directory is used to store the response body that is generated against each “api-resource” request.

To clear the Kubernetes cache, press the “CTRL+A” to select all directories. After that, press the “Delete” or “Del” key to clear the cache folder:

word-image-408428-3.png

Here, you can see we have effectively deleted and cleared the Kubernetes cache:

word-image-408428-4.png

How to Clear Kubernetes Cluster by Removing Nodes and Pods?

Kubernetes cluster does not have a centered or global Kubernetes cache. The Kubernetes command line tool “kubectl” does not provide any command to clear the cluster cache. The Kubernetes cluster cache can belong to a Kubernetes component or application such as pods and nodes. To clear the Kubernetes cluster, go through the below demonstration.

Step 1: Gets Pods

To get the Kubernetes cluster pods, utilize the “kubectl get pods” commands:

kubectl get pods

word-image-408428-5.png

Step 2: Delete Pods

Next, delete the pods to clear the cluster using the “kubectl delete pod <pod-name>” command:

kubectl delete pod <demo>

word-image-408428-6.png

Step 3: Get Nodes

To completely clear the cluster cache or application cache running in the Kubernetes cluster, get the nodes using the “kubectl get nodes” command:

kubectl get nodes

word-image-408428-7.png

Step 4: Drain the Node

Next, drain the node to make it unschedulable and remove the node directory data. To do so, use the below command:

kubectl drain minikube-m02 --force --ignore-daemonsets --delete-emptydir-data

word-image-408428-8.png

Step 5: Delete Node

To completely delete the node, simple use the “kubectl delete node <node-name>” command:

kubectl delete node minikube-m02

word-image-408428-9.png

That is all about removing the Kubernetes cache and clearing the Kubernetes cluster.

Conclusion

The Kubernetes cache does not have a centralized cache and does not offer any kubectl command. To clear the Kubernetes cache, open the “.kube” directory from the system “$Home” directory or User directory. After that, clear all content of the directory. To clear the Kubernetes cluster, remove the Kubernetes components such as pods. After that, drain the node and delete it using the “kubectl delete node <node-name>” command. This post has illustrated how to clear the cache of the Kubernetes cluster.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...