用kubekit搭建k8s集群

作者 : 开心源码 本文共4043个字,预计阅读时间需要11分钟 发布时间: 2022-05-11 共133人阅读

概述

其实有时候安装搭建这个东西是费时费力的事情,假如有脚本为什么不可以用脚本呢?花100分钟在搭建上还不如使用100分钟去研究怎样用

什么是kubekit

Kubekit是一个部署工具包,它为kubernetes提供离线安装处理方案。您能用它将Kubernetes部署到OFFLINE生产环境。

Kubekit将安装

  • Docker(1.12.6)
  • Kubernetes及其所有组件
  • Kubernetes仪表板,默认节点端口:31234

kubkit地址

Orientsoft/kubekit

操作系统

首先官方支持下面两个操作系统,而且都要是最小化安装支持的

  • CentOS release 7.3.1611
  • CentOS release 7.4.1708

我用是1708,k8s版本是V1.9.2,具体的能看github上的readme

wget http://111.1.50.85/files/1128000004BF9EC9/linux.cc.lehigh.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso

在虚拟机里面正常安装,注意是最小化安装,我给虚拟机的内存是2g,希望有一天我也能买台mac book pro吧
安装完成之后关闭防火墙

systemctl stop firewalld

systemctl disable firewalld

关闭selinux

setenforce 0

vim /etc/selinux/config

修改为

SELINUX=disabled

最好还能同步一下时间什么的

yum install ntpdate

ntpdate 0.cn.pool.ntp.org

下载kubekit

yum install wget

wget https://kubekit.orientsoft.cn/kubekit-linux64-0.3.tar.gz

解压

tar -zxvf kubekit-linux64-0.3.tar.gz

mv kubekit-release/ kubekit

下载离线包并且安装集群

wget https://kubekit.orientsoft.cn/package-1.9.2.tar.gz

tar -zxvf package-1.9.2.tar.gz

mv package kubekit

给脚本赋予可执行权限

cd kubekit/package/

chmod +x ./*.sh

最后安装并初始化master节点

./kubekit init 192.168.38.166

到下面这步就说明节点初始化成功了

[root@kubekit kubekit]# ./kubekit init 192.168.38.166 ___  __        ___  ___      ________      _______       ___  __        ___      _________   |\  \|\  \     |\  \|\  \    |\   __  \    |\  ___ \     |\  \|\  \     |\  \    |\___   ___\ \ \  \/  /|_   \ \  \\\  \   \ \  \|\ /_   \ \   __/|    \ \  \/  /|_   \ \  \   \|___ \  \_|  \ \   ___  \   \ \  \\\  \   \ \   __  \   \ \  \_|/__   \ \   ___  \   \ \  \       \ \  \    \ \  \\ \  \   \ \  \\\  \   \ \  \|\  \   \ \  \_|\ \   \ \  \\ \  \   \ \  \       \ \  \    \ \__\\ \__\   \ \_______\   \ \_______\   \ \_______\   \ \__\\ \__\   \ \__\       \ \__\    \|__| \|__|    \|_______|    \|_______|    \|_______|    \|__| \|__|    \|__|        \|__|KubeKit V0.3 ?  OrientSoft 2018Initialization process started, with kubernetes master IP: 192.168.38.166? HTTP file server listening at: 0.0.0.0:8000Start to install docker engine...(1/2) Start to install docker...(2/2) Start to config docker...? Docker engine installed...Start to initialize Kubernetes master node...(1/6) Start to load images for Kubernetes master...(2/6) Start to install components for Kubernetes master...(3/6) Start to configure firewall...(4/6) Start to initialize Kubernetes master...? Master token 3826ab.fef296d97de13f83 saved into .k8s.token file.(5/6) Start to config Kubernetes network...(6/6) Start to install Kubernetes dashboard...? Kubernetes master node initialized...Remember to reload shell with: source ~/.bashrc before using kubectl![GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env:   export GIN_MODE=release - using code:  gin.SetMode(gin.ReleaseMode)[GIN-debug] GET    /assets/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (4 handlers)[GIN-debug] HEAD   /assets/*filepath         --> github.com/gin-gonic/gin.(*RouterGroup).createStaticHandler.func1 (4 handlers)[GIN-debug] Loaded HTML Templates (3):     -     - index.html    - locale.htmlopen ./.nodes: no such file or directory[GIN-debug] GET    /                         --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).IndexHandler-fm (4 handlers)[GIN-debug] GET    /ws                       --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).Initialize.func1 (4 handlers)[GIN-debug] GET    /node/list                --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).ListNodesHandler-fm (4 handlers)[GIN-debug] POST   /node                     --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).CreateNodeHandler-fm (4 handlers)[GIN-debug] PUT    /node/remove/:id          --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).RemoveNodeHandler-fm (4 handlers)[GIN-debug] GET    /node/refresh/:id         --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).RefreshNodeHandler-fm (4 handlers)[GIN-debug] GET    /node/log/:id             --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).GetInstallLog-fm (4 handlers)[GIN-debug] POST   /install                  --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).InstallNodeHandler-fm (4 handlers)[GIN-debug] GET    /install/progress/:id/:step --> github.com/Orientsoft/kubekit/controllers.(*MainRouter).NodeProgressHandler-fm (4 handlers)? Toolkit server is listening at: 0.0.0.0:9000[GIN-debug] Listening and serving HTTP on :9000

接着ctrl+c退出来,而后重新启动kubekit的dashboard并且放在后端

./kubekit server &

增加一个node

浏览器访问ip:9000

创立一个同样安装着centos 1708最小化安装的机器,之后打开修改主机名

hostnamectl set-hostname kubekit-node1

接着点击web界面上的add node,输入ssh账号密码等信息,最后选中点击start deploy即可以了

之后你就会在kubernetes的dashboard看到这个节点的详细信息了

欢迎关注Bboysoul的博客www.bboysoul.com
Have Fun

说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » 用kubekit搭建k8s集群

发表回复