Kubernetes Pods
Kubernetes Pods
But why we have added the command in container specifications? What is the purpose of this
command and what it is doing. As such this command will just echo the comment “Pod running”
and then go to sleep for 7200 seconds (2 hours). Which means that for 2 hours some process will
keep on running and our container will not get terminated.
What will happen, if we will not specify the command. In that case, your container will get created
and Immediately get terminated. Thus your Pod will never get created.
Then why we did not specify any command during creation of “webserver” pod from “nginx:alpine”
image. This is because when we use any web server image, by default, one daemon process is
always running.
Pod Yaml File
pod-with-port.yaml
Multi Container Pod Yaml File
pod-multi-container.yaml
apiVersion: v1
kind: Pod
metadata:
name: webserver
labels:
app: nginxweb
type: production
ver: v1
spec:
containers:
- name: web
image: nginx:1.16-alpine
- name: curl
image: vipin2411/curl
command: ["/bin/sh", "-c", "while : ;do curl http://localhost:80/; sleep 15; done"]
Pod Creation Using CLI
Creating pods using CLI without specifying “yaml” file. As such, not recommended method, but still
we will go ahead with creating 2 different pods using 2 different images as we did with “yaml“ files.
Four types of objects can be created by using CLI. The objects are Pods, Deployments, Jobs, CronJobs
Which type of object gets created will depend upon the options passed. Here we are interested in
creating pods.