快速搭建 k8s 集群
一、集群规划
1、节点规划
搭建3台服务器,1台master,2台worker,分别为:
系统类型 | IP地址 | 节点角色 | CPU | Memory | 硬盘 | Hostname |
---|---|---|---|---|---|---|
CentOS7.9 | 192.168.1.189 | master | 2C | 4G | 40G | k8s-master |
CentOS7.9 | 192.168.1.190 | master | 2C | 4G | 40G | k8s-node1 |
CentOS7.9 | 192.168.1.191 | worker | 2C | 3G | 40G | k8s-node2 |
说明:CPU必须为 2C+,master 内存必须为 4G+,否则安装kubesphere会报错,容器起不来。
设置hostname
[root@localhost ~]# hostnamectl set-hostname k8s-master
[root@localhost ~]# cat /etc/hostname
k8s-master
2、集群规划
集群搭建规划,这里采用kubesphere kubekey 来进行安装,该方案安装简便快捷,详细安装步骤,请看官方文档:使用 KubeKey 内置 HAproxy 创建高可用集群(v3.3)
确定好kubekey、kubesphere、k8s版本后,其他组件包括(docker、helm) 会自动下载安装:
- kubekey 2.1.0
- kubesphere 3.1.1
- k8s 1.19.9
- Docker 20.10.8
- helm v3.6.3
3、搭建
详细搭建步骤请看这篇文章:手把手从零搭建 k8s 集群系列(二)kubekey 搭建高可用集群
4、后台页面
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Console: http://192.168.1.189: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 2022-10-13 05:51:24
#####################################################
05:51:26 CST success: [k8s-master]
05:51:26 CST Pipeline[CreateClusterPipeline] execute successful
Installation is complete.
Please check the result using the command:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
[root@k8s-master softwares]#
查看节点信息:
[root@k8s-master softwares]# kubeclt get nodes
-bash: kubeclt: command not found
[root@k8s-master softwares]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready master 8m25s v1.19.9
k8s-node1 Ready worker 7m48s v1.19.9
k8s-node2 Ready worker 7m48s v1.19.9
[root@k8s-master softwares]# kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-kube-controllers-7fc49b8c4-9mpzk 1/1 Running 0 7m53s
kube-system calico-node-bjqjd 1/1 Running 0 7m53s
kube-system calico-node-ddmqr 1/1 Running 0 7m53s
kube-system calico-node-mjbnh 1/1 Running 0 7m53s
kube-system coredns-86cfc99d74-25lrp 1/1 Running 0 8m7s
kube-system coredns-86cfc99d74-pn886 1/1 Running 0 8m7s
kube-system kube-apiserver-k8s-master 1/1 Running 0 8m25s
kube-system kube-controller-manager-k8s-master 1/1 Running 0 8m25s
kube-system kube-proxy-9cpw7 1/1 Running 0 8m7s
kube-system kube-proxy-fmzdl 1/1 Running 0 7m56s
kube-system kube-proxy-l842v 1/1 Running 0 7m56s
kube-system kube-scheduler-k8s-master 1/1 Running 0 8m25s
kube-system nodelocaldns-fqv7v 1/1 Running 0 7m56s
kube-system nodelocaldns-gj557 1/1 Running 0 7m56s
kube-system nodelocaldns-z5j6r 1/1 Running 0 8m7s
kube-system openebs-localpv-provisioner-64fb84d4cc-qlml7 1/1 Running 0 7m52s
kube-system snapshot-controller-0 1/1 Running 0 5m57s
kubesphere-controls-system default-http-backend-76d9fb4bb7-pwt9d 1/1 Running 0 4m37s
kubesphere-controls-system kubectl-admin-69b8ff6d54-dknrx 1/1 Running 0 2m30s
kubesphere-devops-system ks-jenkins-65db765f86-5m59m 1/1 Running 0 3m54s
kubesphere-devops-system s2ioperator-0 1/1 Running 0 4m9s
kubesphere-monitoring-system alertmanager-main-0 2/2 Running 0 3m19s
kubesphere-monitoring-system alertmanager-main-1 2/2 Running 0 3m18s
kubesphere-monitoring-system alertmanager-main-2 2/2 Running 0 3m17s
kubesphere-monitoring-system kube-state-metrics-67588479db-96h8c 3/3 Running 0 3m29s
kubesphere-monitoring-system node-exporter-2pm6w 2/2 Running 0 3m28s
kubesphere-monitoring-system node-exporter-jbx47 2/2 Running 0 3m29s
kubesphere-monitoring-system node-exporter-wgkw5 2/2 Running 0 3m28s
kubesphere-monitoring-system notification-manager-deployment-7bd887ffb4-6hs4j 1/1 Running 0 95s
kubesphere-monitoring-system notification-manager-deployment-7bd887ffb4-gf5kf 1/1 Running 0 95s
kubesphere-monitoring-system notification-manager-operator-78595d8666-mr8w5 2/2 Running 0 3m13s
kubesphere-monitoring-system prometheus-k8s-0 3/3 Running 1 3m18s
kubesphere-monitoring-system prometheus-k8s-1 3/3 Running 1 3m17s
kubesphere-monitoring-system prometheus-operator-d7fdfccbf-pfjdm 2/2 Running 0 3m30s
kubesphere-system ks-apiserver-58fd6d5595-rq8sc 1/1 Running 0 2m52s
kubesphere-system ks-console-6d6d765964-lw7kf 1/1 Running 0 4m24s
kubesphere-system ks-controller-manager-c5d7b658b-p5njs 1/1 Running 0 2m52s
kubesphere-system ks-installer-66dd9c68cf-hdsd6 1/1 Running 0 7m52s
kubesphere-system minio-f69748945-bs28h 1/1 Running 0 5m33s
kubesphere-system openldap-0 1/1 Running 1 5m45s
[root@k8s-master softwares]#
为者常成,行者常至
自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)