This tutorial teaches how to deploy a pod in a Minikube cluster using the kubectl command-line tool.
In this tutorial, you’ll learn how to deploy a pod in your Minikube cluster. A pod is the smallest and simplest deployable unit in Kubernetes, designed to hold one or more application containers. We’ll use the kubectl command-line tool to interact with our cluster.
You can specify an image tag or use an alternative container registry if your desired image is hosted elsewhere.
To create a pod named “nginx” using the Docker image “nginx” (pulled from Docker Hub), run the following command:
Copy
Ask AI
kubectl run nginx --image=nginx
Once this command executes, Kubernetes creates the pod. You can verify its creation and status by checking the list of pods:
Copy
Ask AI
# kubectl run nginx --image=nginxpod/nginx created# kubectl get podsNAME READY STATUS RESTARTS AGEnginx 1/1 Running 0 3s
The output confirms that the pod is running. The “READY” column indicates how many containers are in a ready state, “RESTARTS” shows the number of times the container has restarted, and “AGE” reflects how long the pod has been active.
For more in-depth information about the pod—including its labels, node assignment, internal IP address, and container specifics—use the kubectl describe command:
This command output provides essential metadata and status details such as the pod’s start time, the node it is running on, and its internal IP address (172.17.0.3). If multiple containers were running within the pod, each would be listed under the “Containers” section.Additionally, the bottom section of the output displays event information that tracks the lifecycle of the pod—from scheduling on the Minikube node to pulling the image and finally creating and launching the container:
Copy
Ask AI
Initialized TrueReady TrueContainersReady TruePodScheduled TrueVolumes: default-token-f5ntk: Type: Secret (a volume populated by a Secret) SecretName: default-token-f5ntk Optional: false QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300sEvents: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 46s default-scheduler Successfully assigned default/nginx to minikube Normal Pulling 45s kubelet, minikube Pulling image "nginx" Normal Pulled 44s kubelet, minikube Successfully pulled image "nginx" Normal Created 44s kubelet, minikube Created container nginx Normal Started 44s kubelet, minikube Started container nginx
For a summary that also includes node and internal IP details, use the following command:
Copy
Ask AI
kubectl get pods -o wide
The output will resemble:
Copy
Ask AI
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODEnginx 1/1 Running 0 2m28s 172.17.0.3 minikube <none>
Here, each pod is assigned its own internal IP address (in this case, 172.17.0.3), which enables network communications within the cluster.This demonstration has shown how to deploy a pod in a Minikube environment using the kubectl command line. In upcoming lessons, we will explore how to define pods using YAML configuration files for more complex deployment scenarios.For further reading and detailed Kubernetes concepts, visit the Kubernetes Documentation.