【云原生】使用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/#%E8%B5%84%E6%BA%90%E7%B1%BB%E5%9E%8B

kubectl常用指令
https://kubernetes.io/zh-cn/docs/reference/kubectl/#%E7%A4%BA%E4%BE%8B-%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C

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
#每个节点都需要执行
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
#前置条件
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 
chmod +x kk

# 删除  
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-kubernetes v1.24.10   --with-kubesphere  
#./kk create config --with-kubernetes v1.21.5 --with-kubesphere v3.2.1 -f k8s.yaml
#--with-kubesphere  没有添加版本默认罪行版本,不加--with-kubesphere参数则不会安装kubesphere
./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
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.

在这里插入图片描述

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值