参考 : https://blog.csdn.net/weixin_43810267/article/details/133347736
1、下载kubesphere的yaml
wget https://github.com/kubesphere/ks-installer/releases/download/v3.4.0/kubesphere-installer.yaml wget https://github.com/kubesphere/ks-installer/releases/download/v3.4.0/kubesphere-installer.yaml
2、查看k8s集群有没有sc,分以下2种情况
情况一、没有sc则需要创建sc和2个pv
- 创建sc
#创建存储类,先创建一个local-storage-class.yaml,然后写入一下内容 apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: local-storage provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer #创建StorageClass资源 kubectl apply -f local-storage-class.yaml #查看StorageClass kubectl get sc
- 创建pv
vim my-pv.yml --- apiVersion: v1 kind: PersistentVolume metadata: name: pv1 spec: capacity: storage: 20Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle storageClassName: local-storage nfs: path: /data/nfs/data3G server: 192.168.18.12 --- apiVersion: v1 kind: PersistentVolume metadata: name: pv2 spec: capacity: storage: 20Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle storageClassName: local-storage nfs: path: /data/nfs/data3G server: 192.168.18.12
#创建pv资源 kubectl apply -f my-pv.yaml #查看pv kubectl get pv
情况二、没有sc则需要创建nfs动态存储,https://www.cnblogs.com/lfxx/p/18069622
创建完sc后需要修改成默认的sc
kubectl patch storageclass local-storage -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
3、安装kubeshepe
kubectl apply -f kubesphere-installer.yaml kubectl apply -f cluster-configuration.yaml
多次删除kubesphere后会报错Internal error occurred: failed calling webhook \"users.iam.kubesphere.io\": failed to call webhook:
解决方法运行kubectl delete validatingwebhookconfigurations `kubectl get validatingwebhookconfigurations|awk '{print $1}'`
4、查看kubesphere有没有安装成功
kubectl logs ks-installer-58f7c6477b-gdjhw -n kubesphere-system
看到登录地址说明安装成功
问题1:运行kubectl get pod -A查看pod发现有2个node的pod异常,这是因为我的集群是1主2从,2个从节点已经安装了node但还有4个node的pod还没分配到其他节点,剩下的4个pod分配到从节点会发生端口已经被占用
标签:kubectl,pv,sc,kubesphere,storage,yaml,1.23,k8s From: https://www.cnblogs.com/lfxx/p/18635227