Kubernetes Day 4 Practicals




Init Container



Environment Label

If we need to Run Application _ Database (App + DB), we need to understand how Application connects with DB.

During application, the developers will give code similar to below :


Here in above DB address, hostname changes to every Environment.

Ex :


# kubectl run pod3 –image Nginx –env=’DBHOST=www.devdb.dc2′ –dry-run=client -o yaml

In Yaml spec: -> under containers we see Environment Variable

Ex :



– env :

-name : DBHOST

value : www.devdb.dc2

image : nginx

name : pods3

With below command we enter in to Pod

# kubectl exec -it pod3 — bash

  • “printevn” -> This is the command to print all the Environment Variables in the Pod.
  • To Restrict the utilisation (memory, space) of a pod, run below command

# kubectl run pod4 –image nginx –requests ‘cpu=0.5, memory=500m’ –lmits=’cpu=1, memory=1200mi’ –dry-run=client -o yaml

In above command we are providing Max and min values (Limits)

apiVersion : v1

kind : pod


creation timestamp : null

labels :

run : pod4

name : pod4

spec :

containers :

– image : nginx

resources :

limits :

cpu : “1”

memory : 1200mi

requests :

cpu : 500 mi

memory : 500 mi

dnspolicy : clusterfirst

restart policy : Always

starts : {}

To Create or run a POD in a particular NODE

  • Static pod is the POD where we can go directly to a NODE and run a POD in which Node we want to Run.
  • kubelet runs as a Service in each and every node.
  • To see Active kubelt on each node # Service kubelet status
  • To check all the details of kubelet

cd /var/lib/kubelet

  • To see yaml file of kubelet

# cd /var/lib/kubelet

# ls

  • To check the details of the kubelet and find static pod paths

# cd /var/lib/kubelet

# cat config.yaml

  • To create a static pod we need to CD to /etc/kubernetes/manifests
  • To create a static pod we have to create a yaml file

  • To ensure static pod is running in node

# docker ps |grep static


# kubectl get pods -o wide

Leave a Comment

MFH IT Solutions (Regd No -LIN : AP-03-46-003-03147775)

Consultation & project support organization.


MFH IT Solutions (Regd)
NAD Kotha Road, Opp Bashyam School, Butchurajupalem, Jaya Prakash Nagar Visakhapatnam, Andhra Pradesh – 530027