Create a Pod - Imperative

Execute kubectl command to create a Pod.

$ kubectl run coffee --image=ansilh/demo-coffee --restart=Never
pod/coffee created

Verify Pod status

$ kubectl get pods -o wide
NAME     READY   STATUS              RESTARTS   AGE   IP       NODE            NOMINATED NODE   READINESS GATES
coffee   0/1     ContainerCreating   0          6s    <none>   k8s-worker-01   <none>           <none>
$ kubectl get pods -o wide
NAME     READY   STATUS    RESTARTS   AGE   IP             NODE            NOMINATED NODE   READINESS GATES
coffee   1/1     Running   0          19s   192.168.1.15   k8s-worker-01   <none>           <none>

Start a CentOS container

$ kubectl run centos-pod --image=tutum/centos --restart=Never
pod/centos-pod created

verify status of the Pod ; it should be in Running

$ kubectl get pods
NAME         READY   STATUS    RESTARTS   AGE
centos-pod   1/1     Running   0          25s
coffee       1/1     Running   0          2m10s

Logon to CentOS Pod

$ kubectl exec -it centos-pod -- /bin/bash
[root@centos-pod /]#

Verify Coffee App status

[root@centos-pod /]# curl -s 192.168.1.15:9090 |grep 'Serving Coffee'
<html><head></head><title></title><body><div> <h2>Serving Coffee from</h2><h3>Pod:coffee</h3><h3>IP:192.168.1.15</h3><h3>Node:172.16.0.1</h3><img src="data:image/png;base64,
[root@centos-pod /]# exit

Delete pod

k8s@k8s-master-01:~$ kubectl delete pod coffee centos-pod
pod "coffee" deleted
pod "centos-pod" deleted
k8s@k8s-master-01:~$ kubectl get pods
No resources found.
k8s@k8s-master-01:~$