在Linux上单机安装 KubeSphere
  TEZNKK3IfmPf 2023年11月14日 44 0

准备 Linux 机器

若要以 All-in-One 模式进行安装,需参考以下对机器硬件和操作系统的要求准备一台主机。

注意:以上的系统要求和以下的说明适用于没有启用任何可选组件的默认最小化安装。如果你的机器至少有 8 Core CPU 和 16 G 内存,则建议启用所有组件。有关更多信息

节点要求

(1)节点必须能够通过 SSH 连接。

(2)节点上可以使用 sudo/curl/openssl 命令。

(3)docker 可以由您自己安装或由 KubeKey 安装。

注意:如果你想离线安装 KubeSphere,请务必提前安装好 docker。

依赖项要求

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

# 依赖项安装
apt-get install socat conntrack ebtables ipset

注意:KubeKey 是用 Go 语言开发的一款全新的安装工具,代替了以前基于 ansible 的安装程序。KubeKey 为用户提供了灵活的安装选择,可以分别安装 KubeSphere 和 Kubernetes 或二者同时安装,既方便又高效。

防火墙

由于我这是测试机器,没有特殊需求,所以将防火墙关闭。

安装docker并配置加速器

# apt安装docker
apt install docker docker.io
# 查看docker版本
docker --version
# 配置加速器,编辑下面文件,保存退出
vim /etc/docker/daemon.json
{
		 "registry-mirrors": ["https://registry.cn-hangzhou.aliyuncs.com", "https://k4lo9gcp.mirror.aliyuncs.com"]
}
# 重载docker
sudo systemctl daemon-reload
sudo systemctl restart docker

安装Kubernetes和kubesphere

下载 KubeKey

# 先执行以下命令以确保从正确的区域下载 KubeKey
export KKZONE=cn
# 执行以下命令下载 KubeKey
curl -sfL https://get-kk.kubesphere.io | VERSION=v1.0.1 sh -
# 为kk添加可执行权限
chmod +x kk

安装Kubernetes和kubesphere

kubekey安装

# 命令模板如下所示:
./kk create cluster [--with-kubernetes version] [--with-kubesphere version]
# 安装
./kk create cluster --with-kubernetes v1.17.9 --with-kubesphere v3.0.0

说明:

(1)支持的 Kubernetes 版本:v1.15.12, v1.16.13, v1.17.9 (默认), v1.18.6。

(2)一般来说,对于 All-in-One 安装,您无需更改任何配置。

(3)如果您在这一步的命令中不添加标志 --with-kubesphere ,则不会部署 KubeSphere,KubeKey 将只安装 Kubernetes。如果您添加标志 --with-kubesphere 时不指定 KubeSphere 版本,则会安装最新版本的 KubeSphere。

输入 yes 继续安装流程

验证安装结果

输入以下命令以检查安装结果:

kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

输出信息会显示 Web 控制台的 IP 地址和端口号,默认的 NodePort 是 30880。现在可以使用默认的帐户和密码 (admin /P@88w0rd) 通过 EIP:30880 访问控制台。

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

Console: http://192.168.0.221:30880
Account: admin
Password: P@88w0rd

NOTES:
  1. After logging into the console, please check the
     monitoring status of service components in
     the "Cluster Management". If any service is not
     ready, please wait patiently until all components 
     are ready.
  2. Please modify the default password after login.

#####################################################
https://kubesphere.io             2021-03-08 16:10:15
#####################################################

启用可插拔组件(可选)

我们这里采用 All-in-One 安装,则不需要创建 config-sample.yaml 文件,因为可以直接创建集群。比如我们这里启用告警和通知系统。

(1)以 admin 身份登录控制台。点击左上角的平台管理,选择集群管理。

(2)点击自定义资源 CRD,在搜索栏中输入 clusterconfiguration。点击结果查看其详细页面。

自定义资源定义 (CRD) 允许用户在不新增 API 服务器的情况下创建一种新的资源类型,用户可以像使用其他 Kubernetes 原生对象一样使用这些自定义资源。

(3)在资源列表中,点击 ks-installer 右边的三个点,选择编辑配置文件。

(4)在该 YAML 文件中,搜寻到 alerting 和 notification,将 enabled 的 false 改为 true。完成后,点击右下角的更新,保存配置。

alerting:
    enabled: true # Change "false" to "true"
notification:
    enabled: true # Change "false" to "true"

(5)通过执行以下命令,使用 Web Kubectl 工具来检查安装过程:

kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

说明:可以通过点击控制台右下角的锤子图标找到 Web Kubectl 工具。

验证组件的安装

官网提供两种验证方式:

仪表板验证

在下图所示界面中可以看到告警消息和告警策略,说明安装成功,因为安装组件之后才会显示这两部分。

kubectl命令行验证

# 执行以下命令来检查 Pod 的状态:
kubectl get pod -n kubesphere-alerting-system
# 如果组件运行成功,输出结果可能如下:
NAME                                       READY   STATUS      RESTARTS   AGE
alerting-client-744c794979-48l59           1/1     Running     4          3m43s
alerting-db-ctrl-job-4wzms                 0/1     Completed   0          3m45s
alerting-db-init-job-qvglh                 0/1     Completed   0          3m46s
alerting-executor-788f558b49-tj5k5         2/2     Running     0          3m42s
alerting-manager-5dc9d6cd46-x5ccq          1/1     Running     0          3m44s
alerting-watcher-dcb87b665-ghgqf           1/1     Running     4          3m45s
notification-db-ctrl-job-dmhsz             0/1     Completed   0          3m46s
notification-db-init-job-gzc9n             0/1     Completed   0          3m46s
notification-deployment-748897cbdf-ts4tz   1/1     Running     4          3m45s
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月14日 0

暂无评论

TEZNKK3IfmPf