0% found this document useful (0 votes)
29 views12 pages

Feb 09 3_14 PM (1)

The document outlines the installation and management of Kubernetes and related container orchestration tools, detailing the necessary system requirements, installation steps, and commands for managing pods and deployments. It covers various container management tools, features of Kubernetes, and practical examples for creating and managing deployments, services, and secrets. Additionally, it provides troubleshooting tips and links to external resources for further guidance.

Uploaded by

Bhanu Gudimanchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views12 pages

Feb 09 3_14 PM (1)

The document outlines the installation and management of Kubernetes and related container orchestration tools, detailing the necessary system requirements, installation steps, and commands for managing pods and deployments. It covers various container management tools, features of Kubernetes, and practical examples for creating and managing deployments, services, and secrets. Additionally, it provides troubleshooting tips and links to external resources for further guidance.

Uploaded by

Bhanu Gudimanchi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

https://github.com/cncf/curriculum/blob/master/CKA_Curriculum_v1.28.

pdf

CRIO

CONTAINERD

DOCKER - OPENSOURCED

PODMAN

RKLET

MOBY

GOOGLE - DOCKER DESKTOP - DOCKER

RANCHER DESKTOP - DOCKER (MOBY / CONTAINERD)

REDHAT - PODMAN

GCP - DOCKER

ORACLE CLOUD - MOBY

AZURE - CONTAINERD

K8S

KUBERNETES

K3S

CONTAINER MANAGEMENT TOOL / ORCHESTRATION TOOL

GOOGLE - GO LANG - OPENSOURCED

CNCF - CLOUD NATIVE COMPUTING FOUNDATION

CMT

1. KUBERNETES
2. DOCKER SWARM
3. APACHE MESOS MARATHON

DEPLOYMENT
SCHEDULING
SCALING
LOAD BALANCING
BATCH EXECUTION
ROLLBACKS
MONITORING
FEATURES

1. AUTOMATIC BIN PACKAGING


2. SERVICE DISCOVERY AND LOAD BALANCING
3. STORAGE ORCHESTRATION
4. SELF HEALING

IF CONTAINER FAILS - RESTARTS CONTAINER

IF NODE DIES - REPLACES AND RESCHEDULE CONTAINERS ON OTHER NODES

IF CONTAINER DOES NOT RESPOND TO USER DEFINED HEALTH CHECKS - KILL CONTAINER

5. AUTOMATED ROLLOUTS AND ROLLBACKS


6. SECRET AND CONFIG MANAGEMENT
7. BATCH EXECUTION
8. HORIZONTAL SCALING

INSTALLATION STEPS

ON UBUNTU

Kubernetes Installation
———————————

12GB RAM Required


16 GB Recommended

4GB - base OS VMware - 512MB UBUNTU- 4GB WORKER NODE - 4 GB


HDD - 40GB Free Space

Minimum 4 cores required

WE USE ONE MASTER AND 2 WORKERS ARCHITECTURE

Step 1

Create 3 images of ubuntu run on different ipaddress and network to be “bridge”

System names
Ubuntu-Master - 192.168.1.101
Ubuntu-Worker1 - 192.168.1.102
Ubuntu-Worker2 - 192.168.1.103

Sudo hostnamectl set-hostname Ubuntu-Master - in first system


Sudo hostnamectl set-hostname Ubuntu-Worker1 - in second system
Sudo hostnamectl set-hostname Ubuntu-Worker2 - in

Third system

Step 2
IN ALL MACHINES
sudo apt-get update
Sudo apt-get install docker.io
docker —version
Enable the docker service Sudo su
Systemctl enable docker Systemctl start docker Systemctl status docker

Step 3
IN ALL MACHINES

Curl -s https://packages.cloud.google.com/apt/doc/apt- key.gpg | sudo apt-key add


Step 4

IN ALL MACHINES
Add Kubernetes repo
Sudo apt-add-repository “deb http://apt.kubernetes.io/
kebernetes-cenial main”
Sudo apt-get install kubeadm kubelet kubectl
Sudo apt-mark hold kubeadm kubelet kubectl
Wait for 10 mins
Kubeadm version
Sudoswapoff-a (INALLMACHINES) Step 5

IN Ubuntu-Master Machine
Sudo kubeadm init —pod-network-cidr=10.244.0.0/16
It will display kubeadm join (KEEP BACKUP OF THE STATEMENT)
Mkdir -p $HOME/.kube
Sudo cp -I /etc/kubernetes/admin.conf $HOME/.kube/ config
Sudo chown $(id -u):$(id -g) $HOME/.kube/config Sudo kubectl apply
https://raw.githubusercontent.com/
coreos/flannel/master/Documentation/kube-flannel.yml
Kubectl get pods —all-namespaces
Step 6

IN ALL WORKER MACHINES


Copy back up kubeadm join command fully with given parameter

Run in all worker machines


COME BACK TO MASTER MACHINE

Kubectl get nodes

To fix Rancher installation issue :


https://learn.microsoft.com/en-us/windows/wsl/install-manual

open Powershell as Admin and run the following :


- dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-
Linux /all /norestart
- dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all
/norestart
From browser - Download and install :
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi // might
be installed already
- wsl --set-default-version 2

OTHER INSTALLTION STEPS

-----------------------

https://github.com/justmeandopensource/kubernetes/blob/master/docs/install-cluster-
centos-7.md

this site contains steps for installing kubernetos on centos - 7

kubectl create -f .\example1.yml


4 kubectl get pods
5 kubectl get pods -o wide
6 kubectl get pods -o yaml

7 kubectl delete po countdown-2bsj7


8 kubectl delete po secret-env-pod
9 kubectl delete po pvpod
10 kubectl delete po pv-pod
11 kubectl delete po mysecretpod cron-demo-28271964-bsfdc cron-demo-28271965-
5lt29 cron-demo-28271966-4w8xp
12 kubectl prune
13 kubectl delete po cron-demo-28271964-bsfdc
14 kubectl get cronjob
15 kubectl delete cronjob cron-demo
16 kubectl get pods

kubectl describe pod tomcat-pod

kubectl delete -f example1.yml

Q 01) #Create a new pod called admin-pod with image busybox. Allow it to be able to
set system_time. Container should sleep for 3200 seconds.

15 alias g=kubectl
16 kubectl run admin-pod --image=busybox --command sleep 3200 --dry-run=client
-o yaml
17 kubectl run admin-pod --image=busybox --command sleep 3200 --dry-run=client
-o yaml | tee admin-pod-1.yml
18 echo ' securityContext:
capabilities:
add: ["NET_ADMIN", "SYS_TIME"]' | tee -a admin-pod-1.yml
19 kubectl create -f admin-pod-1.yml
20 kubectl create -f admin-pod-1.yml
21 kubectl get po
22 kubect describe pod admin-pod
23 kubectl describe pod admin-pod
24 kubectl describe pod admin-pod
25 kubectl get po
26 kubectl get po
27 kubectl describe pod admin-pod
28 kubectl describe pod admin-pod
29 kubectl get po

==========
To check the running sleep command in above container:
kubectl exec -i -t admin-pod -- /bin/sh
/ #
/ #
/ #
/ #
/ # ps -ef | grep sleep
1 root 0:00 sleep 3200
27 root 0:00 grep sleep
/ #
/ #
39 g delete -f example1.yml
40 g delete -f admin-pod-2.yml
41 g create -f example3.yml
42 g get po
43 g get po -o wide
44 g get po -l app=tomcat-app
45 g describe rc tomcat-rc
46 g scale rc tomcat-rc --replicas=8
47 g get po -l app=tomcat-app
48 g scale rc tomcat-rc --replicas=3
49 g get po -l app=tomcat-app
50 kubectl delete rc tomcat-rc
51 g get po -l app=tomcat-app
52 history

Q . deploy a web-load-5461 pod using nginx:1.17 with the label set to tier=web

EQUALITY BASED SELECTION

OPERATORS :
=, ==, !=

EXAMPLES

Environment = production

Tier != frontend

command line

kubectl get pods -l environment=production

in manifest

selector :
environment : production
tier : fronend

supported area : services , Replication Controller


SET BASED SELECTORS

operators :

In, not in , exists

Examples

Environment in (production, qa, dev, stage)


Tier not in (frontend, backend)

command line

kubectl get pods -l 'environment in (production)

in manifest

selector :
matchExpressios :
- {key : environment, operator : in, values : [prod, qa]}
- {key : tier, operator : NotIn, values : [frontend, backend]}

supported areas : job, Deployment, Replica set and Daemon set

56 g create -f example4.yml
57 kubectl get po
58 g get po -l tier=frontend
59 g get rs tomcat-rs -o wide
60 kubectl get po -o wide
61 g scale rs tomcat-rs -- replicas=5
62 g scale rs tomcat-rs --replicas=5
63 g scale rs tomcat-rs --replicas=9
64 kubectl get po -o wide
65 g scale rs tomcat-rs --replicas=4
66 kubectl get po -o wide
67 g delete pod tomcat-rs-hc8fv
68 kubectl get po -o wide
69 g delete pod tomcat-rs-qk5lh
70 kubectl get po -o wide
71 g delete rs tomcat-rs
72 kubectl get po -o wide
73 history
92 g get po
93 g create -f example5.yml
94 g get po
95 g get rs
96 kubectl describe deploy tomcat-deploy
97 history

104 g set image deploy tomcat-deploy tomcat-containers=nginx:1.9.1


105 g rollout status deployment/tomcat-deploy
106*
107 g set image deploy tomcat-deploy tomcat-containers=cognos:11
108 g rollout status deployment/tomcat-deploy
109 history

15 kubectl rollout history deployment/tomcat-deploy


16 kubectl get deploy -o wide
17 kubectl get deploy -o wide
18 kubectl rollout undo deployment/tomcat-deploy
19 kubectl rollout history deployment/tomcat-deploy
20 kubectl get deploy -o wide
21 history

kubectl rollout undo deployment/tomcat-deploy


kubectl rollout undo deployment/tomcat-deploy --to-revision=2

Question 03 ) Create a new deployment called web-proj-268 with image


nginx:1.16 and one replica. Next, upgrade the deployment to version 1.17
using rolling update.
Make sure that the version upgrade is recorded in the resource annotation.

g create deployment web-proj-268 --image=nginx1.16 -o yaml --replicas=6 --record |


tee deployment-6.yml

Question 04 ) Create a new deployment web-003, scale this deployment


to 3 replicas, make sure desired number of pods are always running.

g create deployment web-003 --image=nginx:1.16 -o yaml --replicas=3 | tee


deployment-6.yml

Qusetion 6) deploy a web-load-5461 pod using nginx:1.17 with the label


set to tier=web

g run web-load-5461 --image=nginx:1.17 --labels tier=web -o yaml | tee filename.yml

Q 7) Create static pod on node07 / kworker1 called static-nginx with


image nginx and you have to make sure that it is recreated/restarted
automatically in case of any failure happens

STEP 1)On control-pane :


alias g=kubectl
g run static-nginx --image=nginx --dry-run=client -o yaml
g run static-nginx --image=nginx --dry-run=client -o yaml |tee static-pod.yaml
vi static-pod.yaml
cat static-pod.yaml |ssh node7 "tee static-pod.yaml"
ssh node1

STEP 1)On node1 :

ps -ef|grep kubelet
sudo grep static /var/lib/kubelet/config.yaml
sudo cp static-pod.yaml /etc/kubernetes/manifests/.
ls /etc/kubernetes/manifests

1 oc delete deploy tomcat-deploy


2 kubectl delete deploy recreate-demo
3 oc new-app openshift/deployment-example:v1 --name=greenchannel
4 oc new-app openshift/deployment-example:v2 --name=bluechannel
5 oc expose svc/greenchannel --name=bluegreen-demo
6 oc patch route/bluegreen-demo -p '{"spec":{"to":{"name":"bluechannel"}}}'

4 cat > example5.yml


5 cat > example6.yml
6 kubectl apply -f example5.yml
7 kubectl get po
8 kubectl apply -f example6.yml
9 kubectl get svc
10 kubectl describe my-service
11 kubectl describe svc my-service
12 kubectl describe deploy tomcat-deploy
13 kubectl describe svc my-service
14 kubectl get po -o wide
15 curl http://192.168.1.3:8080
16 curl http://192.168.1.4:8080
17 curl http://192.168.1.5:8080
18 kubectl get nodes
19 kubectl get nodes -o wide
20 curl http://172.30.2.2:31000
21 cat > example8.yml
22 kubectl delete -f example7.yml
23 ls
24 kubectl delete -f example6.yml
25 kubectl apply -f example8.yml
26 kubectl get svc
27 kubectl describe svc my-service
28 curl http://10.102.12.193:8080
29 history

controlplane $ kubectl api-resources | grep -i deployment


deployments deploy apps/v1
true Deployment
controlplane $

kubectl apply -f example8.yaml


41 kubectl get pods -o wide
42 kubectl exec -it tomcat-pod -- /bin/sh
43 kubectl get pod tomcat-pod -o wide
44 cat example8.yaml
45 kubectl exec -it tomcat-pod -- /bin/sh
cd /
cd oracle-volume
touch file1.txt file2.txt
ls
exit
46 kubectl delete pod tomcat-pod
47 kubectl apply -f example8.yaml
48 kubectl get pod tomcat-pod -o wide
49 kubectl exec -it tomcat-pod -- /bin/sh
cd /
cd oracle-volume
ls
exit

4 cat > example11.yml


5 kubectl apply -f example11.yml
6 kubectl get po -o wide
7 kubectl exec -it multicontainer-pod -- /bin/sh

3 kubectl exec -it multicontainer-pod --container=consumer -- /bin/sh

apiVersion : v1
kind : PersistentVolume
metadata :
name : kube-pv
labels :
type : local
spec :
storageClassName : manual
capacity :
storage : 1Gi
accessModes :
- ReadWriteOnce
hostPath :
path : /mnt/datas

139 echo -n 'admin' | base64 > username.txt


140 echo -n 'password@123' | base64 > password.txt
141 kubectl create secret generic db-user-pass --from-file=./username.txt --
from-file=./password.txt
142 g
143 g get secrets
144 kubectl describe secrets db-user-pass
145 g delete secrets mysecret oracle-user-passwd
146 clear
application1.properties

management.endpoints.enabled-by-default=true
management.endpoint.info.enabled=true
management.security.enabled=false
management.endpoints.web.exposure.include=*

application2.properties

server.port= 9000
server.servlet.context-path=/oracle
oracleprops.greeting= Thank you and visit again - altered
oracleprops.greeting1= New Data

162 g delete configmaps my-config-map


163 g delete configmaps config-map1
164 g get configmaps
165 kubectl create configmap my-config-map --from-literal=key1=value1 --from-
literal=key2=value2
166 clear
167 g get configmaps
168 kubectl create configmap my-config-props
--from-file=./application1.properties --from-file=./application2.properties
169 g get cm

You might also like