搭建安装kubesphere平台——在 Linux 上以 All-in-One 模式,附安装步骤—{全篇踩坑排坑记} kubernetes:k8s

记:官方文档有几处坑,安装一次次踩坑,辛酸苦辣甜

官方安装教程:在 Linux 上以 All-in-One 模式安装 KubeSphere

1.对于刚接触 KubeSphere 并想快速上手该容器平台的用户,All-in-One 安装模式是最佳的选择,它能够帮助您零配置快速部署 KubeSphere 和 Kubernetes。

2.本篇采用腾讯云2c4g环境,系统Linux,根据步骤安装最新的ks版本

步骤 1:准备 Linux 机器

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

硬件推荐配置

操作系统最低配置
Ubuntu 16.0418.042 核 CPU,4 GB 内存,40 GB 磁盘空间
Debian BusterStretch2 核 CPU,4 GB 内存,40 GB 磁盘空间
CentOS 7.x2 核 CPU,4 GB 内存,40 GB 磁盘空间

依赖项要求

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

依赖项Kubernetes 版本 ≥ 1.18Kubernetes 版本 < 1.18
socat必须可选但建议
conntrack必须可选但建议
ebtables可选但建议可选但建议
ipset可选但建议可选但建议

#1 安装k8s、kubesphere前需要环境准备

1.1 修改源镜像地址

     1.# 更新yum

        yum -y update

      2.# 安装wget命令

        yum -y install wget

1.2 关闭、禁用防火墙

      1. # 关闭防火墙

        systemctl stop firewalld

        # 开机禁用

        systemctl disable firewalld

       2. # 查看防火墙状态

        systemctl status firewalld

       3. # 临时关闭selinux

        setenforce 0

        4.# 永久关闭, 编辑/etc/selinux/config,将SELINUX更改为disabled

                vim /etc/selinux/config

                # 修改内容如下

                SELINUX=disabled

1.3 关闭iptables服务

        1.# 关闭iptables

        systemctl stop iptables

       2. # 开机禁用

        systemctl disable iptables

1.4 关闭 swap

        swap会将部分内存数据存放到磁盘中导致性能下降,并且会导致系统运行时未知错误。

        1.# 关闭swap

        swapoff -a

       2. # 修改“/etc/fstab”文件,注释掉SWAP的自动挂载(加符号“#”)

                vim /etc/fstab

                # 在“/dev/mapper/centos-swap”行前面添加"#",如下:

               # /dev/mapper/centos-swap swap swap defaults 0 0

        3.# free查看内存和swap,其中swap为0

                free -m

#2 此处踩坑问题:

2.1安装前要关闭selinux

否则报错:ERRO[15:49:04 CST] Failed to get etcdctl: Failed to exec command: sudo -E /bin/sh -c "docker run --rm -v /usr/local/bin:/systembindir kubesphere/etcd:v3.3.12 /bin/cp /usr/local/bin/etcdctl /systembindir/etcdctl"
cp: can't create '/systembindir/etcdctl': Permission denied: Process exited with status 1

主从机器都需要安装   yum install conntrack-tools,安装前要关闭selinux

                vim /etc/selinux/config

                # 修改内容如下

                SELINUX=disabled

然后:

yum -y install conntrack

yum -y install epel-release

yum -y install socat

2.2 remove master taint failed:

20:03:20 CST stdout: [VM-4-7-ubuntu]:

Error from server (NotFound): nodes "VM-4-7-ubuntu" not found

20:03:20 CST message: [VM-4-7-ubuntu]:

remove master taint failed: Failed to exec command: sudo -E /bin/bash -c "/usr/local/bin/kubectl taint nodes VM-4-7-ubuntu node-role.kubernetes.io/master=:NoSchedule-"

Error from server (NotFound): nodes "VM-4-7-ubuntu" not found: Process exited with status 1

 此处需配置hostname:

hostnamectl status

hostnamectl set-hostname VM-4-7-centos
hostnamectl --static set-hostname VM-4-7-centos
hostnamectl --transient set-hostname VM-4-7-centos

        参考命令:

        要查看主机名相关的设置:

        # hostnamectl status

        只查看静态、瞬态或灵活主机名,分别使用“--static”,“--transient”或“--pretty”选项。

        # hostnamectl status [--static|--transient|--pretty]

        要同时修改所有三个主机名:静态、瞬态和灵活主机名:

        # hostnamectl set-hostname <host-name>

        例如,要永久修改主机名,你可以修改静态主机名:

        # hostnamectl --static set-hostname <host-name>

        hostnamectl status

步骤 2:下载 KubeKey

先执行以下命令以确保您从正确的区域下载 KubeKey。

export KKZONE=cn

执行以下命令下载 KubeKey:(此处查看官方版本)

curl -sfL https://get-kk.kubesphere.io | VERSION=v2.0.0 sh -

为 kk 添加可执行权限:

chmod +x kk

备注:kubekey创建配置文件,使用和all in one相同的kubesphere,k8s版本。

步骤 3:开始安装

在本快速入门教程中,您只需执行一个命令即可进行安装,其模板如下所示:

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

若要同时安装 Kubernetes 和 KubeSphere,可参考以下示例命令:(此处查看官方版本)

./kk create cluster --with-kubernetes v1.21.5 --with-kubesphere v3.2.1

步骤 4:验证安装结果

当您看到以下输出时,表明安装已经完成。

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

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) 通过 <NodeIP>:30880 访问控制台。

参考:

在 Linux 上以 All-in-One 模式安装 KubeSphere

https://jingyan.baidu.com/article/36d6ed1f6f9db75ace48831c.html

搭建kubesphere平台———一把辛酸泪_mb60f63d7bf0255的技术博客_51CTO博客

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值