0% found this document useful (0 votes)
16 views7 pages

Day 1 Training Kubernetes

The document provides a comprehensive guide on container management and orchestration tools, focusing on Kubernetes and its installation on Ubuntu. It outlines the necessary system requirements, installation steps, and features such as automatic bin packing, service discovery, and self-healing capabilities. Additionally, it includes commands for managing pods and scaling deployments, along with troubleshooting tips for Rancher installation.

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)
16 views7 pages

Day 1 Training Kubernetes

The document provides a comprehensive guide on container management and orchestration tools, focusing on Kubernetes and its installation on Ubuntu. It outlines the necessary system requirements, installation steps, and features such as automatic bin packing, service discovery, and self-healing capabilities. Additionally, it includes commands for managing pods and scaling deployments, along with troubleshooting tips for Rancher installation.

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/ 7

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

You might also like