在 Linux 上安装 Kubernetes 和 KubeSphere,安装过程中将用到开源工具 KubeKey,有关 KubeKey 的更多信息,请访问 GitHub KubeKey 仓库
准备3台最低配置为4核16G的Linux服务器 ( 本文使用 CentOS 7.9 ),
确保所有服务器属于同一子网、关闭所有服务器防火墙
本文三台服务器IP地址:192.168.80.201、192.168.80.202、192.168.80.203
sudo systemctl stop firewalld
sudo systemctl disable firewalld
确保所有服务器时间同步:参考 CentOS7.9使用chrony同步时间
需要为所有集群节点安装 socat、conntrack、ebtables 和 ipset
yum install socat conntrack ebtables ipset -y
参数说明:-y 自动确认无需手动确认安装或卸载过程
参考:https://cloud.tencent.com/developer/article/2475828
登录任意集群节点,本文登录的是:192.168.80.201 节点机器,执行下面的命令,注意使用KubeKey创建 Kubernetes 集群,只需在一台节点执行下列操作。
export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | sh -
sudo chmod +x kk
查看三台机器的主机名:本文是 kube-01、kube-02、kube-03,分别对应IP 192.168.80.201、192.168.80.202、192.168.80.203
# 查看主机名
uname -n
创建安装配置文件 config-sample.yaml
./kk create config --with-kubernetes v1.28.12
KubeSphere 默认支持 Kubernetes v1.21~1.28, 此处安装最新版本:v1.28.12 ,命令执行完毕后将生成安装配置文件 config-sample.yaml
vi config-sample.yaml
编辑hosts,本文用户名使用root,密码是 123qwe,设置kube-01作为etcd和控制节点,kube-02、kube-03作为工作节点。设置:containerManager 为 docker 。
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
name: sample
spec:
hosts:
- {name: kube-01, address: 192.168.80.201, internalAddress: 192.168.80.201, user: root, password: "123qwe"}
- {name: kube-02, address: 192.168.80.202, internalAddress: 192.168.80.202, user: root, password: "123qwe"}
- {name: kube-03, address: 192.168.80.203, internalAddress: 192.168.80.203, user: root, password: "123qwe"}
roleGroups:
etcd:
- kube-01
control-plane:
- kube-01
worker:
- kube-02
- kube-03
controlPlaneEndpoint:
## Internal loadbalancer for apiservers
# internalLoadbalancer: haproxy
domain: lb.kubesphere.local
address: ""
port: 6443
kubernetes:
version: v1.28
clusterName: cluster.local
autoRenewCerts: true
containerManager: docker
etcd:
type: kubekey
network:
plugin: calico
kubePodsCIDR: 10.233.64.0/18
kubeServiceCIDR: 10.233.0.0/18
## multus support. https://github.com/k8snetworkplumbingwg/multus-cni
multusCNI:
enabled: false
registry:
privateRegistry: ""
namespaceOverride: ""
registryMirrors: []
insecureRegistries: []
addons: []
./kk create cluster -f config-sample.yaml
如果显示如下信息,则表明 Kubernetes 集群创建成功
Pipeline[CreateclusterPipeline] execute successfully
KubeSphere Core (ks-core) 是 KubeSphere 的核心组件,为扩展组件提供基础的运行环境。KubeSphere Core 安装完成后,即可访问 KubeSphere Web 控制台。
在集群任意控制节点执行以下命令:
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm upgrade --install -n kubesphere-system --create-namespace ks-core https://charts.kubesphere.io/main/ks-core-1.1.3.tgz --debug --wait --set global.imageRegistry=swr.cn-southwest-2.myhuaweicloud.com/ks
如果显示如下信息,则表明 ks-core 安装成功
NOTES:
Thank you for choosing KubeSphere Helm Chart.
Please be patient and wait for several seconds for the KubeSphere deployment to complete.
1. Wait for Deployment Completion
Confirm that all KubeSphere components are running by executing the following command:
kubectl get pods -n kubesphere-system
2. Access the KubeSphere Console
Once the deployment is complete, you can access the KubeSphere console using the following URL:
http://192.168.80.201:30880
3. Login to KubeSphere Console
Use the following credentials to log in:
Account: admin
Password: P@88w0rd
NOTE: It is highly recommended to change the default password immediately after the first login.
For additional information and details, please visit https://kubesphere.io.
从成功信息中的 Console、Account 和 Password 参数分别获取 KubeSphere Web 控制台的 IP 地址、管理员用户名和管理员密码,并使用网页浏览器登录 KubeSphere Web 控制台
参考文档:
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。