![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/join_myfuturehub.com_-2.png?resize=591%2C591&ssl=1)
Agenda
Variables
Specifications
Init Container
Services
Controllers
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 :
JDBC:odbc:http://hostname:1521/dbname
Here in above DB address, hostname changes to every Environment.
Ex :
JDBC:odbc:http://DBHost:1521/dbname
# 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 :
spec:
containers:
– 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
metadata:
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
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/image.png?resize=486%2C602&ssl=1)
- To ensure static pod is running in node
# docker ps |grep static
(or)
# kubectl get pods -o wide
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/MFH_DO-Logo-1000x1000px-7.png?resize=1000%2C1000&ssl=1)
![](https://i0.wp.com/myfuturehub.com/wp-content/uploads/2021/08/20210816_184521_0000-5-edited.png?resize=500%2C281&ssl=1)