-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnp_k8s.html
233 lines (208 loc) · 7.58 KB
/
np_k8s.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>13th Dec, 2022 handson</title>
<meta name="description" content="">
<meta name="Minehiko Nohara" content="Macnica Solutions">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="https://www.macnica.co.jp/assets/images/favicon/favicon.ico" />
<link rel="stylesheet" href="/css/reset.css">
<link rel="stylesheet" href="/css/reveal.css">
<link rel="stylesheet" href="/css/theme/moon.css" id="theme">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="/lib/css/monokai.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? '/css/print/pdf.css' : '/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>Netpoleon</br>kubernetes hands on</h2>
<h5>2022/4/07</h5>
<h5>Macnica</h5>
</section>
<section>
<section data-transition="slide" data-background-transition="zoom">
<h3>Cheetsheet</h3>
</section>
</section>
<section>
<section data-markdown>
### Stage 1
https://labs.play-with-k8s.com/#
kubeadm init --apiserver-advertise-address $(hostname -i)
kubectl get nodes
kubectl get pods -n kube-system
kubeadm join <IP-Address Node1>:6443 --token <token> --discovery-token-ca-cert-hash <discovery-token-ca-cert-hash>
kubectl get nodes
kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml
kubectl get nodes
kubectl get pods -n kube-system -o wide
docker ps
</section>
</section>
<section>
<section data-markdown>
- Stage 2
- Step1-1
- ###### Deploy nginx pod by single command
kubectl run nginx --image=nginx:latest --restart=Never
- ###### Show running pods
kubectl get pods
- ###### Show detail about running pods
kubectl get pods -o wide
- ###### See the output and copy IP address
% kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 1/1 Running 0 9h 10.1.0.180 docker-desktop <none> <none>
</section>
<section data-markdown>
- Stage 2
- Step1-2
- ###### create a new pod to access the pod
kubectl run -it curl --image=nginx:latest --restart=Never -- bash
- ###### Run curl command to nginx
root@curl:/# curl http://"IP-Address of nginx"/
- ###### Verify ngnx returns html, and exit from terminal
root@curl:/# exit
</section>
<section data-markdown>
- Stage 2
- Step2-3
- ###### create a new pod to access the pod
kubectl run -it curl --image=nginx:latest --restart=Never -- bash
- ###### Run curl command to nginx
root@curl:/# curl http://"IP-Address of nginx"/
- ###### Verify ngnx returns html, and exit from terminal
root@curl:/# exit kubectl delete pod nginx
kubectl get pods
#### Step1-2
kubectl run nginx --image=nginx:latest --restart=Never --dry-run=client -o yaml
mkdir yamls && cd $_
kubectl run nginx --image=nginx:latest --restart=Never --dry-run=client -o yaml > nginx-pod.yaml
ls
kubectl apply -f nginx-pod.yaml
kubectl get pods
kubectl delete -f nginx-pod.yaml
kubectl get pods
</section>
<section data-markdown>
### Stage 2
#### Step2
kubectl create namespace prod --dry-run=client -o yaml
kubectl create namespace prod --dry-run=client -o yaml > prod-namespace.yaml
ls
kubectl apply -f prod-namespace.yaml
kubectl get namespace
kubectl get pods -n prod
vi nginx-pod.yaml
namespace: prod
:w nginx-pod-prod.yaml
:q!
ls
kubectl apply -f nginx-pod-prod.yaml
kubectl get pods
kubectl get pods -n prod
kubectl delete -f nginx-pod-prod.yaml
kubectl get pods -n prod
</section>
</section>
<section>
<section data-markdown>
### Stage 3
#### Step1
kubectl create deployment nginx --image=nginx:latest --replicas=2 --dry-run=client -o yaml
kubectl create deployment nginx --image=nginx:latest --replicas=2 --dry-run=client -o yaml > nginx-deployment.yaml
ls
kubectl apply -f nginx-deployment.yaml
kubectl get deployment
kubectl get replicasets
kubectl get pods
#### Step2
kubectl get deploy nginx -o yaml
kubectl get replicaset nginx-<hash> -o yaml
kubectl get pods nginx-<hash> -o yaml
</section>
<section data-markdown>
### Stage 3
#### Step3
kubectl get pods
kubectl delete pod nginx-<hash>
kubectl get pods
#### Step4-1
kubectl edit deployment nginx
replicas: 4
:wq
kubectl get deployment
kubectl get replicaset
kubectl get pods
</section>
<section data-markdown>
### Stage 3
#### Step4-2
vi nginx-deployment.yaml
replicas: 4
:wq
kubectl apply -f nginx-deployment.yaml
kubectl get deploy
kubectl get replicaset
kubectl get pods
#### Step4-3
kubectl get deployment
kubectl scale deployment/nginx --replicas=4
kubectl get deployment
kubectl get pods
</section>
</section>
<section>
<section data-markdown>
### Stage 4
#### Step1
kubectl expose deployment nginx --name nginx-service --port=80 --target-port=80 --type=NodePort --dry-run=client -o yaml
kubectl expose deployment nginx --name nginx-service --port=80 --target-port=80 --type=NodePort --dry-run=client -o yaml > nginx-service.yaml
ls
kubectl apply -f nginx-service.yaml
kubectl get services
ip a | grep eth0
</section>
</section>
<section data-transition="slide" data-background="#00008B" data-background-transition="zoom">
FIN
</section>
</div>
</div>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
center: true,
hash: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: '/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: '/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: '/plugin/highlight/highlight.js', async: true },
{ src: '/plugin/search/search.js', async: true },
{ src: '/plugin/zoom-js/zoom.js', async: true },
{ src: '/plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>