Step 1: Let’s check the nodes in the system by executing below command.
kubectl get nodes
$kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready master 29d v1.18.0
As you see the output, there is a node with the name ‘minikube’ is running and in Ready state.
Step 2: Let’s get the pods in your system by executing the command ‘kubectl get pods’.
$kubectl get pods
No resources found in default namespace.
Step 3: Let’s run ‘jboss/wildfly’ image on the Kubernetes cluster by executing the below command.
kubectl run user-service --image jboss/wildfly
In the above command
Pod name: user-service
Image to pull from docker hub is: jboss/wildfly
$kubectl run user-service --image jboss/wildfly
pod/user-service created
As you see the output, a user-service pod is created.
Step 4: Use the command ‘kubectl get pods’ to get pods information.
$kubectl get pods
NAME READY STATUS RESTARTS AGE
user-service 1/1 Running 0 83s
As you see that the pod user-service is in Running state.
Execute the command ‘kubectl describe pods’ to know information about pods.
$kubectl describe pods
Name: user-service
Namespace: default
Priority: 0
Node: minikube/192.168.99.100
Start Time: Thu, 04 Jun 2020 19:49:46 +0530
Labels: run=user-service
Annotations: <none>
Status: Running
IP: 172.17.0.6
IPs:
IP: 172.17.0.6
Containers:
user-service:
Container ID: docker://453f6ec43c0c8fa6701a61f78cd01d77b73b86347656a5b911719a9c27c40e7d
Image: jboss/wildfly
Image ID: docker-pullable://jboss/wildfly@sha256:67a4f90b213bc2600d08d90e82df58be83813d118d163fbcc8765b6eeaade7e6
Port: <none>
Host Port: <none>
State: Running
Started: Thu, 04 Jun 2020 19:49:53 +0530
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-w7rp7 (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-w7rp7:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-w7rp7
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled <unknown> default-scheduler Successfully assigned default/user-service to minikube
Normal Pulling 3m24s kubelet, minikube Pulling image "jboss/wildfly"
Normal Pulled 3m18s kubelet, minikube Successfully pulled image "jboss/wildfly"
Normal Created 3m18s kubelet, minikube Created container user-service
Normal Started 3m18s kubelet, minikube Started container user-service
From the output, you can confirm below things.
Name: user-service
Pod name is user-service
Namespace: default
Pod running in default namespace.
Node: minikube/192.168.99.100
Pod running on the node minikube
Status: Running
Pod is in running status
Apart from these, you can get container id, image, image id etc., from the output.
At the end of the output, you see Events; It gives step-by-step details of how the container created.
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled <unknown> default-scheduler Successfully assigned default/user-service to minikube Normal Pulling 3m24s kubelet, minikube Pulling image "jboss/wildfly" Normal Pulled 3m18s kubelet, minikube Successfully pulled image "jboss/wildfly" Normal Created 3m18s kubelet, minikube Created container user-service Normal Started 3m18s kubelet, minikube Started container user-service
Each pod gets its own internal IP address in the Kubernetes cluster. You can see the IP address of the pods by providing ‘-o wide’ option to get pods command.
$kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
user-service 1/1 Running 0 45m 172.17.0.6 minikube <none> <none>
That’s it you are done with the creation of pod.
No comments:
Post a Comment