Kubernetes(K8S) kubesphere 安装

# 检查 K8S 版本,低版本需要升级
[root@k8smaster kubesphere]# kubectl version

image

安装

[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 

image

如果出现下面错误,需要安装 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
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wsnbb_2023

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值