k8s离线安装进阶版
# 1.参考之前的文章做好以下几点:
- 下载kubernetes 离线安装包.
- 下载最新版本sealos.
- 务必同步服务器时间
- 主机名不可重复
然后,一条命令搞定k8s集群(哭了)
[root@master ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@master ~]# ll
total 650176
-rw-------. 1 root root 1259 Oct 13 18:21 anaconda-ks.cfg
-rw-r--r--. 1 root root 639178706 May 27 11:40 kube1.18.0.tar.gz
-rw-r--r--. 1 root root 26593448 Oct 22 16:11 sealos
[root@master ~]# chmod +x sealos && mv sealos /usr/bin
[root@master ~]# ll
total 624204
-rw-------. 1 root root 1259 Oct 13 18:21 anaconda-ks.cfg
-rw-r--r--. 1 root root 639178706 May 27 11:40 kube1.18.0.tar.gz
[root@master ~]# pwd
/root
[root@master ~]# sealos init --passwd hadoop \
> --master 192.168.0.190 \
> --node 192.168.0.191 --node 192.168.0.192 \
> --pkg-url /root/kube1.18.0.tar.gz \
> --version v1.18.0
16:16:30 [INFO] [ssh.go:13] [ssh][192.168.0.190:22] hostname
16:16:30 [DEBG] [ssh.go:25] [ssh][192.168.0.190:22]command result is: master
16:16:30 [INFO] [ssh.go:58] [ssh][192.168.0.190:22] cat /etc/hosts |grep master || echo '192.168.0.190 master' >> /etc/hosts
16:16:30 [INFO] [ssh.go:51] [192.168.0.190:22] 127.0.0.1 master
16:16:30 [INFO] [check.go:52] [192.168.0.190:22] ------------ check ok
16:16:30 [INFO] [ssh.go:13] [ssh][192.168.0.191:22] hostname
16:16:31 [DEBG] [ssh.go:25] [ssh][192.168.0.191:22]command result is: node1
16:16:31 [INFO] [ssh.go:58] [ssh][192.168.0.191:22] cat /etc/hosts |grep node1 || echo '192.168.0.191 node1' >> /etc/hosts
16:16:31 [INFO] [ssh.go:51] [192.168.0.191:22] 127.0.0.1 node1
16:16:31 [INFO] [check.go:52] [192.168.0.191:22] ------------ check ok
16:16:31 [INFO] [ssh.go:13] [ssh][192.168.0.192:22] hostname
16:16:31 [DEBG] [ssh.go:25] [ssh][192.168.0.192:22]command result is: node2
16:16:31 [INFO] [ssh.go:58] [ssh][192.168.0.192:22] cat /etc/hosts |grep node2 || echo '192.168.0.192 node2' >> /etc/hosts
16:16:32 [INFO] [ssh.go:51] [192.168.0.192:22] 127.0.0.1 node2
16:16:32 [INFO] [check.go:52] [192.168.0.192:22] ------------ check ok
16:16:32 [INFO] [print.go:13]
[globals]sealos config is: {"Hosts":["192.168.0.190:22","192.168.0.191:22","192.168.0.192:22"],"Masters":["192.168.0.190:22"],"Nodes":["192.168.0.191:22","192.168.0.192:22"]}
16:16:32 [INFO] [ssh.go:58] [ssh][192.168.0.192:22] mkdir -p /usr/bin || true
16:16:32 [INFO] [ssh.go:58] [ssh][192.168.0.191:22] mkdir -p /usr/bin || true
16:16:32 [INFO] [ssh.go:58] [ssh][192.168.0.190:22] mkdir -p /usr/bin || true
16:16:32 [DEBG] [download.go:29] [192.168.0.191:22]please wait for mkDstDir
16:16:32 [DEBG] [download.go:31] [192.168.0.191:22]please wait for before hook
...喝杯咖啡等待即可
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
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
# 2.验证
差不多15分钟就搭建好了!(又哭了) 感谢sealyun大佬,如官网所描述>>>>>>>纵享丝滑
16:34:30 [INFO] [ssh.go:58] [ssh][192.168.0.191:22] rm -rf /root/kube
16:34:31 [DEBG] [print.go:20] ==>SendPackage==>KubeadmConfigInstall==>InstallMaster0==>JoinMasters==>JoinNodes
16:34:31 [INFO] [print.go:25] sealos install success.
___ ___ ___ ___ ___ ___
/\ \ /\ \ /\ \ /\__\ /\ \ /\ \
/::\ \ /::\ \ /::\ \ /:/ / /::\ \ /::\ \
/:/\ \ \ /:/\:\ \ /:/\:\ \ /:/ / /:/\:\ \ /:/\ \ \
_\:\~\ \ \ /::\~\:\ \ /::\~\:\ \ /:/ / /:/ \:\ \ _\:\~\ \ \
/\ \:\ \ \__\ /:/\:\ \:\__\ /:/\:\ \:\__\ /:/__/ /:/__/ \:\__\ /\ \:\ \ \__\
\:\ \:\ \/__/ \:\~\:\ \/__/ \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ \:\ \/__/
\:\ \:\__\ \:\ \:\__\ \::/ / \:\ \ \:\ /:/ / \:\ \:\__\
\:\/:/ / \:\ \/__/ /:/ / \:\ \ \:\/:/ / \:\/:/ /
\::/ / \:\__\ /:/ / \:\__\ \::/ / \::/ /
\/__/ \/__/ \/__/ \/__/ \/__/ \/__/
官方文档:sealyun.com
项目地址:github.com/fanux/sealos
QQ群 :98488045
常见问题:sealyun.com/faq
[root@master ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
master Ready master 88s v1.18.0
node1 Ready <none> 57s v1.18.0
node2 Ready <none> 57s v1.18.0
[root@master ~]# kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-84445dd79f-57xsb 1/1 Running 0 92s
kube-system calico-node-48vmr 1/1 Running 0 77s
kube-system calico-node-rzp45 1/1 Running 0 80s
kube-system calico-node-w2jbx 1/1 Running 0 92s
kube-system coredns-66bff467f8-cjhdr 1/1 Running 0 92s
kube-system coredns-66bff467f8-g2kxl 1/1 Running 0 92s
kube-system etcd-master 1/1 Running 0 99s
kube-system kube-apiserver-master 1/1 Running 0 99s
kube-system kube-controller-manager-master 1/1 Running 0 99s
kube-system kube-proxy-7cnrg 1/1 Running 0 80s
kube-system kube-proxy-7l84h 1/1 Running 0 77s
kube-system kube-proxy-ld98f 1/1 Running 0 92s
kube-system kube-scheduler-master 1/1 Running 0 99s
kube-system kube-sealyun-lvscare-node1 1/1 Running 0 66s
kube-system kube-sealyun-lvscare-node2 1/1 Running 0 73s
[root@master ~]#
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
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
- 增加master
sealos join --master 192.168.0.6 --master 192.168.0.7
sealos join --master 192.168.0.6-192.168.0.9 # 或者多个连续IP
1
2
2
- 增加node
sealos join --node 192.168.0.6 --node 192.168.0.7
sealos join --node 192.168.0.6-192.168.0.9 # 或者多个连续IP
1
2
2
- 删除指定master节点
注意clean不加任何参数会清理整个集群
sealos clean --master 192.168.0.6 --master 192.168.0.7
sealos clean --master 192.168.0.6-192.168.0.9 # 或者多个连续IP
1
2
3
2
3
- 删除指定node节点
sealos clean --node 192.168.0.6 --node 192.168.0.7
sealos clean --node 192.168.0.6-192.168.0.9 # 或者多个连续IP
1
2
2
# 3.dashboard访问
sealos install --pkg-url https://github.com/sealstore/dashboard/releases/download/v2.0.0-bata5/dashboard.tar
1
使用上述命令安装完dashboard后日志中会输出token,登录页面时需要使用.
https://你的master地址:32000 chrome访问不了就用火狐
或者使用此命令获取token
kubectl get secret -nkubernetes-dashboard \
$(kubectl get secret -n kubernetes-dashboard|grep dashboard-token |awk '{print $1}') \
-o jsonpath='{.data.token}' | base64 --decode
1
2
3
2
3