KuberSphere 安装kubernates

准备机器

最少3台机器

centos Linux 内核:官方建议 3.10 以上

bash 复制代码
uname -r

control 一台 配置 2c 4g

worker 二台 配置 2c 4g

3台设备需要用不同的hostname,需要提前修改

bash 复制代码
hostnamectl set-hostname <新的主机名>
# 修改后执行一下命令刷新一下
su -

安装KubeSphere

依赖要求

KubeKey 可以将 Kubernetes 和 KubeSphere 一同安装。针对不同的 Kubernetes 版本,需要安装的依赖项可能有所不同。您可以参考以下列表,查看是否需要提前在节点上安装相关的依赖项

如果没有安装 socat和conntrack可以执行以下命令安装, 记住每台机器都要安装必要依赖

bash 复制代码
yum install -y socat conntrack ebtables ipset

从 GitHub Release Page 下载 KubeKey

bash 复制代码
# 如果访问githu受限可以执行以下命令
# export KKZONE=cn
# 然后在下载KubeKey

curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.13 sh -

为 kk 添加可执行权限

bash 复制代码
chmod +x kk

同时安装KubeSphere UI和Kubernates

bash 复制代码
./kk create cluster --with-kubernetes v1.22.12 --with-kubesphere v3.4.1

验证安装结果

bash 复制代码
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

输出信息会显示 Web 控制台的 IP 地址和端口号,默认的 NodePort 是 30880。现在,您可以使用默认的帐户和密码

(admin/P@88w0rd) 通过 :30880 访问控制台

bash 复制代码
#####################################################

###              Welcome to KubeSphere!           ###

#####################################################

Console: http://192.168.0.2: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             20xx-xx-xx xx:xx:xx
#####################################################

安装完成后界面如下:

添加工作(Worker)节点

1. 使用 KubeKey 检索集群信息。以下命令会创建配置文件 (sample.yaml)。
bash 复制代码
./kk create config --from-cluster

执行后文件生产路径会打印出来

2. 在配置文件中,将新节点的信息放在 hosts 和 roleGroups 之下。该示例添加了两个新节点(即 node1 和 node2)。其中 control 是文件中默认的记录和节点。打开sample.yaml文件如下:
bash 复制代码
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  ##You should complete the ssh information of the hosts
  - {name: control, address: 192.168.1.52, internalAddress: 192.168.1.52}
  ## 添加2个工作节点
  - {name: worker1, address: 192.168.1.25, internalAddress: 192.168.1.25, user: root, password: Ijc123;;'' }
  - {name: worker2, address: 192.168.1.98, internalAddress: 192.168.1.98, user: root, password: Ijc123;;'' }

  roleGroups:
    etcd:
    ## 将control设置为etcd,没有高可用
    - control
    master:
    ## 设置master
    - control
    ## 设置worker1和worker2为工作节点
    worker:
    - worker1
    - worker2
  controlPlaneEndpoint:
    ##Internal loadbalancer for apiservers
    #internalLoadbalancer: haproxy

    ##If the external loadbalancer was used, 'address' should be set to loadbalancer's ip.
    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.22.12
    clusterName: cluster.local
    proxyMode: ipvs
    masqueradeAll: false
    maxPods: 110
    nodeCidrMaskSize: 24
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
  registry:
    privateRegistry: ""
3. 执行以下命令
bash 复制代码
./kk add nodes -f /root/sample.yaml
4. 安装完成后,您将能够在 KubeSphere 的控制台上查看新节点及其信息。在集群管理页面,选择左侧菜单节点下的集群节点,或者执行命令 kubectl get node 以检查更改。
bash 复制代码
$ kubectl get node
NAME          STATUS   ROLES           AGE   VERSION
master1       Ready    master,worker   20d   v1.17.9
node1         Ready    worker          31h   v1.17.9
node2         Ready    worker          31h   v1.17.9

此时UI可看到新加入集群的node

进阶操作点击这里进入官网查看

相关推荐
liulanba14 小时前
八股取士--docker&k8s
docker·容器·kubernetes
桂月二二15 小时前
基于eBPF的云原生网络加速引擎:突破Kubernetes Service转发性能瓶颈
网络·云原生·kubernetes
格桑阿sir19 小时前
Kubernetes控制平面组件:Kubernetes如何使用etcd
kubernetes·k8s·etcd·高可用集群·故障分析·etcd集群调优
格桑阿sir19 小时前
Kubernetes控制平面组件:etcd常用配置参数
kubernetes·etcd·配置参数·etcd容量·磁盘耗尽·碎片整理·灾备与安全
Rocky00000019 小时前
【云原生】最新版Kubernetes集群基于Containerd部署
云原生·容器·kubernetes
全栈工程师修炼指南21 小时前
云原生 | Kubernetes 原生 Dashboard 已升级至 7.10.x 界面更简洁、功能更强大
云原生·容器·kubernetes
2301_793069821 天前
微服务架构,Spring Cloud、Kubernetes 以及云厂商(AWS、Azure)的管理方式
spring cloud·微服务·云原生·架构·kubernetes
慢一点会很快2 天前
K8s学习总结
学习·容器·kubernetes
周周的奇妙编程2 天前
红队视角出发的k8s敏感信息收集——日志与监控系统
云原生·容器·kubernetes
Karoku0662 天前
【k8s应用管理】kubernetes lngress资源管理
运维·docker·云原生·容器·kubernetes