Searching for the kubectl restart pod command? It doesn’t exist so here’s what to do instead.

Aspiring Kubernetes (k8s) administrators and k8s developers at some point may try executing the kubectl restart pod command only to be faced with the following message:

Table of Contents

error: unknown command “restart” for “kubectl”

— such as what we see in the following image:

Command line example where the user attempted to execute the 'kubectl restart pod' command with a pointer to the 'error: unknown command "restart" for "kubectl"' message.
'kubectl restart pod' command results in an 'error: unknown command "restart" for "kubectl"'.

In the next section we’ll explore how to restart a pod using the kubectl command.

In Kubernetes microservices, restarting a pod can be important when recovering from failed deployments, freeing up stuck processes, or applying updated configuration changes by reloading environment variables or mounted volumes.

Understanding how to perform a k8s restart pod operation is helpful for engineers studying for the CKAD exam since it demonstrates control over pod lifecycles, helps when troubleshooting misbehaving containers, and reinforces core concepts like statelessness and configuration reloads.

This article was updated on June 26, 2025.

Learn how to restart a pod in Kubernetes

In this section we’ll review several examples regarding how to restart a pod in k8s, starting with the article prerequisites.

Article Prerequisites

We need the following applications and tools in order to run the examples in this project: Refer also to the article prerequisites for details about technology and setup instructions required to answer this question.

Start minikube

We’ve included two examples regarding how you might start minikube here — either should work..

				
					minikube start
				
			

The example below is the one which was used when developing this article.

				
					minikube start --hyperv-virtual-switch "My Virtual Switch" --v=4
				
			

The output when minikube has been started successfully should look like what we have below.

Terminal screenshot showing the minikube start command with a red pointer highlighting the command itself and a blue pointer indicating the successful startup message: “kubectl is now configured to use 'minikube' cluster and 'default' namespace.”
minikube start --hyperv-virtual-switch "My Virtual Switch" --v=4 executed successfully; kubectl is now configured to use the "minikube" cluster.

Create the k8s-restart-pod-ns namespace

For this exercise we’ll do everything in the k8s-restart-pod-ns namespace and we can create this namespace using the following command:

				
					kubectl create namespace k8s-restart-pod-ns
				
			

We should see the following when this command returns successfully:

kubectl command creating the 'k8s restart pod' namespace, with confirmation message displayed.
kubectl command to create the 'k8s restart pod' namespace, confirmed by the creation message.

Save the alpine-spin-configuration.yaml locally.

We need an example pod to work with and I’ve included the pod configuration YAML here.

This configuration is saved to the file named alpine-spin-configuration.yaml.

				
					apiVersion: v1
kind: Pod
metadata:
  name: alpine-spin-pod
  namespace: k8s-restart-pod-ns
  labels:
    role: myrole
spec:
  containers:
    - name: alpine-spin-container
      image: kubegoldenguide/alpine-spin:1.0.0
      ports:
        - name: web
          containerPort: 80
          protocol: TCP
				
			

Let’s take a look at the first example that covers how to restart k8s pods.

Example One: Use kubectl to restart a single pod with a namespace in Kubernetes.

A simple solution for restarting a k8s pod is to delete the pod and then create it again and this is demonstrated in the following image.

Using kubectl to restart a pod by deleting and recreating it.
Delete the pod (lite blue pointer) and manually create it again (magenta pointer) -- this is a simple method for restarting pods using kubectl.

We’ll go through each step here.

Step One: Get all pods in the k8s-restart-pod-ns.

In the first step, indicated by the red pointer, we issue the command to get the pods in the k8s-restart-pod-ns namespace and there are none.

				
					kubectl get pods --namespace k8s-restart-pod-ns
				
			

Step Two: Create the alpine-spin-pod pod.

In the second step, indicated by the orange pointer, we create the alpine-spin-pod pod using the pod configuration file we created in the prerequisites section.

				
					kubectl apply -f ./alpine-spin-configuration.yaml
				
			

Step Three: Wait for the pod status to be Running.

In the third step, indicated by the yellow pointers, we check the pod status and we wait until it’s Running.
				
					kubectl get pods --namespace k8s-restart-pod-ns
				
			

Step Four: Delete the alpine-spin-pod pod.

In the fourth step, indicated by the sky blue pointer, we delete the alpine-spin-pod pod using the command below.

				
					kubectl delete pod alpine-spin-pod --namespace k8s-restart-pod-ns
				
			

Step Five: Check the pods in the k8s-restart-pod-ns namespace.

In the fifth step, indicated by the blue pointer, we check the pods in the k8s-restart-pod-ns namespace and we can see that no pods exist and this is expected.
				
					kubectl get pods --namespace k8s-restart-pod-ns
				
			

Step Six: Recreate the pod.

In the sixth step, indicated by the magenta pointer, we create the pod again by applying the same pod configuration file that we used in the second step.

				
					kubectl apply -f ./alpine-spin-configuration.yaml
				
			

Step Seven: Confirm that the alpine-spin-pod pod is Running.

In the seventh step, indicated by the green pointer, we check the status of the alpine-spin-pod pod and we confirm that it is Running.

				
					kubectl get pods --namespace k8s-restart-pod-ns
				
			

This concludes the first example regarding how to use kubectl to restart a single pod in Kubernetes — we’ll take a look at some more complicated examples in the following sections.

Example Two: Learn how to restart a pod in a deployment in Kubernetes.

This example is actually easier than the using kubectl to restart a pod in a namespace, which we just covered and the reason is that if a pod gets deleted, Kubernetes will automatically start a new one.

We’ll borrow the deployment used in the article that examines a mock CKAD exam questions and answers involving Kubernetes replicas for this exercise.

Prerequisites

The following steps are required before proceeding with this example:

				
					apiVersion: apps/v1
kind: Deployment
metadata:
  name: question-five-deployment
  namespace: ggckad-s5
  labels:
    client: user
  annotations:
        kubernetes.io/change-cause: "New deployment."
spec:
  replicas: 6
  strategy:
    type: Recreate
  selector:
    matchLabels: {
      app: revproxy
    }
  template:
    metadata: {
      labels: {
        app: revproxy
      }
    }
    spec:
      containers:
      - name: web
        #
        # We start with nginx:1.28.0 but will cause a rolling update when we change this
        # to latest.
        #
        image: nginx:latest
        ports:
          - name: web
            containerPort: 80
            protocol: TCP
				
			

Step One: Apply the deployment file.

The first step involves applying the deployment file using kubectl.

Our deployment resides in the ggckad-s5 namespace so we need to create that prior to applying the deployment configuration.

These commands are included here:

  • The red pointer points to the script used to create the ggckad-s5 namespace.
				
					kubectl create namespace ggckad-s5
				
			
  • The green pointer points to the script used to create the deployment.
				
					kubectl apply -f ./question-five-deployment.yaml
				
			
  • The blue pointer points to the six pods defined in the deployment file.
				
					kubectl get pods --namespace ggckad-s5
				
			

We can see what the successful execution should look like in the image below.

Terminal screenshot showing kubectl output: a new namespace was created and six pods deployed with ‘Running’ status.
Screenshot of terminal showing a namespace created and six pods deployed via kubectl, all running successfully.

Step Two: Choose a random pod for deletion purposes.

In this step we’ll pick a random pod for deletion.

We have six pods running below and for this exercise we’ll delete the one ending in “ds6qt”.

Screenshot of running pods in a deployment with a red underline marking the pod selected for deletion.
Screenshot showing running pods in a deployment with a red underline marking the pod selected for deletion.

Step Three: Delete the pod.

We’ll use the following command to perform the deletion:
				
					kubectl delete pod question-five-deployment-664b476b6-ds6g4 --namespace ggckad-s5
				
			

We can see the result of a successful pod deletion in the following image.

Terminal output showing the kubectl delete pod command deleting a specific pod in a namespace with a successful deletion message.
Screenshot of the CLI showing kubectl delete pod run in the ggckad-s5 namespace with the pod deleted successfully.

Step Four: Check and verify the pods in the deployment.

In the last step we can see that the pod we deleted has been replaced by a new pod, ending in “lsgk5”, which has only been running for three seconds.

We can inspect the pods in the ggckad-s5 namespace using the following command:

				
					kubectl get pods --namespace ggckad-s5
				
			

The output when this command is executed is included here:

Terminal output of kubectl get pods in the ggckad-s5 namespace showing six pods, with a red pointer marking a new pod running for three seconds.
Screenshot of the CLI showing kubectl get pods --namespace ggckad-s5 output with six pods listed and a red pointer highlighting a new pod running for three seconds.
This deployment requires six replicas so if one is removed k8s will start a new one automatically as indicated by the red pointer.

Tutorial Conclusion

Restarting a pod in Kubernetes isn’t a one-size-fits-all task, but there are several simple ways to do it using kubectl and depending on your use case.

Use the solution that works best for your situation, and you’ll be back up and running quickly.

There are several other scenarios where restarting a pod is necessary and we’ll add these in due course.

See Also

  1. Learn how to use kubectl to get the cluster name in this guide.
  2. Learn how to install the Metrics Server in minikube quickly.
  3. Explore several solution for mounting a local directory in minikube.
  4. Learn how to use kubectl to create deployment replicas now.
  5. Example Four: Learn how to set up Kubernetes health check probes.
author avatar
ThosPFuller
I am a software engineer based in Northern Virginia (USA) and this website focuses on content engineering, web development, Technical SEO, Search Engine Optimization (SEO).

Leave a Reply