一、安装前环境准备
# kubesphere官网:https://kubesphere.io/zh/docs/v3.4/introduction/what-is-kubesphere/
# 1.kubenetes版本查看
[root@master kubesphere]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready control-plane 106m v1.26.0
node1 Ready work 103m v1.26.0
# 2.kubesphere安装前环境准备
# https://kubesphere.io/zh/docs/v3.4/installing-on-kubernetes/introduction/prerequisites/
Centos 7.9
cpu内存:4核8G
硬盘:50G
依赖项:yum install -y socat、conntrack、ebtables、ipset
# 2.集群中创建默认StorageClass
# 默认没有,可以自建
创建 StorageClass
设置默认 StorageClass
# 创建storageclass最后
[root@master kubesphere]# cat sc.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
# 设置为默认StorageClass
ubectl patch storageclass local-storage -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
# 执行查看
[root@master kubesphere]# kubectl get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
local-storage (default) kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 54m
PS:上面创建的storageclass 确实可以成功安装kubesphere,但是local-storage配合pvc无法动态创建pv。因此,创建storageclass 也可以使用nfs-storageclass
二、安装kubesphere
# 1.如果配置要求达到8核16G,可以把插件都启用安装上,没有的话就最小化安装
# 执行命令安装
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
# 2.检查安装日志,上面命令执行完成后,等待10分钟左右可以看到
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 ...
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Console: http://192.168.10.20:30880
Account: admin
Password: P@88w0rd
NOTES:
1. After you log into the console, please check the
monitoring status of service components in
"Cluster Management". If any service is not
ready, please wait patiently until all components
are up and running.
2. Please change the default password after login.
#####################################################
https://kubesphere.io 2024-04-17 18:06:26
#####################################################
# 3.使用 kubectl get pod --all-namespaces 查看所有 Pod 在 KubeSphere 相关的命名空间是否正常运行。如果是正常运行,请通过以下命令来检查控制台的端口(默认为 30880):
[root@master kubesphere]# kubectl get pod --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-6d6dc86d84-dfdsv 1/1 Running 0 127m
kube-system calico-node-r6zrj 1/1 Running 0 127m
kube-system calico-node-xh8dv 1/1 Running 1 (125m ago) 127m
kube-system calico-typha-57cbf5b54d-4zc9r 1/1 Running 0 127m
kube-system coredns-567c556887-j9jfb 1/1 Running 0 133m
kube-system coredns-567c556887-mv57p 1/1 Running 0 133m
kube-system etcd-master 1/1 Running 0 133m
kube-system kube-apiserver-master 1/1 Running 0 133m
kube-system kube-controller-manager-master 1/1 Running 0 133m
kube-system kube-proxy-4lrj6 1/1 Running 0 133m
kube-system kube-proxy-pdwzp 1/1 Running 0 130m
kube-system kube-scheduler-master 1/1 Running 0 133m
kube-system snapshot-controller-0 1/1 Running 0 42m
kubesphere-controls-system default-http-backend-864f4f5c6b-s6s92 1/1 Running 1 (40m ago) 41m
kubesphere-controls-system kubectl-admin-c6988866d-ghstw 1/1 Running 0 34m
kubesphere-monitoring-system alertmanager-main-0 2/2 Running 0 38m
kubesphere-monitoring-system kube-state-metrics-5f77fc8f6d-7pvbz 3/3 Running 0 38m
kubesphere-monitoring-system node-exporter-7nwsc 2/2 Running 0 38m
kubesphere-monitoring-system node-exporter-kf5cj 2/2 Running 0 38m
kubesphere-monitoring-system notification-manager-deployment-f86fdf45d-m5gj9 2/2 Running 0 37m
kubesphere-monitoring-system notification-manager-operator-7b8dcfd75c-bpm6c 2/2 Running 0 37m
kubesphere-monitoring-system prometheus-k8s-0 0/2 Pending 0 38m
kubesphere-monitoring-system prometheus-operator-845b8fb9df-nxhpd 2/2 Running 0 38m
kubesphere-system ks-apiserver-756b474857-47jjd 1/1 Running 0 41m
kubesphere-system ks-console-876f69ff4-47rgn 1/1 Running 0 41m
kubesphere-system ks-controller-manager-64d7d5dc77-95ln2 1/1 Running 0 41m
kubesphere-system ks-installer-7fc5675448-8wphm 1/1 Running 0 43m
[root@master kubesphere]# kubectl get svc/ks-console -n kubesphere-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ks-console NodePort 10.96.165.196 <none> 80:30880/TCP 43m
4.确保在安全组中打开了 30880 端口,通过 NodePort (IP:30880) 使用默认帐户和密码 (admin/P@88w0rd) 访问 Web 控制台
http://192.168.10.20:30880/login
![]()
![]()
三、启动插件
# 插件占用资源
https://kubesphere.io/zh/docs/v3.4/pluggable-components/overview/
# 启动日志插件
[root@master kubesphere]# vim cluster-configuration.yaml
logging:
enabled: true # false改true
[root@master kubesphere]# kubectl apply -f cluster-configuration.yaml
clusterconfiguration.installer.kubesphere.io/ks-installer configured
[root@master kubesphere]# kubectl get pods --all-namespaces | grep log
kubesphere-logging-system fluent-bit-77s4z 0/1 ContainerCreating 0 31s
kubesphere-logging-system fluent-bit-b5zlk 0/1 ContainerCreating 0 31s
kubesphere-logging-system fluentbit-operator-67898f4dd8-lxnd5 1/1 Running 0 2m14s
kubesphere-logging-system opensearch-cluster-data-0 0/1 Pending 0 2m31s
kubesphere-logging-system opensearch-cluster-data-1 0/1 Pending 0 2m30s
kubesphere-logging-system opensearch-cluster-master-0 0/1 Pending 0 2m32s