Skip to content

Commit 996d992

Browse files
author
zhangjiong
committed
1 parent cca4431 commit 996d992

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

k8shacluster.md

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
#### 每台机器都要装好docker并启动了服务
1818

19-
##### 1. 安装wget
19+
#### 1. 安装wget
2020
```
2121
yum install -y wget
2222
```
23-
##### 2. 提前下载需要的k8s docker images
23+
#### 2. 提前下载需要的k8s docker images
2424
```
2525
MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings
2626
@@ -49,7 +49,7 @@ echo 'swapoff -a' >> /etc/profile
4949
source /etc/profile
5050
```
5151

52-
##### 设置环境IP
52+
#### 4. 设置环境IP
5353
```
5454
vip=30.0.2.10
5555
master1=30.0.2.11
@@ -58,7 +58,7 @@ master3=30.0.2.13
5858
node1=30.0.2.14
5959
netswitch=`ifconfig | grep 'UP,BROADCAST,RUNNING,MULTICAST' | awk -F: '{print $1}'`
6060
```
61-
#### 4. 设置hosts
61+
#### 5. 设置hosts
6262
```
6363
cat >>/etc/hosts<<EOF
6464
${master1} master1
@@ -67,12 +67,12 @@ ${master3} master3
6767
${node1} node1
6868
EOF
6969
```
70-
#### 5. 生成公钥与私钥对
70+
#### 6. 生成公钥与私钥对
7171
```
7272
ssh-keygen -t rsa
7373
```
7474

75-
#### 6.
75+
#### 7.
7676
```
7777
cat <<EOF > /etc/sysctl.d/k8s.conf
7878
net.bridge.bridge-nf-call-ip6tables = 1
@@ -85,7 +85,7 @@ EOF
8585
sysctl --system
8686
8787
```
88-
#### 7.
88+
#### 8.
8989
```
9090
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
9191
modprobe -- ip_vs
@@ -98,11 +98,11 @@ EOF
9898
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
9999
100100
```
101-
#### 8. 安装keepalived+haproxy
101+
#### 9. 安装keepalived+haproxy
102102
```
103103
yum install -y keepalived haproxy ipvsadm ipset
104104
```
105-
#### 9.
105+
#### 10.
106106
```
107107
mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
108108
@@ -130,7 +130,7 @@ END4
130130
131131
```
132132

133-
##### 10. 配置haproxy
133+
#### 11. 配置haproxy
134134
```
135135
cat >/etc/haproxy/haproxy.cfg<<END1
136136
global
@@ -164,19 +164,19 @@ END1
164164
165165
```
166166

167-
##### 11. 启动 keepalived
167+
#### 12. 启动 keepalived
168168
```
169169
systemctl enable keepalived && systemctl start keepalived && systemctl status keepalived
170170
171171
```
172-
##### 12. 启动 haproxy
172+
#### 13. 启动 haproxy
173173
```
174174
systemctl enable haproxy && systemctl start haproxy && systemctl status haproxy
175175
176176
```
177177

178178

179-
##### 13. 设置k8s repo
179+
#### 14. 设置k8s repo
180180
```
181181
cat << EOF > /etc/yum.repos.d/kubernetes.repo
182182
[kubernetes]
@@ -189,19 +189,19 @@ gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.a
189189
EOF
190190
```
191191

192-
##### 14. 安装 kube 组件
192+
#### 15. 安装 kube 组件
193193
```
194194
yum makecache fast
195195
yum install -y kubelet kubeadm kubectl
196196
```
197197

198-
##### 15. 这是cgroupfs
198+
#### 16. 这是cgroupfs
199199
```
200200
echo 'Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs"' >> /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
201201
202202
systemctl enable kubelet && systemctl start kubelet && systemctl status kubelet
203203
```
204-
##### 16. 设置初始化位置文件
204+
#### 17. 设置初始化位置文件
205205
```
206206
cat >kubeadm-init.yaml<<END1
207207
apiVersion: kubeadm.k8s.io/v1beta1
@@ -253,27 +253,27 @@ END1
253253
kubeadm init --config kubeadm-init.yaml
254254
255255
```
256-
##### 17. 设置kube config
256+
#### 18. 设置kube config
257257
```
258258
mkdir -p $HOME/.kube
259259
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
260260
sudo chown $(id -u):$(id -g) $HOME/.kube/config
261261
262262
```
263-
##### 18. 查看容器
263+
#### 19. 查看容器
264264
```
265265
kubectl get cs
266266
kubectl get pod --all-namespaces -o wide
267267
```
268-
##### 19. 下载flannel配置
268+
#### 20. 下载flannel配置
269269
```
270270
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
271271
```
272-
##### 20. 应用flannel
272+
#### 21. 应用flannel
273273
```
274274
kubectl apply -f kube-flannel.yml
275275
```
276-
##### 21. 查看容器
276+
#### 22. 查看容器
277277
```
278278
kubectl get nodes
279279
kubectl -n kube-system get pod -o wide
@@ -286,7 +286,7 @@ kubectl -n kube-system get pod -o wide
286286

287287
#### 每台机器都要装好docker并启动了服务
288288

289-
##### 1.
289+
#### 1. 下载容器镜像
290290
```
291291
MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings
292292
@@ -310,13 +310,13 @@ docker tag jmgao1983/flannel:v0.11.0-amd64 quay.io/coreos/flannel:v0.11.0-amd64
310310
```
311311

312312

313-
##### 2. 关闭swap
313+
#### 2. 关闭swap
314314
```
315315
echo 'swapoff -a' >> /etc/profile
316316
source /etc/profile
317317
```
318318

319-
##### 3. 设置环境IP
319+
#### 3. 设置环境IP
320320
```
321321
vip=30.0.2.10
322322
master1=30.0.2.11
@@ -326,7 +326,7 @@ node1=30.0.2.14
326326
netswitch=`ifconfig | grep 'UP,BROADCAST,RUNNING,MULTICAST' | awk -F: '{print $1}'`
327327
```
328328

329-
##### 4. 设置hosts
329+
#### 4. 设置hosts
330330
```
331331
cat >>/etc/hosts<<EOF
332332
${master1} master1
@@ -335,7 +335,7 @@ ${master3} master3
335335
${node1} node1
336336
EOF
337337
```
338-
##### 5. 复制公钥
338+
#### 5. 复制公钥
339339
```
340340
mkdir /root/.ssh
341341
chmod 700 /root/.ssh
@@ -354,7 +354,6 @@ scp root@master1:$HOME/.kube/config $HOME/.kube/config
354354
355355
```
356356

357-
358357
#### 7. 配置k8s.conf
359358
```
360359
cat <<EOF > /etc/sysctl.d/k8s.conf
@@ -415,7 +414,7 @@ END4
415414
416415
```
417416

418-
##### 11. 配置haproxy
417+
#### 11. 配置haproxy
419418
```
420419
cat >/etc/haproxy/haproxy.cfg<<END1
421420
global
@@ -449,17 +448,17 @@ END1
449448
450449
```
451450

452-
##### 12. 启动keepalived
451+
#### 12. 启动keepalived
453452
```
454453
systemctl enable keepalived && systemctl start keepalived && systemctl status keepalived
455454
```
456-
##### 13. 启动haproxy
455+
#### 13. 启动haproxy
457456
```
458457
systemctl enable haproxy && systemctl start haproxy && systemctl status haproxy
459458
```
460459

461460

462-
##### 14. 设置k8s repo
461+
#### 14. 设置k8s repo
463462
```
464463
cat << EOF > /etc/yum.repos.d/kubernetes.repo
465464
[kubernetes]
@@ -476,13 +475,13 @@ yum install -y kubelet kubeadm kubectl
476475
477476
```
478477

479-
##### 15. 设置cgroupfs
478+
#### 15. 设置cgroupfs
480479
```
481480
echo 'Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs"' >> /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
482481
systemctl enable kubelet && systemctl start kubelet && systemctl status kubelet
483482
484483
```
485-
##### 16. 加入集群
484+
#### 16. 加入集群
486485
```
487486
488487
(master)
@@ -600,7 +599,7 @@ systemctl enable kubelet && systemctl start kubelet && systemctl status kubelet
600599
601600
```
602601

603-
##### 10. 设置kube config文件
602+
#### 10. 设置kube config文件
604603
```
605604
mkdir -p $HOME/.kube
606605
scp root@master1:$HOME/.kube/config $HOME/.kube/config

0 commit comments

Comments
 (0)