This guide explains how to deploy and inspect a pod in a Minikube cluster using kubectl.
In this guide, we will walk through the process of deploying a pod within your Minikube cluster and inspecting its details using the kubectl command-line utility. This tutorial is ideal for developers and Kubernetes practitioners looking to get started with pod management in a local environment.
Ensure you have Minikube installed and a cluster running. Your kubectl should be configured to communicate with your Minikube cluster.
A pod is the smallest deployable unit in Kubernetes. To create a pod named “nginx” using the official Nginx image from Docker Hub, execute the following command:
Copy
Ask AI
kubectl run nginx --image=nginx
In this command:
“nginx” is both the pod name and the Docker image name.
The Docker image must be available on Docker Hub or any other container registry. You can also specify an image tag or a custom registry if needed.
After running the command, you should see output similar to this:
Copy
Ask AI
pod/nginx createdkubectl get podsNAME READY STATUS RESTARTS AGEnginx 1/1 Running 0 3s
This output confirms that the pod has been created and is running:
READY: Indicates the container is ready.
RESTARTS: Shows the number of times the container has restarted.
It is scheduled on the Minikube node with IP address 192.168.99.100, and the pod itself has the internal IP 172.17.0.3.
Container-specific information such as Container ID, image details, and current state are also provided.
Below the description, you will find an events section outlining the pod’s lifecycle, which might appear as follows:
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
Each event provides a timestamp and message detailing stages such as scheduling, image pulling, container creation, and container start. This is crucial for troubleshooting.
To get additional details such as the node and internal IP address where the pod is running, use the --wide flag:
Copy
Ask AI
kubectl get pods -o wide
The output might be:
Copy
Ask AI
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODEnginx 1/1 Running 0 2m28s 172.17.0.3 minikube <none>
This display confirms that each pod in a Kubernetes cluster receives its own internal IP address. In this example, the “nginx” pod has the IP address 172.17.0.3.
This demonstration showed you how to deploy a pod using a simple command in Minikube, inspect its configuration and lifecycle events with kubectl describe, and view extended information with the --wide flag. You can also create pods using YAML definition files for more advanced configurations.For further reading, consider exploring: