文章目錄
主要功能
- 安裝 Kubernetes 集群
- 支持在任何基礎設施上部署 Kubernetes,提供在線與離線安裝,支持添加 GPU 節點
- Kubernetes 資源管理
- 提供 Web 控制台對接 Kubernetes 原生 API 快速創建與管理 Kubernetes 資源,內置多維度的可觀測性
- 多租戶管理
- 提供統一的認證鑒權與細粒度的基於角色的授權系統,支持對接 AD/LDAP
硬件要求
- 官方建議
- all-in-one(基於Linux系統,部署Kubernetes集群以及KubeSphere平台)
- 最小化:2C4G
- 開啟全部組件:8C16G
- 基於Kubernetes集群
- 最小化1C2G(kubernetes集群,master節點是需要2C2G的配置要求,node節點是可以1C2G的)
- all-in-one(基於Linux系統,部署Kubernetes集群以及KubeSphere平台)
插件性能需求
https://kubesphere.io/zh/docs/pluggable-components/overview/
Kubernetes版本要求
安裝 KubeSphere v3.1.0 的建議 Kubernetes 版本:v1.17.9,v1.18.8,v1.19.8 以及 v1.20.4。
如果不指定 Kubernetes 版本,KubeKey 將默認安裝 Kubernetes v1.19.8
| KubeSphere 版本 | 受支持的 Kubernetes 版本 |
|---|---|
| v3.1.0 | v1.17.0,v1.17.4,v1.17.5,v1.17.6,v1.17.7,v1.17.8,v1.17.9,v1.18.3,v1.18.5,v1.18.6,v1.18.8,v1.19.0,v1.19.8,v1.19.9,v1.20.4 |
所以,如果想在現有的Kubernetes集群上部署KubeSphere,Kubernetes的版本不能低於1.17.0
| IP | 配置 | 系統版本 |
|---|---|---|
| 192.168.72.77 | 3C5G | CentOS 7.6 |
| 192.168.72.78 | 3C5G | CentOS 7.6 |
| 192.168.72.79 | 3C5G | CentOS 7.6 |
如果不是外網服務器,firewalld服務可以直接關掉,需要關閉selinux服務,重啟后才會生效
selinux的關閉方式:
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
# systemctl status firewalld.service | grep active
Active: inactive (dead)
# sestatus
SELinux status: disabled
配置主機之間的免密
# ssh-keygen
# ssh-copy-id 192.168.72.78
# ssh-copy-id 192.168.72.79
安裝所需依賴
- Kubernetes 版本 < 1.18
- 官方建議都安裝以下依賴
- Kubernetes 版本 ≥ 1.18
- socat 和 conntrack 是必須安裝的依賴
- ebtables 和 ipset 是建議安裝的
- 小孩子才做選擇,我全都要
- 三個節點都需要安裝依賴
# yum install -y socat conntrack ebtables ipset
下載KubeKey
- Github下載是真的難頂(還好我有一個香港的服務,才下載下來這個KubeKey)
- 我已經上傳到百度雲網盤了,只有14MB
- 鏈接:https://pan.baidu.com/s/1_f6WFgZZ6OwQ5GDo7lmvwg
提取碼:yfui - 如果連接Github不方便,並且想要使用kk命令來部署Kubernetes集群,建議使用命令
export KKZONE=cn,這樣,拉取的鏡像都會是國內的鏡像站,拉取速度會快很多很多
# export KKZONE=cn
# curl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.0 sh -
# chmod +x kk
創建Kubernetes集群以及KubeSphere
kk命令使用方式
創建一個配置文件模板,執行后,會在當前目錄生成一個
config-sample.yaml文件修改
config-sample.yaml文件,可以創建多節點Kubernetes集群,並且開啟自定義插件
開啟自定義插件,可以參考官方文檔:啟用可插拔組件
可以先部署最小化的機器,然后在web頁面開啟自定義的插件
# ./kk create config
apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
name: sample
spec:
hosts:
- {name: node1, address: 172.16.0.2, internalAddress: 172.16.0.2, user: ubuntu, password: Qcloud@123}
- {name: node2, address: 172.16.0.3, internalAddress: 172.16.0.3, user: ubuntu, password: Qcloud@123}
roleGroups:
etcd:
- node1
master:
- node1
worker:
- node1
- node2
controlPlaneEndpoint:
domain: lb.kubesphere.local
address: ""
port: 6443
kubernetes:
version: v1.19.8
imageRepo: kubesphere
clusterName: cluster.local
network:
plugin: calico
kubePodsCIDR: 10.233.64.0/18
kubeServiceCIDR: 10.233.0.0/18
registry:
registryMirrors: []
insecureRegistries: []
addons: []
創建集群
# ./kk create cluster -h
-f, --filename string Path to a configuration file
--with-kubernetes string Specify a supported version of kubernetes (default "v1.19.8")
--with-kubesphere Deploy a specific version of kubesphere (default v3.1.0)
只取了幾條參數,其他的,可以自己查看
-f, --filename:指定配置文件進行部署--with-kubernetes:指定部署的kubernetes版本,不指定版本,默認安裝1.19.8版本--with-kubesphere:指定部署的kubesphere版本,不指定版本,默認安裝3.1.0版本如果執行
./kk create cluster --with-kubesphere則會安裝默認的Kubernetes集群和KubeSphere服務
修改配置文件
apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
name: sample
spec:
hosts:
- {name: k8s-node1, address: 192.168.72.77, internalAddress: 192.168.72.77, user: root, password: 123.com}
- {name: k8s-node2, address: 192.168.72.78, internalAddress: 192.168.72.78, user: root, password: 123.com}
- {name: k8s-node3, address: 192.168.72.79, internalAddress: 192.168.72.79, user: root, password: 123.com}
roleGroups:
etcd:
- k8s-node1
master:
- k8s-node1
worker:
- k8s-node1
- k8s-node2
- k8s-node3
controlPlaneEndpoint:
domain: lb.kubesphere.local
#address: "192.168.72.77"
address: ""
port: 6443
kubernetes:
version: v1.20.4
imageRepo: kubesphere
clusterName: cluster.local
network:
plugin: calico
kubePodsCIDR: 10.233.64.0/18
kubeServiceCIDR: 10.233.0.0/18
registry:
registryMirrors: []
insecureRegistries: []
addons: []
k8s-node1自行設定,設定后,這個將會變成主機名
開始部署
# ./kk create cluster --with-kubernetes v1.20.4 --with-kubesphere v3.1.0 -f config-sample.yaml -y
| name | sudo | curl | openssl | ebtables | socat | ipset | conntrack | docker | nfs client | ceph client | glusterfs client | time |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| localhost.localdomain.cluster.local | y | y | y | y | y | y | y | CST 23:44:43 |
以上是KubeSphere依賴的服務,如果在現有的Kubernetes集群上部署KubeSphere,需要有一個持久化(nfs、ceph、glusterfs三個選一個)
kk命令是以Kubeadm的形式安裝的Kubernetes集群
如果是內網服務器,要先把所需的鏡像都下載好,還需要提前安裝好docker,然后加上
--skip-pull-images參數,就不會去網絡上拉取鏡像了使用KubeKey部署Kubernetes集群,需要用到如下鏡像,版本自己根據實際所需去修改:
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-proxy:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-apiserver:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controller-manager:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-scheduler:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/node:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/pod2daemon-flexvol:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/cni:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controllers:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/etcd:v3.4.13
registry.cn-beijing.aliyuncs.com/kubesphereio/k8s-dns-node-cache:1.15.12
registry.cn-beijing.aliyuncs.com/kubesphereio/coredns:1.6.9
registry.cn-beijing.aliyuncs.com/kubesphereio/pause:3.2
關於一些會出現的報錯,以及解決方法
如果一直有報錯:The connection to the server localhost:8080 was refused - did you specify the right host or port?: Process exited with status 1
可以嘗試下面的命令,清除集群,重新創建集群
# ./kk delete cluster -f config-sample.yaml
如果鏡像已經下載好了才報錯的,清除集群后,再次創建集群即可
# ./kk create cluster --with-kubernetes v1.20.4 --with-kubesphere v3.1.0 -f config-sample.yaml -y
如果看到這個報錯,就看一下,是不是報錯的節點,缺少依賴
Failed to join node: interrupted by error
到所有節點,再次執行下面的這個命令,確保返回
Nothing to do
# yum install -y socat conntrack ebtables ipset
集群驗證
看到這個,表示Kubernetes集群已經部署完成了,這里在部署KubeSphere,需要等待一會,時間會稍微有點久
Please wait for the installation to complete: >>--->
看到這個,表示KubeSphere以及部署完成了
訪問:http://192.168.72.77:30880
用戶名:admin
密碼:P@88w0rd
第一次登錄,會提示修改密碼
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Console: http://192.168.72.77:30880
Account: admin
Password: P@88w0rd
NOTES:
1. After you log into the console, please check the
monitoring status of service components in
"Cluster Management". If any service is not
ready, please wait patiently until all components
are up and running.
2. Please change the default password after login.
#####################################################
https://kubesphere.io 2021-05-09 22:23:47
#####################################################




KubeSphere還支持各種告警

到這里,完成了一個最小化的KubeSphere的部署
