千千梦丶琪 发表于 2023-4-27 16:56:09

Kubernetes(K8S) kubesphere 安装

安装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 版本,低版本需要升级
# kubectl versionhttps://img2023.cnblogs.com/blog/80824/202304/80824-20230423131939594-1280145899.png
安装

# cd /opt/k8s/kubesphere
# 创建文件storageclass.yaml
# vi storageclass.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

# persistentVolumeClaim.yaml
# vi persistentVolumeClaim.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: local-pve
spec:
accessModes:
   - ReadWriteOnce
resources:
    requests:
      storage: 20Gi
storageClassName: local-storage

# 下载核心文件(可以讯雷下载好传到 服务器)
# wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/kubesphere-installer.yaml
# wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/cluster-configuration.yaml
# 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

# 安装
# kubectl apply -f storageclass.yaml
storageclass.storage.k8s.io/local-storage created
# kubectl apply -f persistentVolumeClaim.yaml
persistentvolumeclaim/local-pve created

# 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

# kubectl apply -f cluster-configuration.yaml
clusterconfiguration.installer.kubesphere.io/ks-installer created

#解决找不到证书的问题
# 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 详情
# kubectl describe pod -n kubesphere-system
Events:
Type    Reason   Age   From               Message
----    ------   --------               -------
NormalScheduled12m   default-schedulerSuccessfully assigned kubesphere-system/ks-installer-7bd6b699df-9lnlc to k8snode1
NormalPulling    12m   kubelet            Pulling image "kubesphere/ks-installer:v3.1.1"
NormalPulled   11m   kubelet            Successfully pulled image "kubesphere/ks-installer:v3.1.1"
NormalCreated    11m   kubelet            Created container installer
NormalStarted    11m   kubelet            Started container installer
#

# 使用命令查看进度
# kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items.metadata.name}') -f https://img2023.cnblogs.com/blog/80824/202304/80824-20230423112500993-1183923526.png
如果出现下面错误,需要安装 storageclass、persistentVolumeClaim
TASK ***
fatal: : FAILED! => {
    "assertion": "\"(default)\" in default_storage_class_check.stdout",
    "changed": false,
    "evaluated_to": false,
    "msg": "Default StorageClass was not found !"
}# 删除
# kubectl delete -f kubesphere-installer.yaml
# kubectl delete -f cluster-configuration.yaml
# 安装完 storageclass后,重新安装
# kubectl apply -f storageclass.yaml
# kubectl apply -f persistentVolumeClaim.yaml
# kubectl apply -f kubesphere-installer.yaml
# kubectl apply -f cluster-configuration.yaml
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页: [1]
查看完整版本: Kubernetes(K8S) kubesphere 安装