0% found this document useful (0 votes)
57 views10 pages

Application Deployment-Kuber

The document discusses several Kubernetes labs and commands: Lab 1 covers creating pods using commands or files. Lab 2 covers the meaning of labels in pod files. Lab 3 discusses high availability and scalability. Lab 4 covers deploying pods using private registries. Lab 5 introduces replica sets. The rest of the document shows examples of creating replica sets, deleting and recreating pods, exploring pod logs and executing commands in pods. It also demonstrates creating pod configuration files and deploying pods using files.

Uploaded by

apa
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)
57 views10 pages

Application Deployment-Kuber

The document discusses several Kubernetes labs and commands: Lab 1 covers creating pods using commands or files. Lab 2 covers the meaning of labels in pod files. Lab 3 discusses high availability and scalability. Lab 4 covers deploying pods using private registries. Lab 5 introduces replica sets. The rest of the document shows examples of creating replica sets, deleting and recreating pods, exploring pod logs and executing commands in pods. It also demonstrates creating pod configuration files and deploying pods using files.

Uploaded by

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

Unit02: Application

lab1: pod creation using command / file method

lab2: what is meaning of label keyword in pod file

lab3: HighAvailability & Scalability

pod creation using Pod Controller .

1) RC: Replication Controller:

1) it will maintain desired pod state .


2) Scalability

lab4: deploying pod using Private Registry

lab5: RS: Replica Set =

[root@kubemaster ~]# clear


[root@kubemaster ~]# cat > rs.yml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# modify replicas according to your case
replicas: 3
selector:
matchLabels:
tier: frontend
template:
metadata:
labels:
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
[root@kubemaster ~]# kubectl create -f rs.yml
replicaset.apps/frontend created
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get rs
NAME DESIRED CURRENT READY AGE
frontend 3 3 0 16s
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
frontend-8ppxd 0/1 ContainerCreating 0 23s
frontend-9s7rx 0/1 ContainerCreating 0 23s
frontend-ch54k 0/1 ContainerCreating 0 23s
nginx-9lpg4 1/1 Running 0 8m40s
nginx-rz858 1/1 Running 0 8m40s
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
frontend-8ppxd 1/1 Running 0 33s
frontend-9s7rx 0/1 ContainerCreating 0 33s
frontend-ch54k 1/1 Running 0 33s
nginx-9lpg4 1/1 Running 0 8m50s
nginx-rz858 1/1 Running 0 8m50s
[root@kubemaster ~]# kubectl delete pod frontend-8ppxd
pod "frontend-8ppxd" deleted
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
frontend-9s7rx 1/1 Running 0 46s
frontend-ch54k 1/1 Running 0 46s
frontend-dq6mr 1/1 Running 0 6s
nginx-9lpg4 1/1 Running 0 9m3s
nginx-rz858 1/1 Running 0 9m3s
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl delete rs frontend
replicaset.apps "frontend" deleted
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# RC vs RS different
-bash: RC: command not found
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# history
1 ifconfig
2 cd /ets
3 cd /etc
4 ls -lrth
5 ls host
6 cat hosts
7 vi hosts
8 cat hosts
9 ping kubemaster
10 ping kubemaster.example.com
11 yum-config-manager --add-repo
https://download.docker.com/linux/centos/docker-ce.repo
12 yum install docker-ce -y
13 systemctl start docker
14 system enable docker
15 systemctl enable docker
16 vi /etc/yum.repos.d/kube.repo
17 yum install kubeadm -y
18 cat kube.repo
19 pwd
20 cd yum.repos.d/
21 ls -lrth
22 cat kube.repo
23 yum install kubeadm -y
24 vi kube.repo
25 cat kube.repo
26 yum install kubeadm -y
27 rpm -qa kubelet
28 systemctl start kubelet
29 systemctl enable kubelet
30 docker ps
31 docker images
32 kubeadm init
33 kubeadm init --ignore-preflight-errors=all
34 vi /etc/docker/daemon.json
35 cat /etc/docker/daemon.json
36 system daemon-reload
37 systemctl daemon-reload
38 systemctl restart docker
39 kubeadm init --ignore-preflight-errors=all
40 netstat -tnlp | grep -i api
41 netstat -tnlp | grep -i contol
42 netstat -tnlp | grep -i control
43 netstat -tnlp | grep -i schedul
44 kubectl get pods
45 kubectl get pod
46 kubectl get pods --all-namespcae
47 kubectl get pods --all-namespe
48 kubectl get pods --all-namespace
49 kubectl get pods --all-namespaces
50 getenforce
51 setenforce 0
52 getenforce
53 vi /etc/sysconfig/selinux
54 swapon -s
55 swapoff -a
56 vi /etc/fstab
57 hostnamectl set-hostname kubemaster.example.com
58 bash
59 kubectl get ns
60 kubectl get pods -n kube-system
61 kubectl get pods kube-proxy-86n52 -n kube-system
62 kubectl get logs kube-proxy-86n52 -n kube-system
63 kubectl get log kube-proxy-86n52 -n kube-system
64 kubectl log kube-proxy-86n52 -n kube-system
65 kubectl get nodes
66 netstat -tnlp | grep -i api
67 kubeadm token list
68 kubectl get events
69 kubectl get events -n kube-system
70 rpm -qa kubectl
71 rpm -qa kubeadm
72 kubectl get nodes
73 ls -lrt /etc/kubernetes/admin.conf
74 grep -i server /etc/kubernetes/admin.conf
75 ifconfig
76 netstat -tnlp | grep -i api
77 kubectl get nodes --kubeconfig=/etc/kubernetes/admin.conf
78 kubectl get pod
79 kubectl get pod --kubeconfig=/etc/kubernetes/admin.conf
80 export KUBECONFIG=/etc/kubernetes/admin.conf
81 unset KUBECONFIG
82 cp /etc/kubernetes/admin.conf .kube/config
83 kubectl get nodes
84 kubectl get ns
85 kubectl get pod -n kube-system
86 systemctl is-active docker
87 systemctl is-active kubelet
88 kubectl get pod -n kube-system -o wide
89 ifconfig eth0
90 kubectl get events
91 rpm -qa
92 rpm -qa kubectl
93 kubectl get onodes
94 kubectl get nodes
95 ls -lrth /etc/kubernetes/admin.conf
96 grep -i server /etc/kubernetes/admin.conf
97 ifconfig
98 netstat -tnlp | grep -i api
99 netstat -tnlp | grep -w 6443
100 cat /etc/kubernetes/admin.conf
101 kubectl get nodes --kubeconfig=/etc/kubernetes/admin.conf
102 docker ps
103 kubectl get pod
104 kubectl get pod --kubeconfig=/etc/kubernetes/admin.conf
105 pwd
106 ls -lrth
107 export KUBECONFIG=/etc/kubernetes/admin.conf
108 ls -lrth
109 cd /home/
110 ls -lrth
111 cd /root
112 cd /
113 ls -lrth
114 cd /root
115 kubectl get pod
116 kubectl get nodes
117 unset KUBECONFIG
118 cp /etc/kubernetes/admin.conf .kube/config
119 kubectl get nodes
120 pwd
121 ls -lrth
122 ls -larth
123 cd .kube/
124 ls -lrth
125 cat config
126 cd ..
127 pwd
128 kubectl get pod
129 kubectl get nd
130 kubectl get ns
131 kubectl get pod -n kube-system
132 systemctl is-active docker
133 systemctl is-active kubelet
134 kubectl get pod -n kube-system -o wide
135 ifconfig
136 kubectl get componentstatus
137 cat /etc/docker/daemon.json
138 systemctl daemon reload
139 cat /etc/yum.repos.d/kube.repo
140 kubeadm token list
141 kubeadm token delete
142 kubeadm token create
143 kubeadm token list
144 kubeadm token delete tq3wvp.03aupx21fsbt1tpb
145 kubeadm token list
146 ls -larth /etc/kubernetes/pki/
147 cat ca.crt
148 kubeadm token create --print-join-command
149 kubectl get node
150 kubectl get events
151 kubectl get events -n kube-system
152 kubectl get pod -n kube-system
153 kubectl logs kube-proxy-86n52 -n kube-system
154 curl https://docs.projectcalico.org/manifests/calico.yaml -O
155 ls
156 cat calico.yaml
157 kubectl apply -f calico.yaml
158 kubectl get pod -o wide -n kube.systemc
159 kubectl get pod -o wide -n kube.system
160 kubectl get pod -o wide -n kube-system
161 kubectl get node
162 kubectl run test --image=nginx
163 kubectl get pod -o wide
164 ping 192.168.71.194
165 kubeadm token create --print-join-command
166 kubectl get nodes
167 kubectl get pod
168 kebectl delete pod
169 kebectl delete pod test
170 kubectl delete pod test
171 kubectl run test --image=nginx
172 kubectl get ns
173 kubectl get pod
174 kubectl delete pod test
175 kubectl run test --image=docker.io/nginx
176 kubectl get pod
177 kubectl get pod -o wide
178 kubectl log test
179 kubectl logs test
180 kubectl exec -it test /bin/bash
181 kubectl delete pod test
182 kubectl run test --image=docker.io/nginx
183 kubectl logs test
184 kubectl exec -it test /bin/bash
185 kubectl get pod -o wide
186 curl 192.168.71.199:
187 curl 192.168.71.199
188 kubectl get pod test
189 kubectl describe pod test
190 kubectl delete pod test
191 kubectl run test --image=docker.io/nginx --dry-run -o yaml
192 ls -lrth
193 cat pod.yaml
194 cat > pod.yaml
195 cat > pod.yml
196 kubectl run test --image=docker.io/nginx --dry-run -o yaml
197 cat > pod.yml
198 ls -lrth
199 cat pod.yml
200 rm -rf pod.yml pod.yaml
201 ls -larth
202 pwd
203 cd //
204 ls -larth
205 cd /ro
206 cd /root
207 ls -larth
208 kubectl run test1 --image=nginx --dry-run -o yaml
209 cat > pod.yml
210 ls -larth
211 cat pod.yml
212 vi pod.yml
213 cat pod.yml
214 kubectl create -f pod.yml
215 cat pod.yml
216 kubectl api-resources
217 kubectl run test1 --image-nginx --dry-run -o yaml > pod1.yml
218 kubectl run test1 --image=nginx --dry-run -o yaml > pod1.yml
219 ls -lrth
220 cat pod1.yml
221 kubectl explain pod
222 kubectl explain pod.metadata
223 kubectl explain VolumeAttachment
224 kubectl explain VolumeAttachment.status
225 kubectl get pod
226 kubectl delete -f pod.yml
227 kubectl delete -f pod1.yml
228 kubectl get pod
229 kubectl logs test1
230 kubectl log test1
231 kubectl logs test1
232 kubectl delete pod test1
233 ls -larth
234 cat pod.yml
235 cat pod1.yml
236 rm -rf pod.yml
237 rm -rf pod1.yml
238 ls -lrth
239 ls -larth
240 kubectl get pod
241 kubectl delete --help
242 kubectl delete -f pod --help
243 kubectl get pod
244 kubectl delete pod -f test1
245 kubectl get pod
246 kubectl describe pod test1
247 kubectl get logs test1
248 kubectl logs test1
249 kubectl get pod
250 ifconfig
251 clear
252 kubectl get nodes
253 ls
254 kubectl create -f calico.yaml
255 clear
256 kubectl run test --image=nginx --dry-run -o yaml > pod.yml
257 vim pod.yml
258 vi pod.yml
259 kubectl create -f pod.yml
260 vi pod.yml
261 kubectl create -f pod.yml
262 vi pod.yml
263 kubectl create -f pod.yml
264 kubectl get pod
265 kubectl get pod --show-labels
266 kubectl get pod -l color=green
267 cat pod.yml
268 kubectl delete pod -l color=red
269 kubectl run test --image=nginx --dry-run -o yaml
270 kubectl run test --image=nginx --label=env=qa --dry-run -o yaml
271 kubectl run test --image=nginx --labesl=env=qa --dry-run -o yaml
272 kubectl run test --image=nginx --labels=env=qa --dry-run -o yaml
273 kubectl run test --image=nginx --labels=env=qa,color=blue --dry-run -o
yaml
274 kubectl run test --image=nginx --labels=env=qa,color=blue
275 kubectl get pod test --show-labels
276 kubectl get po -l env=qa
277 kubectl get po -l color=blue
278 clear
279 kubectl get pod
280 '
281 kubectl delete pod test
282 kubectl get pod
283 kubectl api-resources
284 kubectl get pod
285 cat rc.yml
286 kubectl explain rc.spec
287 cat rc.yml
288 kubectl explain rc.spec.template.spec
289 clear
290 cat > rs.yml
291 kubectl create -f rs.yml
292 kubectl get rs
293 kubectl get pod
294 kubectl delete pod frontend-8ppxd
295 kubectl get pod
296 kubectl delete rs frontend
297 RC vs RS different
298 history
[root@kubemaster ~]#

Lab6: How to take update on application in kubernetes .

Rollout(Upgrade ) & Rollback for Application in kubernetes .

1) Deployment : RS + Rollout + Rollback

command:

yaml file

Deployment:
update:
1) Rollingupdate (Bydefault enable)
Create: 25%: 25% max surge
delete: 25% : 25% max unavailable

2) Recreate

RC VS RS
______________

label
or selector
_____________________

metadata:
name: nginx
spec:
replicas: 3
selector:
color: red
template:
metadata:
name: nginx
labels:
color: red
spec:
containers:
- name: nginx
image: nginx
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl delete rc nginx
replicationcontroller "nginx" deleted
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# clear
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# vi pod.yml
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl create -f pod.yml
pod/demo created
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get po --show-labels
NAME READY STATUS RESTARTS AGE LABELS
demo 1/1 Running 0 6s color=blue
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# vi rc.yml
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl create -f rc.yml
replicationcontroller/krnetwork created
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
demo 1/1 Running 0 72s
krnetwork-58r7g 1/1 Running 0 23s
krnetwork-v7mxh 1/1 Running 0 23s
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get rc
NAME DESIRED CURRENT READY AGE
krnetwork 3 3 3 33s
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl describe pod demo | grep -i controller
Controlled By: ReplicationController/krnetwork
[root@kubemaster ~]# vi rc.yml
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get po

NAME READY STATUS RESTARTS AGE


demo 1/1 Running 0 5m7s
krnetwork-58r7g 1/1 Running 0 4m18s
krnetwork-v7mxh 1/1 Running 0 4m18s
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl delete pod demo
pod "demo" deleted
[root@kubemaster ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
krnetwork-58r7g 1/1 Running 0 4m25s
krnetwork-9tj6b 0/1 ContainerCreating 0 3s
krnetwork-v7mxh 1/1 Running 0 4m25s
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl create -f pod.yml
pod/demo created
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
demo 0/1 Terminating 0 2s
krnetwork-58r7g 1/1 Running 0 4m45s
krnetwork-9tj6b 1/1 Running 0 23s
krnetwork-v7mxh 1/1 Running 0 4m45s
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
krnetwork-58r7g 1/1 Running 0 5m21s
krnetwork-9tj6b 1/1 Running 0 59s
krnetwork-v7mxh 1/1 Running 0 5m21s
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl create -f pod.yml
pod/demo created
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get po
NAME READY STATUS RESTARTS AGE
demo 0/1 Terminating 0 2s
krnetwork-58r7g 1/1 Running 0 5m28s
krnetwork-9tj6b 1/1 Running 0 66s
krnetwork-v7mxh 1/1 Running 0 5m28s
[root@kubemaster ~]#
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get rc
NAME DESIRED CURRENT READY AGE
krnetwork 3 3 3 5m42s
[root@kubemaster ~]# vi pod.yml
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl create -f pod.yml
pod/demo created
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
demo 0/1 ContainerCreating 0 3s
krnetwork-58r7g 1/1 Running 0 6m11s
krnetwork-9tj6b 1/1 Running 0 109s
krnetwork-v7mxh 1/1 Running 0 6m11s
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl describe pod demo | grep -i controll
[root@kubemaster ~]#
[root@kubemaster ~]# kubectl describe pod krnetwork-58r7g | grep -i controll
Controlled By: ReplicationController/krnetwork
[root@kubemaster ~]#
[root@kubemaster ~]# vi rc.yml
[root@kubemaster ~]#
[root@kubemaster ~]#

You might also like