Day 2 – Kubernetes Sept 2023

Lab#1 – Set a k8 cluster

Demo – Namespace

Demo – Pod

DEMO – rc

Demo – Deployment

Day 2 – Kubernetes Sept 2023

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

Demo - Namespace

Demo - Pod

DEMO - rc

Demo - Deployment
===========================================================
C R U D
------------------------------------
	Create
		cmd
			create 
		yaml	
			create -f yaml
	Read
		cmd
			get
			describe
		yaml
			get -f yaml
	Update
		cmd
			edit
		yaml
			apply -f yaml

	Delete
		cmd
			delete
		yaml
			delete -f yaml





Namespace

 328  ls
  329  kubectl api-resources
  330  clear
  331  kubectl
  332  clear
  333  kubectl get ns
  334  kubectl create
  335  kubectl create -h
  336  kubectl create ns -h
  337  clear
  338  kubectl create ns dev
  339  kubectl create ns qa
  340  kubectl get ns
  341  kubectl describe ns dev
  342  kubectl edit ns dev
  343  kubectl describe ns dev
  344  kubectl delete ns dev

Working with POD

  354  vi pod.yaml
  355  kubectl create -f pod.yaml
  356  kubectl get pods
  357  kubectl get ns
  358  kubectl create -f pod.yaml
  359  kubectl create -f pod.yaml -n=qa
  360  kubectl get ns
  361  kubectl get pods
  362  kubectl get pods -n=qa
  363  kubectl describe pod rajesh
  364  ls
  365  vi pod.yaml
  366  kubectl describe pod rajesh
  367  kubectl apply -f pod.yaml
  368  kubectl describe pod rajesh
  369  clear
  370  ls
  371  kubectl delete -f pod.yaml
  372  kubectl delete pod rajesh -n=qa
  373  history

How to access and troubleshoot pods/containers?

=============================================================
How to access and troubleshoot pods/containers?
---------------------------------------------------
Troubleshooting and Debugging Commands:
  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


  396  kubectl logs rajesh
  397  curl http://192.168.0.7
  398  kubectl logs rajesh
  399  kubectl logs rajeshclear
  400  clear
  401  kubectl attach rajesh
  402  kubectl exec rajesh ls
  403  kubectl exec -it rajesh /bin/bash
  404  clear
  405  kubectl port-forward -h
  406  clear
  407  kubectl port-forward --address 0.0.0.0 pod/rajesh 8888:80
  408  ckear
  409  ls
  410  kubectl exec rajesh ls /tmp
  411  kubectl cp pod.yaml rajesh:/tmp
  412  kubectl exec rajesh ls /tmp
  413  kubectl auth
  414  kubectl auth can-i
  415  kubectl auth can-i create pdo
  416  kubectl auth can-i create pod
  417  kubectl auth can-i create ns

Replication Controller

 421  cd rc.yaml
  422  vi rc.yaml
  423  kubectl create -f rc.yaml
  424  kubectl get rc
  425  kubectl get pods
  426  kubectl
  427  kubectl scale -h
  428  kubectl get rc
  429  kubectl scale --replicas=20 rc/replicationcontroller-example
  430  kubectl get rc
  431  kubectl get pods
  432  kubectl scale --replicas=2 rc/replicationcontroller-example
  433  kubectl get pods
  434  kubectl scale --replicas=0 rc/replicationcontroller-example
  435  kubectl get pods
  436  kubectl scale --replicas=5 rc/replicationcontroller-example
  437  kubectl get pods
  438  clear
  439  kubectl get pods
  440  kubectl delete pod rajesh
  441  kubectl get pods
  442  kubectl delete pod replicationcontroller-example-6fmtr replicationcontroller-example-8sl9j replicationcontroller-example-hzjff
  443  kubectl get pods
  444  kubectl get rc
  445  kubectl delete rc replicationcontroller-example
  446  kubectl get rc
  447  kubectl create -f rc.yaml
  448  kubectl get rc
  449  kubectl describe rc replicationcontroller-example
  450  kubectl get pods
  451  kubectl describe pod replicationcontroller-example-2gf5p
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