Kubernetes Day 4 Practicals

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

  • To ensure static pod is running in node

# docker ps |grep static

(or)

# kubectl get pods -o wide

Leave a Comment

MFH DevOps Consultation Services

Add Few lines about the company here

Contact

MFH Devops Consulation
#4-72-1/1. 1st Floor, Beach Road Lawson’s Bay Colony, Near Shanti Ashram, Opp. Bharat Petroleum, Visakhapatnam, Andhra Pradesh – 530017