KubeKey 与 KubeSphere:快速构建 Kubernetes 集群

news/2025/3/12 2:08:36/

深度解析 KubeKey 与 KubeSphere:快速构建现代化 Kubernetes 集群

一、技术栈概述

KubeKey(KK)是由 KubeSphere 团队开发的轻量级 Kubernetes 集群部署工具,其优势在于:

基于 Ansible 的安装程序具有大量软件依赖性,例如 Python。KubeKey 是使用 Go 语言开发的,可以消除在各种环境中出现的问题,从而提高安装成功率。
KubeKey 使用 Kubeadm 在节点上尽可能多地并行安装 K8s 集群,以降低安装复杂性并提高效率。与较早的安装程序相比,它将大大节省安装时间。
KubeKey 支持将集群从 all-in-one 扩展到多节点集群甚至 HA 集群。
KubeKey 旨在将集群当作一个对象操作,即 CaaO。

有三种情况可以使用 KubeKey

仅安装 Kubernetes
用一个命令中安装 Kubernetes 和 KubeSphere
首先安装 Kubernetes,然后使用 ks-installer 在其上部署 KubeSphere

二、环境支持

Linux 发行版

Ubuntu 16.04, 18.04, 20.04, 22.04
Debian Bullseye, Buster, Stretch
CentOS/RHEL 7
AlmaLinux 9.0
SUSE Linux Enterprise Server 15
建议使用 Linux Kernel 版本: 4.15 or later 可以通过命令 uname -srm 查看 Linux Kernel 版本。

Kubernetes 版本

v1.19:   v1.19.15
v1.20:   v1.20.10
v1.21:   v1.21.14
v1.22:   v1.22.15
v1.23:   v1.23.10 (default)
v1.24:   v1.24.7
v1.25:   v1.25.3

要求和建议

最低资源要求(仅对于最小安装 KubeSphere):
2 核虚拟 CPU
4 GB 内存
20 GB 储存空间
/var/lib/docker 主要用于存储容器数据,在使用和操作过程中会逐渐增大。对于生产环境,建议 /var/lib/docker 单独挂盘。

操作系统要求:

SSH 可以访问所有节点。
所有节点的时间同步。
sudo/curl/openssl 应在所有节点使用。
docker 可以自己安装,也可以通过 KubeKey 安装。
Red Hat 在其 Linux 发行版本中包括了 SELinux,建议关闭SELinux或者将SELinux的模式切换为Permissive[宽容]工作模式
建议您的操作系统环境足够干净 (不安装任何其他软件),否则可能会发生冲突。
如果在从 dockerhub.io 下载镜像时遇到问题,建议准备一个容器镜像仓库 (加速器)。为 Docker 守护程序配置镜像加速。
默认情况下,KubeKey 将安装 OpenEBS 来为开发和测试环境配置 LocalPV,这对新用户来说非常方便。对于生产,请使用 NFS/Ceph/GlusterFS 或商业化存储作为持久化存储,并在所有节点中安装相关的客户端 。
如果遇到拷贝时报权限问题Permission denied,建议优先考虑查看SELinux的原因。

依赖要求:

KubeKey 可以同时安装 Kubernetes 和 KubeSphere。在版本1.18之后,安装kubernetes前需要安装一些依赖。你可以参考下面的列表,提前在你的节点上检查并安装相关依赖。

Kubernetes 版本 ≥ 1.18
socat	必须安装
conntrack	必须安装
ebtables	可选,但推荐安装
ipset	可选,但推荐安装
ipvsadm	可选,但推荐安装

网络和 DNS 要求:

确保 /etc/resolv.conf 中的 DNS 地址可用。否则,可能会导致集群中出现某些 DNS 问题。
如果您的网络配置使用防火墙或安全组,则必须确保基础结构组件可以通过特定端口相互通信。建议您关闭防火墙或遵循链接配置:网络访问。

三、KubeKey 安装

安装必要工具

yum  install -y curl wget openssl socat conntrack

离线安装包(推荐)

下载解压后可直接使用。

kubekey-v3.1.7-linux-amd64

添加到环境变量下可任意位置调用(可选)

chmod +x kk
sudo mv kk /usr/local/bin/

使用脚本获取 KubeKey(可选)

如果无法访问 https://github.com, 请先执行 export KKZONE=cn.

curl -sfL https://get-kk.kubesphere.io | sh -

从源代码生成二进制文件(可选)

git clone https://github.com/kubesphere/kubekey.git
cd kubekey
make kk

四、创建集群

注意: 由于 Kubernetes 暂不支持大写 NodeName, hostname 中包含大写字母将导致后续安装过程无法正常结束

如果无法访问 https://storage.googleapis.com, 请先执行 export KKZONE=cn.

./kk create cluster [--with-kubernetes version] [--with-kubesphere version]

使用默认版本创建一个纯 Kubernetes 集群

./kk create cluster

创建指定一个(支持的版本)的 Kubernetes 集群

./kk create cluster --with-kubernetes v1.19.8

创建一个部署了 KubeSphere 的 Kubernetes 集群 (例如 --with-kubesphere v3.1.0)

./kk create cluster --with-kubesphere [version]

创建一个指定的 container runtime 的 Kubernetes 集群(docker, crio, containerd and isula)

./kk create  cluster --container-manager containerd

通过指定配置文件来创建集群。

如果无法访问 https://storage.googleapis.com, 请先执行 export KKZONE=cn.

创建一个示例配置文件

./kk create config [--with-kubernetes version] [--with-kubesphere version] [(-f | --filename) path]

使用默认配置创建一个示例配置文件。您也可以指定文件名称或文件所在的文件夹。

./kk create config [-f ~/myfolder/config-sample.yaml]

同时安装 KubeSphere

./kk create config --with-kubesphere

根据环境修改配置文件 config-sample.yaml

当指定安装KubeSphere时,要求集群中有可用的持久化存储。默认使用localVolume

使用配置文件创建集群。

./kk create cluster -f ~/myfolder/config-sample.yaml

标准配置文件示例


apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:name: sample
spec:hosts:- {name: k8s-master, address: 172.16.8.58, internalAddress: 172.16.8.58, user: root, password: "123456"}- {name: k8s-node, address: 172.16.8.59, internalAddress: 172.16.8.59, user: root, password: "123456"}- {name: node2, address: 10.2.12.39, internalAddress: 10.2.12.39, user: root, password: "123456"}- {name: gpu-node-v100, address: 172.16.8.62, internalAddress: 172.16.8.62, user: root, password: "123456"}roleGroups:etcd:- k8s-mastercontrol-plane:- k8s-masterworker:- k8s-master- k8s-node- node2- gpu-node-v100controlPlaneEndpoint:## Internal loadbalancer for apiservers# internalLoadbalancer: haproxydomain: lb.kubesphere.localaddress: ""port: 6443kubernetes:version: v1.23.15imageRepo: registry.cn-hangzhou.aliyuncs.com/google_containersclusterName: cluster.localautoRenewCerts: truecontainerManager: dockeretcd:type: kubekeynetwork:plugin: calicokubePodsCIDR: 10.233.64.0/18kubeServiceCIDR: 10.233.0.0/18## multus support. https://github.com/k8snetworkplumbingwg/multus-cnimultusCNI:enabled: falseregistry:privateRegistry: ""namespaceOverride: ""registryMirrors: []insecureRegistries: []addons: []---
apiVersion: installer.kubesphere.io/v1alpha1
kind: ClusterConfiguration
metadata:name: ks-installernamespace: kubesphere-systemlabels:version: v3.3.2
spec:persistence:storageClass: ""authentication:jwtSecret: ""zone: ""local_registry: ""namespace_override: ""# dev_tag: ""etcd:monitoring: falseendpointIps: localhostport: 2379tlsEnable: truecommon:core:console:enableMultiLogin: trueport: 30880type: NodePort# apiserver:#  resources: {}# controllerManager:#  resources: {}redis:enabled: falsevolumeSize: 2Giopenldap:enabled: falsevolumeSize: 2Giminio:volumeSize: 20Gimonitoring:# type: externalendpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090GPUMonitoring:enabled: falsegpu:kinds:- resourceName: "nvidia.com/gpu"resourceType: "GPU"default: truees:# master:#   volumeSize: 4Gi#   replicas: 1#   resources: {}# data:#   volumeSize: 20Gi#   replicas: 1#   resources: {}logMaxAge: 7elkPrefix: logstashbasicAuth:enabled: falseusername: ""password: ""externalElasticsearchHost: ""externalElasticsearchPort: ""alerting:enabled: false# thanosruler:#   replicas: 1#   resources: {}auditing:enabled: false# operator:#   resources: {}# webhook:#   resources: {}devops:enabled: false# resources: {}jenkinsMemoryLim: 8GijenkinsMemoryReq: 4GijenkinsVolumeSize: 8Gievents:enabled: false# operator:#   resources: {}# exporter:#   resources: {}# ruler:#   enabled: true#   replicas: 2#   resources: {}logging:enabled: truelogsidecar:enabled: truereplicas: 2# resources: {}metrics_server:enabled: falsemonitoring:storageClass: ""node_exporter:port: 9100# resources: {}# kube_rbac_proxy:#   resources: {}# kube_state_metrics:#   resources: {}# prometheus:#   replicas: 1#   volumeSize: 20Gi#   resources: {}#   operator:#     resources: {}# alertmanager:#   replicas: 1#   resources: {}# notification_manager:#   resources: {}#   operator:#     resources: {}#   proxy:#     resources: {}gpu:nvidia_dcgm_exporter:enabled: false# resources: {}multicluster:clusterRole: nonenetwork:networkpolicy:enabled: falseippool:type: nonetopology:type: noneopenpitrix:store:enabled: falseservicemesh:enabled: falseistio:components:ingressGateways:- name: istio-ingressgatewayenabled: falsecni:enabled: falseedgeruntime:enabled: falsekubeedge:enabled: falsecloudCore:cloudHub:advertiseAddress:- ""service:cloudhubNodePort: "30000"cloudhubQuicNodePort: "30001"cloudhubHttpsNodePort: "30002"cloudstreamNodePort: "30003"tunnelNodePort: "30004"# resources: {}# hostNetWork: falseiptables-manager:enabled: truemode: "external"# resources: {}# edgeService:#   resources: {}terminal:timeout: 600

五、KubeSphere

k8s集群及KubeSphere 安装完成后访问地址为:
https:// < node-ip > :30880

用户名是 admin,默认密码是 P@88w0rd

在这里插入图片描述
登录后可通过图形化界面管理集群

六、官方资源与社区支持

文档中心:https://kubesphere.io/docs/
GitHub 仓库:https://github.com/kubesphere/kubesphere


http://www.ppmy.cn/news/1578503.html

相关文章

Spring Security 官网文档学习

文章目录 通过maven向普通的WEB项目中引入spring security配置 spring securityconfigure(HttpSecurity) 方法自定义URL身份验证身份验证 and 授权AuthenticationAuthenticationProvider自定义身份验证器授权Spring Security 的过滤器创建和自定义 拦截链请求匹配调度和授权方法…

【数据挖掘】异构图与同构图

在图论&#xff08;Graph Theory&#xff09;中&#xff0c;异构图&#xff08;Heterogeneous Graph&#xff09;和同构图&#xff08;Homogeneous Graph&#xff09;是两种不同的图结构概念&#xff0c;它们的主要区别在于节点和边的类型是否单一。 1. 异构图&#xff08;Hete…

Ubuntu切换lowlatency内核

文章目录 一. 前言二. 开发环境三. 具体操作 一. 前言 低延迟内核&#xff08;Lowlatency Kernel&#xff09; 旨在为需要低延迟响应的应用程序设计的内核版本。Linux-lowlatency特别适合音频处理、实时计算、游戏和其他需要及时响应的实时任务。其主要特点是优化了中断处理、调…

每日一题----------String 和StringBuffer和StringBuiler重点

本质&#xff1a;是一个char字符数组存储字符串 总结&#xff1a; 1.如果字符串存在大量的修改操作&#xff0c;一般使用StringBuffer或者StringBuilder。 2.如果字符串存在大量的修改操作&#xff0c;并且单线程的情况&#xff0c;使用StringBuilder。 3.如果字符串存在大…

论文阅读《TrustRAG: An Information Assistant with Retrieval AugmentedGeneration》

这篇论文介绍了一个名为TrustRAG的新型检索增强生成&#xff08;Retrieval-Augmented Generation, RAG&#xff09;框架&#xff0c;旨在提高RAG系统的可信度和可靠性。以下是对论文每个部分的分析&#xff1a; 1. 引言&#xff08;Introduction&#xff09; 背景&#xff1a;…

python文本处理pdfminer库安装与使用

为了安装并使用pdfminer库来处理PDF文件&#xff0c;你需要先确保已经安装了这个库。pdfminer是一个可以从PDF文档中提取信息的工具包。在Python 3.9.7环境下&#xff0c;你可以通过pip来安装它。 安装 打开命令行工具&#xff08;终端或命令提示符&#xff09;&#xff0c;然…

1433抓鸡工具_1433抓鸡工具在软件安全测试中的重要性及应用

在信息安全领域&#xff0c;“1433抓鸡工具”这一术语往往与网络安全测试紧密相关。虽然名字听起来有些戏谑&#xff0c;但这类工具在软件安全评估和渗透测试中扮演着重要角色。本文将从软考的角度出发&#xff0c;探讨1433抓鸡工具的基本概念、使用场景及其在软件安全中的作用…

内网激活JRebel插件(无网络环境)

1.官网下载安装包,JRebel and XRebel JRebel and XRebel - IntelliJ IDEs Plugin | Marketplace 2.以IInstall Plugin from Disk的方式读取 3.运行JrebelServer.jar 终端输入&#xff1a; java -jar JrebelServer.jar -p 8080 (默认8080端口)服务会自动打开浏览器至 http:/…