【微服务】使用kubekey部署k8s多节点及kubesphere

kubesphere官方部署文档

https://github.com/kubesphere/kubesphere/blob/master/README_zh.md

kubuctl命令文档

https://kubernetes.io/zh-cn/docs/reference/kubectl/

k8s资源类型

https://kubernetes.io/zh-cn/docs/reference/kubectl/#资源类型

kubectl常用指令

https://kubernetes.io/zh-cn/docs/reference/kubectl/#示例-常用操作

kubectl所有命令文档

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

  1. 配置虚拟机
    hostname ip
    k8s-master 192.168.152.70
    k8s-node1 192.168.152.71
    k8s-node2 192.168.152.72
c 复制代码
#每个节点都需要执行
vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 114.114.114.114

vi /etc/hosts  
192.168.152.70 k8s-master01
192.168.152.71 k8s-node1
192.168.152.72 k8s-node2
20.205.243.166 github.com  #kubekey要从github下载,使用国内的域名映射

hostnamectl set-hostname k8s-master #设置主机名
hostnamectl set-hostname k8s-node1
hostnamectl set-hostname k8s-node2

service network restart  #网络服务重启

systemctl stop firewalld && systemctl disable firewalld  #关闭防火墙

#关闭selinux 它是一个linux内核模块,也是linux的一个安全子系统。 selinux的主要作用就是最大限度地减小系统中服务进程可访问的资源
setenforce 0  #临时关闭
vi /etc/selinux/config   SELINUX=disabled #永久关闭

# 禁用虚拟内存
swapoff -a #临时
sed -ri 's/.*swap.*/#&/' /etc/fstab #永久

#设置时间同步
yum install ntpdate -y && timedatectl set-timezone Asia/Shanghai && ntpdate cn.pool.ntp.org
  1. master节点安装kubekey
c 复制代码
#前置条件
yum install -y conntrack  socat  ebtables ipset

# 从国下载镜像 KubeKey
export KKZONE=cn

# 在线下载 自动解压kk
curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.7 sh -
  
# 如果上面命令下载不了,可以使用这个
wget https://kubernetes.pek3b.qingstor.com/kubekey/releases/download/v3.0.7/kubekey-v3.0.7-linux-amd64.tar.gz

# 解压
tar -xvf kubekey-v3.0.7-linux-amd64.tar.gz 

# 删除  
rm -rf kubekey-v3.0.7-linux-amd64.tar.gz 

./kk -h  #查看指令
./kk version --show-supported-k8s #查看当前版本的kubekey支持那个版本的k8s

#KubeKey 将默认安装 Kubernetes v1.23.10 kubesphere的版本为V3.3.2
./kk create config --with-kubesphere v3.3.2
 
 #执行上面命令生成的配置文件修改下列内容
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: k8s-master, address: 192.168.152.70, internalAddress: 192.168.152.70, user: root, password: "123456"}
  - {name: k8s-node1, address: 192.168.152.71, internalAddress: 192.168.152.71, user: root, password: "123456"}
  - {name: k8s-node2, address: 192.168.152.72, internalAddress: 192.168.152.72, user: root, password: "123456"}
  roleGroups:
    etcd:
    - k8s-master
    control-plane:
    - k8s-master
    worker:
    - k8s-master
    - k8s-node1
    - k8s-node2
  controlPlaneEndpoint:
    ## Internal loadbalancer for apiservers
    # internalLoadbalancer: haproxy
  1. 自动生成自动安装k8s和kubesphere
c 复制代码
export KKZONE=cn

# 创建集群
./kk create cluster -f config-sample.yaml


#出现下面内容则创建完成
Console: http://192.168.152.70: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.
相关推荐
孟健7 分钟前
我用 REA 逆向自己的 Electron 桌面端,扒出 178 个 IPC 通道后我反而放心了
架构·开源·ai编程
猫猫不是喵喵.11 分钟前
从0到1创建一个微服务项目
java·数据库·微服务·1024程序员节
东风微鸣40 分钟前
把 DeepSeek Harness 装进 K8s
kubernetes·deepseek·harness
Cosolar2 小时前
极简智库:快速搭建你的开源项目教程阅读平台,让 docs/ 目录被更多人看见
java·架构·github
Linye2 小时前
配了 3 套 AI 规则还打架?聊聊 Agent 信源仲裁与三层验真
人工智能·架构
一条Go2 小时前
历史告警归档:为什么"删掉主库行"是最后一步
后端·架构·github
程序员敲笔记2 小时前
把 Ubuntu-22.04 从 C 盘搬到其他盘:小白操作手册
架构
htzyl2062 小时前
别急着上微前端:从 6 个场景倒推 Module Federation 2.0 与 qiankun 2.x 的选型
前端·微服务
炫酷的大高个2 小时前
3.2TB 权重开源了,我算了 4bit 之后还要几张卡
人工智能·架构·开源
ZhengEnCi4 小时前
AI Agent 时代前端项目怎么组织:按页面纵向切块,替代按类型分层目录
架构·前端框架·前端工程化