DevOps Batch – 18 Aug – 2023 – Kubernetes – Notes

https://www.devopsschool.com/blog/kubernetes-1-23-6-cluster-setup-master-and-worker-in-ubuntu-20-04/

Master - 54.160.98.129

Worker - 54.227.222.224
kubeadm join 172.31.63.230:6443 --token ggh70j.dm3im2mwg0ajeku9 --discovery-token-ca-cert-hash sha256:b3a3d73921ee264dc989c968a9a38057503d7c69ad2546b65ea7d21f1777eccf



    1  clear
    2  ls
    3  cd
    4  ls
    5  git clone https://github.com/certifications-tutorials/cks-course-environment/
    6  clearls
    7  clear
    8  ls
    9  cd cks-course-environment/
   10  ls
   11  cd cluster-setup
   12  ls
   13  cd latest
   14  clear
   15  ls
   16  pwd
   17  ls
   18  clear
   19  ls
   20  chmod 755 install_master.sh
   21  ls
   22  ./install_master.sh
   23  clear
   24  ls
   25  kubectk
   26  kubectl
   27  clear
   28  kubectl get nodes
   29  kubectl
   30  kubectl cluster-info
   31  clear
   32  kubectl get nodes
   33  cd
   34  kubectl get nodes
   35  kubectl get pods --all-namespaces
   36  histpry
   37  history


How Workstation connect to API server?

kubectl 
	read a file 		
			$HOME/.kube/config
					Cluster
					uSer
					Context


What to do?
===========================================
1- All the api resources
2. What is the use of each res
3. How to deploy??
=======================================================

CRUD
	Create
		CMD
			create
		YAML
			create -f yaml
	Read
		CMD
			get
			describe
		YAML
			get -f  yaml
			describe -f  yaml
	Update
		CMD
			edit
		YAML
			apply -f yaml
	Delete
		CMD
			delete
		YAML
			delete -f yaml
======================================================
Namespace

 38  clear
   39  ls
   40  more $HOME/.kube/config
   41  clear
   42  kubectl config view
   43  clear
   44  kubectl
   45  kubectl api-resources
   46  cler
   47  clear
   48  kubectl
   49  kubectl api-resources
   50  clear
   51  kubectl get ns
   52  kubectl get pods -n=kube-system
   53  clear
   54  ls
   55  kubectl create ns dev
   56  kubectl create ns qa
   57  kubectl get ns
   58  kubectl describe ns dev
   59  kubectl edit ns dev
   60  kubectl describe ns dev
   61  clear
   62  kubectl get ns
   63  kubectl delete ns qa



POD


apiVersion: v1
kind: Pod
metadata:
  name: rajesh
  labels:
    app: helloworld
spec:
  containers:
  - name: devopsschool1
    image: scmgalaxy/nginx-devopsschoolv1
    ports:
    - name: nginx-port
      containerPort: 80

  67  vi pod.yaml
   68  kubectl create -f pod.yaml
   69  kubectl get pods
   70  kubectl get pods -o wide
   71* kubectl get pods -o wide --sho
   72  kubectl describe pod rajesh
   73  clear
   74  kubectl create -f pod.yaml
   75  kubectl get ns
   76  kubectl create -f pod.yaml -n=dev
   77  kubectl get pods -n=dev
   78  kubectl edit pod rajesh
   79  kubectl describe pod rajesh
   80  cler
   81  clear
   82  kubectl delete -f pod.yaml
   83  kubectl delete -f pod.yaml -n=dev
   84  history

Troubleshooting and Debugging Commands:
  describe      Show details of a specific resource or group of resources
  logs          Print the logs for a container in a pod
  attach        Attach to a running container
  exec          Execute a command in a container
  port-forward  Forward one or more local ports to a pod
  cp            Copy files and directories to and from containers
  auth          Inspect authorization

kubectl port-forward --address 0.0.0.0 pod/rajesh 8888:80

85  clear
   86  kubectl
   87  clear
   88  ls
   89  kubectl create -f pod.yaml
   90  kubectl get pods
   91  kubectl logs rajesh
   92  kubectl get pods -o wide
   93  kubectl logs rajesh
   94  kubectl logs -f rajesh
   95  kubectl attach  rajesh
   96  kubectl exec rajesh ls /tmp
   97  kubectl exec -it rajesh /bin/bash
   98  kubectl port-forward -h
   99  clear
  100  kubectl port-forward --address 0.0.0.0 pod/rajesh 8888:80
  101  clear
  102  kubectl get pods
  103  ls
  104  kubectl cp pod.yaml rajesh:/tmp
  105  kubectl exec rajesh ls /tmp
  106  kubectl auth
  107  kubectl auth can-i create pod
  108  kubectl auth can-i create service
  109  history

============================================
Replication Controller
==============================================
Replication --- Many PODS
Controller == Desire == Actual PODS


apiVersion: v1
kind: ReplicationController
metadata:
  name: rajesh
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: scmgalaxy/nginx-devopsschoolv1

  112  kubectl get rc
  113  vi rc.yaml
  114  kubectl create -f rc.yaml
  115  kubectl get rc
  116  kubectl get pods
  117  kubectl edit rc rajesh
  118  kubectl get pods
  119  cler
  120  kubectl get pods
  121  kubectl edit rc rajesh
  122  kubectl get pods
  123  clear
  124  kubectl get pods
  125  kubectl delete pods rajesh-42dr5 rajesh-6zjpc
  126  kubectl get pods
  127  kubectl delete -f rc.yaml
  128  kubectl get pods
  129  kubectl get rc




Deployment

Replication + Controller + Versioning +  Rollout + RollBack
=======================
    ReplicaSets


kubectl create deployment my-dep --image=scmgalaxy/nginx-devopsschoolv1 --replicas=3

 130  history
  131  clear
  132  kubectl create -h
  133  kubectl create deployment -h
  134  clear
  135  kubectl create deployment my-dep --image=scmgalaxy/nginx-devopsschoolv1 --replicas=3
  136  kubectl get deploy
  137  kubectl get pods
  138  kubectl get pods -o wide
  139  curl http://192.168.1.29
  140  clear
  141  kubectl rollout
  142  kubectl rollout history my-dep
  143  kubectl get deployt
  144  kubectl get deploy
  145  kubectl rollout history my-dep
  146  kubectl rollout history deploy my-dep
  147  clear
  148  kubectl edit deploy my-dep
  149  kubectl get pods -o wide
  150  curl http://192.168.1.32
  151  kubectl rollout history deploy my-dep
  152  kubectl rollout undo -h
  153  kubectl rollout undo deploy/my-dep --to-revision=1
  154  kubectl get pods -o wide
  155  curl http://192.168.1.34

kubernetes deployment strategy explained with example
Services ======================================== LOADBALANCER of PODS kubectl expose deployment my-dep --port=80 --target-port=80 kubectl expose deployment my-dep --port=80 --target-port=80 --type=NodePort --name=np kubectl expose deployment my-dep --port=80 --target-port=80 --type=LoadBalancer --name=np ====================================================================== Security RBAC role clusterrole rolebnding clusterbinding serviceaccount Storage PV PVC StorrageClass JObs job cronjob PODS statefulesets deamonsets
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x