-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s.html
255 lines (230 loc) · 7.38 KB
/
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>k8s 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>kubernetes hands on</h2>
<h5></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
* 1-1
* Open link below
[https://labs.play-with-k8s.com/](https://labs.play-with-k8s.com/)
* 1-2
* add 3 nodes
* 1-3
* Execute below command on node1
```
kubeadm init --apiserver-advertise-address $(hostname -i)
```
* 1-4
* Verify the nodes in the cluster
```
kubectl get nodes
```
* 1-5
* Verify runnning pods in the cluster
```
kubectl get pods -n kube-system
```
</section>
<section data-markdown>
### Stage 1
* 1-5
* Copy "kubeadm join" command output from node1,
and paste it on node2 and node3
```
kubeadm join <IP-Address Node1>:6443 --token <token> --discovery-token-ca-cert-hash <discovery-token-ca-cert-hash>
```
* 1-6
* Verify the nodes in the cluster
(statuses are "NotReady" at this point)
```
kubectl get nodes
```
* 1-7
* Install CNI to the cluster by applying
following manifest
```
kubectl apply -f https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml
```
* 1-8
* Verify the nodes in the cluster
(wait until all the status changes to "Ready")
```
kubectl get nodes
```
* 1-9
* Verify runnning pods in the cluster
```
kubectl get pods -n kube-system -o wide
```
* 1-10 (Optional)
* Verify runnning containers on the master node using "docker ps"
```
docker ps
```
</section>
</section>
<section>
<section data-markdown>
### Stage 2
#### Step1-1
kubectl run nginx --image=nginx:latest --restart=Never
kubectl get pods
kubectl get pods -o wide
curl http://<IP-Address nginx>/
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>