kubesphere 安装要求有默认storageclass
NFS部署
yum install -y nfs-utils # CentOS
apt install -y nfs-kernel-server # Ubuntu
mkdir -p /data/nfs
echo "/data/nfs *(rw,sync,no_subtree_check,no_root_squash)" >> /etc/exports
systemctl restart nfs-server
systemctl enable nfs-server
[root@nfs ~]# exportfs -rv
exporting *:/data/nfs
K8S Master/Client 节点NFS客户端
yum install -y nfs-utils # CentOS apt-get install -y nfs-common # Ubuntu
部署动态StoragesClass
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
--set nfs.server=192.168.77.11 \
--set nfs.path=/data/nfs/kubesphere \
--set image.repository=registry.sundayhk.com/k8s/sig-storage/nfs-subdir-external-provisioner \
-n nfs-provisioner \
--create-namespace
root@ks-master01:~# kubectl get storageclass -n nfs-provisioner
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
nfs-client cluster.local/nfs-subdir-external-provisioner Delete Immediate true 95s
root@ks-master01:~# kubectl get pod -n nfs-provisioner
NAME READY STATUS RESTARTS AGE
nfs-subdir-external-provisioner-768dc5f875-77z58 1/1 Running 0 77s
测试
# kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-claim.yaml
# test-claim.yaml
cat <<EOF | kubectl apply -f -
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-claim
spec:
storageClassName: nfs-client
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Mi
EOF
# kubectl create -f https://raw.githubusercontent.com/kubernetes-sigs/nfs-subdir-external-provisioner/master/deploy/test-pod.yaml
# test-pod
cat <<EOF | kubectl apply -f -
kind: Pod
apiVersion: v1
metadata:
name: test-pod
spec:
containers:
- name: test-pod
image: busybox:1.28
command:
- "/bin/sh"
args:
- "-c"
- "touch /mnt/SUCCESS && exit 0 || exit 1"
volumeMounts:
- name: nfs-pvc
mountPath: "/mnt"
restartPolicy: "Never"
volumes:
- name: nfs-pvc
persistentVolumeClaim:
claimName: test-claim
EOF
root@ks-master01:~# kubectl get pod test-pod
NAME READY STATUS RESTARTS AGE
test-pod 0/1 Completed 0 73s
root@ks-master01:~# kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
test-claim Bound pvc-3707b82e-cf26-479f-8d0c-84ad7e6bce19 1Mi RWX nfs-client 87s
NFS服务器查看
[root@nfs nfs]# ls -l /data/nfs/kubesphere/default-test-claim-pvc-3707b82e-cf26-479f-8d0c-84ad7e6bce19/SUCCESS
-rw-r--r--. 1 root root 0 Sep 26 01:17 /data/nfs/kubesphere/default-test-claim-pvc-3707b82e-cf26-479f-8d0c-84ad7e6bce19/SUCCESS
删除测试POD PVC
kubectl delete pod test-pod
kubectl delete pvc test-claim
设置为默认storageclass
kubectl patch storageclass nfs-client -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
Kubesphere部署
确保现有的 Kubernetes 集群满足所有要求之后,您可以使用 kubectl 以默认最小安装包来安装 KubeSphere。
- 执行以下命令以开始安装:
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/kubesphere-installer.yaml kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/cluster-configuration.yaml
- 检查安装日志:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
TASK [ks-core/prepare : KubeSphere | Generating kubeconfig-admin] **************
skipping: [localhost]
PLAY RECAP *********************************************************************
localhost : ok=30 changed=22 unreachable=0 failed=0 skipped=17 rescued=0 ignored=0
Start installing monitoring
Start installing multicluster
Start installing openpitrix
Start installing network
**************************************************
Waiting for all tasks to be completed ...
task network status is successful (1/4)
task openpitrix status is successful (2/4)
task multicluster status is successful (3/4)
task monitoring status is successful (4/4)
**************************************************
Collecting installation results ...
- 使用
kubectl get pod --all-namespaces
查看所有 Pod 在 KubeSphere 相关的命名空间是否正常运行。如果是正常运行,请通过以下命令来检查控制台的端口(默认为 30880):
kubectl get svc/ks-console -n kubesphere-system
root@ks-master01:~# kubectl get svc/ks-console -n kubesphere-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ks-console NodePort 10.233.15.88 <none> 80:30880/TCP 10m
- 确保在安全组中打开了 30880 端口,通过 NodePort (
IP:30880
) 使用默认帐户和密码 (admin/P@88w0rd
) 访问 Web 控制台。
https://kubesphere.io/zh/docs/v3.4/installing-on-kubernetes/introduction/overview/