KubeSphere安装

k8s 集群一键安装

https://github.com/fanux/sealos

环境信息

主机名IP地址
master0192.168.0.2
master1192.168.0.3
master2192.168.0.4
node0192.168.0.5

服务器密码:123456

只需要准备好服务器,在任意一台服务器上执行下面命令即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#指定目录
cd /home

# 下载并安装sealos, sealos是个golang的二进制工具,直接下载拷贝到bin目录即可, release页面也可下载
wget -c https://sealyun.oss-cn-beijing.aliyuncs.com/latest/sealos && \
chmod +x sealos && mv sealos /usr/bin

# 下载离线资源包
wget -c https://sealyun.oss-cn-beijing.aliyuncs.com/7b6af025d4884fdd5cd51a674994359c-1.18.0/kube1.18.0.tar.gz

#修改主机名(每台主机都需要修改)
hostnamectl set-hostname 192.168.0.2

# 安装一个三master的kubernetes集群
sealos init --passwd 123456 \
--master 192.168.0.2 --master 192.168.0.3 --master 192.168.0.4 \
--node 192.168.0.5 \
--pkg-url /home/kube1.18.0.tar.gz \
--version v1.18.0

参数含义

参数名含义示例
passwd服务器密码123456
masterk8s master节点IP地址192.168.0.2
nodek8s node节点IP地址192.168.0.3
pkg-url离线资源包地址,支持下载到本地,或者一个远程地址/root/kube1.16.0.tar.gz
version资源包对应的版本v1.16.0

其他版本离线包

https://sealyun.oss-cn-beijing.aliyuncs.com/6300ecea5ab9621-14-1/kube1.14.1.tar.gz

https://sealyun.oss-cn-beijing.aliyuncs.com/free/kube1.15.0.tar.gz

https://sealyun.oss-cn-beijing.aliyuncs.com/cf6bece970f6dab3d8dc8bc5b588cc18-1.16.0/kube1.16.0.tar.gz

https://sealyun.oss-cn-beijing.aliyuncs.com/413bd3624b2fb9e466601594b4f72072-1.17.0/kube1.17.0.tar.gz

https://sealyun.oss-cn-beijing.aliyuncs.com/7b6af025d4884fdd5cd51a674994359c-1.18.0/kube1.18.0.tar.gz

https://sealyun.oss-cn-beijing.aliyuncs.com/3806559ce0593d046d418663873afe7d-1.18.1/kube1.18.1.tar.gz

https://sealyun.oss-cn-beijing.aliyuncs.com/9a8299ea8016abe32e1564a44d5162e4-1.18.2/kube1.18.2.tar.gz

因为后面要安装kubesphere,对版本有特定的要求(3.0之前)

1
sealos init --passwd 123456 --master 192.168.171.129 --node 192.168.171.130 --pkg-url /home/kube1.17.0.tar.gz --version v1.17.0

安装完成后检查安装情况

1
kubectl get pods -A

kubesphere安装

https://kubesphere.io/zh/

https://kubesphere.io/docs/zh-CN/installation/install-on-k8s/

kubesphere安装前提条件

https://kubesphere.io/docs/zh-CN/installation/prerequisites/

sealogs安装没有helm,所以需要安装helm

https://devopscube.com/install-configure-helm-kubernetes/

helm2安装(kubesphere3之前只支持2.10.0 ≤ Helm Version < 3.0.0)

1
2
3
4
curl -L https://git.io/get_helm.sh | bash
chmod 700 get_helm.sh
./get_helm.sh
helm version

如果网络不好离线安装

1
2
3
4
wget https://get.helm.sh/helm-v2.16.9-linux-amd64.tar.gz
tar zxvf helm-v2.16.9-linux-amd64.tar.gz
cd /home/linux-amd64
mv helm /usr/local/bin

创建权限及账号

helm-rbac.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
1
kubectl apply -f helm-rbac.yaml

在K8S Master上创建Helm的ServiceAccount,即sa,并设定RBAC

1
2
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller

安装Tiller

1
2
docker pull dotbalo/tiller:v2.11.0
helm init --service-account tiller --tiller-image dotbalo/tiller:v2.11.0 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts --history-max 300
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Creating /root/.helm 
Creating /root/.helm/repository
Creating /root/.helm/repository/cache
Creating /root/.helm/repository/local
Creating /root/.helm/plugins
Creating /root/.helm/starters
Creating /root/.helm/cache/archive
Creating /root/.helm/repository/repositories.yaml
Adding stable repo with URL: https://kubernetes-charts.storage.googleapis.com
Adding local repo with URL: http://127.0.0.1:8879/charts
$HELM_HOME has been configured at /root/.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation
Happy Helming!

查看确认

1
2
3
helm version
Client: &version.Version{SemVer:"v2.11.0", GitCommit:"2e55dbe1fdb5fdb96b75ff144a339489417b146b", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.11.0", GitCommit:"2e55dbe1fdb5fdb96b75ff144a339489417b146b", GitTreeState:"clean"}

查看kubernetest 集群中的tiller pod:

1
2
kubectl get pod -n kube-system | grep tiller
tiller-deploy-765dcb8745-fj52j 1/1 Running 0 4h23m

最小化安装 KubeSphere

若集群可用 CPU > 1 Core 且可用内存 > 2 G,可以使用以下命令最小化安装 KubeSphere:

1
kubectl apply -f https://raw.githubusercontent.com/kubesphere/ks-installer/master/kubesphere-minimal.yaml

验证与访问

  1. 查看滚动刷新的安装日志,请耐心等待安装成功。
1
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

说明:安装过程中若遇到问题,也可以通过以上日志命令来排查问题。

  1. 通过 kubectl get pod --all-namespaces查看 KubeSphere 相关 namespace 下所有 Pod 状态是否为 Running。确认 Pod 都正常运行后,可使用 IP:30880访问 KubeSphere UI 界面,默认的集群管理员账号为 admin/P@88w0rd

参考

https://juejin.im/post/5d89a2e3518825090d61c39e

helm2安装参考

https://blog.csdn.net/arnolan/article/details/105304711

https://devopscube.com/install-configure-helm-kubernetes/

-------------本文结束-------------
0%