Centos 7.6 使用 kubekey 部署 kubesphere v3.1.0
阅读原文时间:2022年02月20日阅读:1

文章目录

插件性能需求

https://kubesphere.io/zh/docs/pluggable-components/overview/

安装 KubeSphere v3.1.0 的建议 Kubernetes 版本:v1.17.9,v1.18.8,v1.19.8 以及 v1.20.4。

如果不指定 Kubernetes 版本,KubeKey 将默认安装 Kubernetes v1.19.8

KubeSphere 版本

受支持的 Kubernetes 版本

v3.1.0

v1.17.0,v1.17.4,v1.17.5,v1.17.6,v1.17.7,v1.17.8,v1.17.9,v1.18.3,v1.18.5,v1.18.6,v1.18.8,v1.19.0,v1.19.8,v1.19.9,v1.20.4

所以,如果想在现有的Kubernetes集群上部署KubeSphere,Kubernetes的版本不能低于1.17.0

IP

配置

系统版本

192.168.72.77

3C5G

CentOS 7.6

192.168.72.78

3C5G

CentOS 7.6

192.168.72.79

3C5G

CentOS 7.6

如果不是外网服务器,firewalld服务可以直接关掉,需要关闭selinux服务,重启后才会生效

selinux的关闭方式:sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
# systemctl status firewalld.service | grep active
   Active: inactive (dead)
# sestatus
SELinux status:                 disabled

配置主机之间的免密

# ssh-keygen
# ssh-copy-id 192.168.72.78
# ssh-copy-id 192.168.72.79

安装所需依赖

  • Kubernetes 版本 < 1.18

    • 官方建议都安装以下依赖
  • Kubernetes 版本 ≥ 1.18

    • socat 和 conntrack 是必须安装的依赖
    • ebtables 和 ipset 是建议安装的
  • 小孩子才做选择,我全都要

  • 三个节点都需要安装依赖

    yum install -y socat conntrack ebtables ipset

下载KubeKey

  • Github下载是真的难顶,除非你可以连接外网(还好我有一个香港的服务,才下载下来这个KubeKey)

  • 我已经上传到百度云网盘了,只有14MB

  • 链接:https://pan.baidu.com/s/1_f6WFgZZ6OwQ5GDo7lmvwg
    提取码:yfui

  • 如果连接Github不方便,并且想要使用kk命令来部署Kubernetes集群,建议使用命令export KKZONE=cn,这样,拉取的镜像都会是国内的镜像站,拉取速度会快很多很多

    export KKZONE=cn

    curl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.0 sh -

    chmod +x kk

kk命令使用方式

创建一个配置文件模板,执行后,会在当前目录生成一个config-sample.yaml文件

修改config-sample.yaml文件,可以创建多节点Kubernetes集群,并且开启自定义插件
开启自定义插件,可以参考官方文档:启用可插拔组件
可以先部署最小化的机器,然后在web页面开启自定义的插件

# ./kk create config


apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: node1, address: 172.16.0.2, internalAddress: 172.16.0.2, user: ubuntu, password: Qcloud@123}
  - {name: node2, address: 172.16.0.3, internalAddress: 172.16.0.3, user: ubuntu, password: Qcloud@123}
  roleGroups:
    etcd:
    - node1
    master:
    - node1
    worker:
    - node1
    - node2
  controlPlaneEndpoint:
    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.19.8
    imageRepo: kubesphere
    clusterName: cluster.local
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
  registry:
    registryMirrors: []
    insecureRegistries: []
  addons: []

创建集群

# ./kk create cluster -h
      -f, --filename string      Path to a configuration file
      --with-kubernetes string   Specify a supported version of kubernetes (default "v1.19.8")
      --with-kubesphere          Deploy a specific version of kubesphere (default v3.1.0)

只取了几条参数,其他的,可以自己查看

  • -f, --filename:指定配置文件进行部署
  • --with-kubernetes:指定部署的kubernetes版本,不指定版本,默认安装1.19.8版本
  • --with-kubesphere:指定部署的kubesphere版本,不指定版本,默认安装3.1.0版本

如果执行./kk create cluster --with-kubesphere 则会安装默认的Kubernetes集群和KubeSphere服务

修改配置文件

apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: k8s-node1, address: 192.168.72.77, internalAddress: 192.168.72.77, user: root, password: 123.com}
  - {name: k8s-node2, address: 192.168.72.78, internalAddress: 192.168.72.78, user: root, password: 123.com}
  - {name: k8s-node3, address: 192.168.72.79, internalAddress: 192.168.72.79, user: root, password: 123.com}
  roleGroups:
    etcd:
    - k8s-node1
    master:
    - k8s-node1
    worker:
    - k8s-node1
    - k8s-node2
    - k8s-node3
  controlPlaneEndpoint:
    domain: lb.kubesphere.local
    #address: "192.168.72.77"
    address: ""
    port: 6443
  kubernetes:
    version: v1.20.4
    imageRepo: kubesphere
    clusterName: cluster.local
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
  registry:
    registryMirrors: []
    insecureRegistries: []
  addons: []

k8s-node1自行设定,设定后,这个将会变成主机名

开始部署

# ./kk create cluster --with-kubernetes v1.20.4 --with-kubesphere v3.1.0 -f config-sample.yaml -y

name

sudo

curl

openssl

ebtables

socat

ipset

conntrack

docker

nfs client

ceph client

glusterfs client

time

localhost.localdomain.cluster.local

y

y

y

y

y

y

y

 

 

 

 

CST 23:44:43

以上是KubeSphere依赖的服务,如果在现有的Kubernetes集群上部署KubeSphere,需要有一个持久化(nfs、ceph、glusterfs三个选一个)

kk命令是以Kubeadm的形式安装的Kubernetes集群

如果是内网服务器,要先把所需的镜像都下载好,还需要提前安装好docker,然后加上--skip-pull-images参数,就不会去网络上拉取镜像了

使用KubeKey部署Kubernetes集群,需要用到如下镜像,版本自己根据实际所需去修改:

registry.cn-beijing.aliyuncs.com/kubesphereio/kube-proxy:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-apiserver:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controller-manager:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-scheduler:v1.20.4
registry.cn-beijing.aliyuncs.com/kubesphereio/node:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/pod2daemon-flexvol:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/cni:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controllers:v3.16.3
registry.cn-beijing.aliyuncs.com/kubesphereio/etcd:v3.4.13
registry.cn-beijing.aliyuncs.com/kubesphereio/k8s-dns-node-cache:1.15.12
registry.cn-beijing.aliyuncs.com/kubesphereio/coredns:1.6.9
registry.cn-beijing.aliyuncs.com/kubesphereio/pause:3.2

关于一些会出现的报错,以及解决方法

如果一直有报错:The connection to the server localhost:8080 was refused - did you specify the right host or port?: Process exited with status 1

可以尝试下面的命令,清除集群,重新创建集群

# ./kk delete cluster -f config-sample.yaml

如果镜像已经下载好了才报错的,清除集群后,再次创建集群即可

# ./kk create cluster --with-kubernetes v1.20.4 --with-kubesphere v3.1.0 -f config-sample.yaml -y

如果看到这个报错,就看一下,是不是报错的节点,缺少依赖

Failed to join node: interrupted by error

到所有节点,再次执行下面的这个命令,确保返回Nothing to do

# yum install -y socat conntrack ebtables ipset

集群验证

看到这个,表示Kubernetes集群已经部署完成了,这里在部署KubeSphere,需要等待一会,时间会稍微有点久

Please wait for the installation to complete:  >>--->

看到这个,表示KubeSphere以及部署完成了

访问:http://192.168.72.77:30880

用户名:admin

密码:P@88w0rd

第一次登录,会提示修改密码

#####################################################
###              Welcome to KubeSphere!           ###
#####################################################

Console: http://192.168.72.77: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             2021-05-09 22:23:47
#####################################################




KubeSphere还支持各种告警

到这里,完成了一个最小化的KubeSphere的部署

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章