Kubernetes 17 Oct 2023 Day 2

Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Working with Namesspace

=======================================
Namespace		DONE
POD
ReplicationController
Deployment
=====================================
What is Namespace?

Secret Formula
------------------------------------
C
	CMD
		create
	YAML
		create -f yaml
R
	CMD		
		get 
		describe
	YAML
		get -f yaml
U
	CMD
		edit
	YAML
		apply -f yaml
D
	CMD
		delete
	YAML
		delete -f yaml


root@ip-172-31-46-170:/home/ubuntu# kubectl get ns
NAME              STATUS   AGE
default           Active   19h
kube-node-lease   Active   19h
kube-public       Active   19h
kube-system       Active   19h
root@ip-172-31-46-170:/home/ubuntu#


   79  clear
   80  ls
   81  kubectl get ns
   82  kubectl create ns raj
   83  kubectl get ns
   84  kubectl describe ns raj
   85  kubectl edit ns raj
   86  kubectl describe ns raj
   87  kubectl delete ns raj
   88  history

Namespace LAB

Working with Kubernetes PODS

  112  ls
  113  vi pod.yaml
  114  kubectl create -f pod.yaml
  115  kubectl get pods
  116  kubectl create ns rajesh
  117  kubectl create -f pod.yaml
  118  kubectl create -f pod.yaml -n=rajesh
  119  kubectl get pods
  120  kubectl get pods -n=rajesh
  121  kubectl describe pod rajesh
  122  clear
  123  vi pod.yaml
  124  kubectl apply -f pod.yaml
  125  kubectl describe pod rajesh
  126  clear
  127  ls
  128  kubectl apply -f pod.yaml -n=rajesh
  129  kubectl delete -f pod.yaml
  130  kubectl delete -f pod.yaml -=rajesh
  131  kubectl delete -f pod.yaml -nrajesh
  132  kubectl apply -f pod.yaml
  133  kubectl get pods
  134  kubectl get pods --show-labels
  135  kubectl get pods -o wide
  136  curl http://192.168.1.4

How to troubleshoot PODS?

 142  kubectl get pods
  143  kubectl get pods -o wide
  144  kubectl logs rajesh
  145  curl http://192.168.1.4
  146  kubectl logs rajesh
  147  curl http://192.168.1.4
  148  kubectl logs rajesh
  149  curl http://192.168.1.4
  150  kubectl logs rajesh
  151  clear
  152  ls
  153  kubectl attach rajesh
  154  clear
  155  ls
  156  clear
  157  kubectl exec rajesh ls
  158  clear
  159  ;ls
  160  kubectl exec -it rajesh /bin/bash
  161  clear
  162  kubectl port-forward -h
  163  clear
  164  kubectl port-forward --address 0.0.0.0 pod/rajesh 8888:80
  165  clear
  166  ls
  167  kubectl cp pod.yaml rajesh:/tmp
  168  kubectl exec rajesh ls /tmp
  169  kubectl auth
  170  kubectl auth can-i
  171  clear
  172  kubectl auth can-i
  173  kubectl auth can-i create pod
  174  kubectl auth can-i create ns
  175  history

Working with Kubernetes ReplicationController

ReplicationController

KIND: Pod

Replication --> 1 TO MANY
Controller --> DESIRE === Actual
===================================
https://www.devopsschool.com/blog/kubernetes-replicationcontroller-example-programs/
Difference between ReplicaSet and ReplicationController?
apiVersion: v1 kind: ReplicationController metadata: name: rajeshrc spec: replicas: 5 template: metadata: labels: app: nginx spec: containers: - name: nginx image: scmgalaxy/nginx-devopsschoolv1 kubectl scale --replicas=1 rc/rajeshrc apiVersion: v1 kind: ReplicationController metadata: creationTimestamp: "2023-10-17T08:52:12Z" generation: 4 labels: app: nginx name: rajeshrc namespace: default resourceVersion: "58311" uid: 45119ee9-e4e5-48b9-96fd-346e7deb01ec spec: replicas: 20 selector: app: nginx template: metadata: creationTimestamp: null labels: app: nginx spec: containers: - image: scmgalaxy/nginx-devopsschoolv1 imagePullPolicy: Always name: nginx resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} terminationGracePeriodSeconds: 3 192 clear 193 kubectl get ns 194 kubectl get pods --all--namespaces 195 kubectl get pods --all-namespaces 196 clear 197 ls 198 kubectl get rc 199 kubectl create -f rc.yaml 200 kubectl get rc 201 kubectl get pods 202 kubectl get rc 203 clear 204 kubectl get rc 205 kubectl describe rc rajeshrc 206 clear 207 l 208 kubectl get pods 209 kubectl describe pod pl321 210 kubectl get pods 211 kubectl describe pod rajeshrc-4s4dj 212 clear 213 l 214 kubectl get rc 215 kubectl edit rc rajeshrc 216 kubectl get rc 217 kubectl get pods 218 kubectl 219 clear 220 kubectl scale -h 221 clear 222 kubectl scale --replicas=1 rc/rajeshrc 223 kubectl get pods 224 kubectl scale --replicas=20 rc/rajeshrc 225 kubectl get pods 226 clear 227 ls 228 kubectl get rc 229 kubectl get rc rajeshrc -o yaml 230 clear 231 lsclear 232 clear 233 ls 234 kubectl scale --replicas=3 rc/rajeshrc 235 clear 236 celar 237 clear 238 kubectl get pods 239 kubectl delete pod nodehelloworld.example.com 240 kubectl get pods 241 clear 242 kubectl get pods 243 kubectl delete pod rajeshrc-2zl4w rajeshrc-rg5kf 244 kubectl get pods 245 kubectl delete rc rajeshrc 246 kubectl get pods https://stackoverflow.com/questions/43147941/allow-scheduling-of-pods-on-kubernetes-master

Working with Kubernetes Deployment

https://www.devopsschool.com/blog/list-of-popular-deployment-strategies/
 266  kubectl delete all pods
  267  kubectl delete pods --all
  268  clear
  269  kubectl create deployment my-dep --image=scmgalaxy/nginx-devopsschoolv1 --replicas=5
  270* kubectl
  271  clear
  272  kubectl describe deploy my-dep
  273  clear
  274  kubectl edit deploy my-dep
  275  history | grep scale
  276  kubectl scale --replicas=20 deploy/my-dep
  277  kubectl get deploy
  278  kubectl get pods
  279  clear
  280  kubectl scale --replicas=2 deploy/my-dep
  281  kubectl get pods
  282  clear
  283  kubectl get pods
  284  clear
  285  kubectl get pods
  286  kubectl delete pod my-dep-7d597cfb66-868vs my-dep-7d597cfb66-zztmx
  287  kubectl get pods
  288  clear
  289  ls
  290  history
  291  clear
  292  kubectl
  293  clear
  294  kubectl rollout -h
  295  kubectl rollout history dep/my-dep
  296  kubectl rollout history deploy/my-dep
  297  kubectl get pods -o wide
  298  curl http://192.168.1.213
  299  clear
  300  kubectl scale --replicas=30 deploy/my-dep
  301  kubectl rollout status deploy/my-dep
  302  kubectl rollout restart deploy/my-dep
  303  kubectl rollout status deploy/my-dep
  304  kubectl rollout history deploy/my-dep
  305  kubectl get pods -o wide
  306  curl http://192.168.1.243
  307  clear
  308  kubectl
  309  clear
  310  kubectl get pods
  311  clear
  312  kubectl get deploy
  313  kubectl describe deploy my-dep
  314  clear
  315  kubectl patch deployment my-dep --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"scmgalaxy/nginx-devopsschoolv2"}]'
  316  kubectl rollout status deploy/my-dep
  317  kubectl rollout history deploy/my-dep
  318  kubectl get pods -o wide
  319  curl http://192.168.1.254
  320  clear
  321  kubectl rollout -h
  322  clear
  323  kubectl rollout undo -h
  324  clear
  325  kubectl rollout undo deploy/my-dep --to-revision=2
  326  kubectl rollout status deploy/my-dep
  327  kubectl get pods -o wide
  328  curl http://192.168.1.26

Subscribe
Notify of
guest

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

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