凯发k8天生赢家一触即发

kubernetes(k8s) kubesphere 安装 -凯发k8天生赢家一触即发

2023-10-20,,

安装kubesphere最好的方法就是参考官方文档,而且官方文档是中文的。

凯发k8天生赢家一触即发官网地址:https://kubesphere.com.cn/

https://github.com/kubesphere/kubesphere/blob/master/readme_zh.md

() 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

kubernetes(k8s) kubesphere 安装的相关教程结束。

网站地图