Imperatively create a kubernetes pod using kubectl (for docker administrators)

Just as an hello-world equivalent, first thing one want to try to start learning how to use a Kubernetes cluster is to run a pod in it. Let's try to create our first pod on kubernetes just as we would do with docker for running a container

To create a container in docker it is as easy as:

docker run -dt nginx

To create a pod in Kubernetes is not that different than this

kubectl run demo --image nginx

To be able to check whether the container is running in docker we would use docker ps:

$ docker ps
CONTAINER ID   IMAGE                           COMMAND                  CREATED         STATUS         PORTS     NAMES
7bb916d41482   nginx                           "/docker-entrypoint.…"   7 seconds ago   Up 3 seconds   80/tcp    eager_snyder

It's equivalency on kubernetes is kubectl get pods:

$ kubectl get pods
NAME                         READY   STATUS    RESTARTS   AGE
demo                         1/1     Running   0          5s

Posted on 29/03/2021