Centos 7.6 使用 kubekey 部署 kubesphere v3.1.0

简介: Centos 7.6 使用 kubekey 部署 kubesphere v3.1.0

主要功能

  • 安装 Kubernetes 集群
  • 支持在任何基础设施上部署 Kubernetes,提供在线与离线安装,支持添加 GPU 节点
  • Kubernetes 资源管理
  • 提供 Web 控制台对接 Kubernetes 原生 API 快速创建与管理 Kubernetes 资源,内置多维度的可观测性
  • 多租户管理
  • 提供统一的认证鉴权与细粒度的基于角色的授权系统,支持对接 AD/LDAP

硬件要求

官方建议

  • all-in-one(基于Linux系统,部署Kubernetes集群以及KubeSphere平台)
  • 最小化:2C4G
  • 开启全部组件:8C16G
  • 基于Kubernetes集群
  • 最小化1C2G(kubernetes集群,master节点是需要2C2G的配置要求,node节点是可以1C2G的)

插件性能需求

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

Kubernetes版本要求

安装 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

创建Kubernetes集群以及KubeSphere

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的部署

相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
云原生实践公开课
课程大纲 开篇:如何学习并实践云原生技术 基础篇: 5 步上手 Kubernetes 进阶篇:生产环境下的 K8s 实践 相关的阿里云产品:容器服务&nbsp;ACK 容器服务&nbsp;Kubernetes&nbsp;版(简称&nbsp;ACK)提供高性能可伸缩的容器应用管理能力,支持企业级容器化应用的全生命周期管理。整合阿里云虚拟化、存储、网络和安全能力,打造云端最佳容器化应用运行环境。 了解产品详情:&nbsp;https://www.aliyun.com/product/kubernetes
目录
相关文章
|
23天前
|
监控 Linux 应用服务中间件
centos7 部署zabbix5 踩坑笔记
centos7 部署zabbix5 踩坑笔记
|
23天前
|
分布式计算 关系型数据库 MySQL
Sqoop【部署 01】CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
【2月更文挑战第8天】Sqoop CentOS Linux release 7.5 安装配置 sqoop-1.4.7 解决警告并验证(附Sqoop1+Sqoop2最新版安装包+MySQL驱动包资源)
124 1
|
21天前
|
Shell Linux 应用服务中间件
centos系统内容器部署服务访问不到是因为run后面加了bash
centos系统内容器部署服务访问不到是因为run后面加了bash
|
23天前
|
运维 Kubernetes 监控
本地CentOS安装轻量级容器PaaS平台KubeSphere并实现无公网IP远程访问
本地CentOS安装轻量级容器PaaS平台KubeSphere并实现无公网IP远程访问
18 0
|
23天前
|
存储 关系型数据库 Linux
CentOS如何使用Docker部署Plik服务并实现公网访问本地设备上传下载文件
CentOS如何使用Docker部署Plik服务并实现公网访问本地设备上传下载文件
41 4
|
23天前
|
存储 安全 网络协议
云服务器 Centos7 部署 Elasticsearch 8.0 + Kibana 8.0 指南
云服务器 Centos7 部署 Elasticsearch 8.0 + Kibana 8.0 指南
45 0
|
23天前
|
Linux 数据库 开发者
Centos7安装docker并部署halo建站
Docker 是一个开源的应用容器引擎,它允许开发者将应用及其依赖打包到可移植的容器中,然后在任何支持 Docker 的平台上运行。Docker 的核心概念包括镜像(Image)、容器(Container)和仓库(Repository)。镜像是创建容器的基础,容器是镜像的运行实例,而仓库是存储和分发镜像的中心仓库。 Docker 的优势在于快速、一致地交付应用,实现响应式部署和扩展,以及更高效地利用硬件资源。它常用于简化配置、代码流水线管理、提
57 0
|
23天前
|
运维 安全 Linux
如何在CentOS部署JumpServer堡垒机并实现无公网ip环境远程访问
如何在CentOS部署JumpServer堡垒机并实现无公网ip环境远程访问
|
23天前
|
数据可视化 Linux Apache
CentOS部署Apache Superset大数据可视化BI分析工具并实现无公网IP远程访问
CentOS部署Apache Superset大数据可视化BI分析工具并实现无公网IP远程访问
|
23天前
|
JavaScript Linux 数据安全/隐私保护
如何在CentOS7部署Wiki.js知识库并实现分享好友公网远程使用【内网穿透】
如何在CentOS7部署Wiki.js知识库并实现分享好友公网远程使用【内网穿透】