Lab 7 – Kubernetes – 6 July 2023
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
25 ls $HOME/.kube/config
26 more /root/.kube/config
27 clear
28 kubectl config vide
29 kubectl config view
30 clear
31 kubectl version
32 kubectl
33 clear
34 kubectl cluster-info
35 kubectl
36 kubectl api-resources
37 kubectl api-version
38 kubectl api-versions
39 kubectl nodes
40 kubectl get nodes
41 kubectl get pods --all-namespaces
==========================================================================
CRUD
create
CMD
create
YAML
create -f yaml
read
CMD
get
describe
YAML
get -f yaml
update
CMD
edit
YAML
apply -f
delete
CMD
delete
YAML
delete -f
What is Namesapce?
49 ls
50 kubectl get ns
51 clear
52 kubectl -h
53 clear
54 kubectl create -h
55 clear
56 kubectl create ns -h
57 cler
58 clear
59 kubectl create ns rajesh
60 kubectl get ns
61 kubectl edit ns rajesh
62 kubectl get ns
63 kubectl describe ns rajesh
64 kubectl delete ns rajesh
65 kubectl get ns
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
69 mkdir rajesh
70 cd rajesh/
71 ls
72 vi pod.yaml
73 clear
74 kubectl get pods
75 kubectl get ns
76 clear
77 ls
78 kubectl get ns
79 kubectl get pods
80 kubectl get pods -n=ashu
81 clear
82 ls
83 kubectl create -f pod.yaml
84 kubectl create ns rajesh
85 kubectl create -f pod.yaml -n=rajesh
86 kubectl get pods
87 kubectl get deploy
88 kubectl delete deploy preeti
89 clear
90 kubectl get pods
91 kubectl edit pod rajesh
92 kubectl get pods
93 kubectl describe pod rajesh
94 clear
95 kubectl get pods
96 kubectl get pods -n=rajesh
97 history
98 clear
99 ls
100 vi pod.yaml
101 kubectl apply -f pod.yaml
102 kubectl describe pod rajesh
103 q!
104 clear
105 ls
106 kubectl delete -f pod.yaml
107 kubectl delete -f pod.yaml -n=rajesh
108 kubectl get pods
===========================
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
114 kubectl get pods
115 kubectl get pods -o wide
116 kubectl logs rajesh
117 curl http://192.168.1.16
118 kubectl logs rajesh
119 curl http://192.168.1.16
120 kubectl logs rajesh
121 kubectl attach rajesh
122 clear
123 kubectl get pods
124 kubectl exec rajesh ls
125 kubectl exec -it rajesh /bin/bash
126 clear
127 kubectl get pods
128 kubectl port-forward -h
129 clear
130 kubectl port-forward --address 0.0.0.0 pod/rajesh 8888:80
131 clear
132 ls
133 kubectl cp pod.yaml rajesh:/tmp
134 kubectl exec rajesh ls /tmp
135 kubectl
136 clear
137 kubectl auth
138 kubectl auth can-i create pod
139 kubectl auth can-i create svc
https://www.devopsschool.com/blog/kubernetes-deployment-strategy-explained-with-example/
176 kubectl expose -h
177 clear
178 kubectl get svc
179 kubectl expose deployment my-dep --port=80 --target-port=80
180 kubectl get svc
181 curl http://10.110.10.104
182 kubectl expose deployment -h
183 kubectl expose deployment my-dep --port=80 --target-port=80 --type=NodePort --name=np
184 kubectl get svc