安裝KubeSphere最好的方法就是參考官方文件,而且官方文件是中文的。
官網地址:https://kubesphere.com.cn/
https://github.com/kubesphere/kubesphere/blob/master/README_zh.md
Kubernetes(K8S) kubesphere 介紹
安裝提前條件:
使用 Kubeadm 部署 Kubernetes(K8S) 安裝--附K8S架構圖
使用 Kubeadm 部署 Kubernetes(K8S) 安裝 -- 持久化儲存(NFS網路儲存)
Kubernetes(K8S) 安裝 Metrics-Server
# 檢查 K8S 版本,低版本需要升級
[root@k8smaster kubesphere]# kubectl version
安裝
[root@k8smaster ~]# cd /opt/k8s/kubesphere
# 建立檔案storageclass.yaml
[root@k8smaster kubesphere]# vi storageclass.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
# persistentVolumeClaim.yaml
[root@k8smaster kubesphere]# vi persistentVolumeClaim.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-pve
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storageClassName: local-storage
# 下載核心檔案(可以訊雷下載好傳到 伺服器)
[root@k8smaster kubesphere]# wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/kubesphere-installer.yaml
[root@k8smaster kubesphere]# wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/cluster-configuration.yaml
[root@k8smaster kubesphere]# ll
總用量 12
-rwxrwxrwx 1 root root 7663 4月 23 09:41 cluster-configuration.yaml
-rwxrwxrwx 1 root root 4064 4月 23 09:41 kubesphere-installer.yaml
# 安裝
[root@k8smaster kubesphere]# kubectl apply -f storageclass.yaml
storageclass.storage.k8s.io/local-storage created
[root@k8smaster kubesphere]# kubectl apply -f persistentVolumeClaim.yaml
persistentvolumeclaim/local-pve created
[root@k8smaster kubesphere]# kubectl apply -f kubesphere-installer.yaml
customresourcedefinition.apiextensions.k8s.io/clusterconfigurations.installer.kubesphere.io created
namespace/kubesphere-system created
serviceaccount/ks-installer created
clusterrole.rbac.authorization.k8s.io/ks-installer created
clusterrolebinding.rbac.authorization.k8s.io/ks-installer created
deployment.apps/ks-installer created
[root@k8smaster kubesphere]# kubectl apply -f cluster-configuration.yaml
clusterconfiguration.installer.kubesphere.io/ks-installer created
#解決找不到證書的問題
[root@k8smaster kubesphere]# kubectl -n kubesphere-system create secret generic kube-etcd-client-certs --from-file=etcd-client-ca.crt=/etc/kubernetes/pki/etcd/ca.crt --from-file=etcd-client.crt=/etc/kubernetes/pki/apiserver-etcd-client.crt --from-file=etcd-client.key=/etc/kubernetes/pki/apiserver-etcd-client.key
secret/kube-etcd-client-certs created
# 檢視 POD 詳情
[root@k8smaster kubesphere]# kubectl describe pod -n kubesphere-system
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 12m default-scheduler Successfully assigned kubesphere-system/ks-installer-7bd6b699df-9lnlc to k8snode1
Normal Pulling 12m kubelet Pulling image "kubesphere/ks-installer:v3.1.1"
Normal Pulled 11m kubelet Successfully pulled image "kubesphere/ks-installer:v3.1.1"
Normal Created 11m kubelet Created container installer
Normal Started 11m kubelet Started container installer
[root@k8smaster kubesphere]#
# 使用命令檢視進度
[root@k8smaster kubesphere]# kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
如果出現下面錯誤,需要安裝 storageclass、persistentVolumeClaim
TASK [preinstall : KubeSphere | Stopping if default StorageClass was not found] ***
fatal: [localhost]: FAILED! => {
"assertion": "\"(default)\" in default_storage_class_check.stdout",
"changed": false,
"evaluated_to": false,
"msg": "Default StorageClass was not found !"
}
# 刪除
[root@k8smaster kubesphere]# kubectl delete -f kubesphere-installer.yaml
[root@k8smaster kubesphere]# kubectl delete -f cluster-configuration.yaml
# 安裝完 storageclass 後,重新安裝
[root@k8smaster kubesphere]# kubectl apply -f storageclass.yaml
[root@k8smaster kubesphere]# kubectl apply -f persistentVolumeClaim.yaml
[root@k8smaster kubesphere]# kubectl apply -f kubesphere-installer.yaml
[root@k8smaster kubesphere]# kubectl apply -f cluster-configuration.yaml