阿里云上kubesphere安装配置 - 使用阿里云负载均衡

教程参考

https://www.kubesphere.io/zh/docs/v3.3/installing-on-linux/public-cloud/install-kubesphere-on-ali-ecs/

环境配置
  • 关闭防火墙
  • 关闭selinux
  • 关闭swap分区
  • 时间同步
  • hosts解析
  • 内核参数设置
  • 检查DNS
  • 安装ipvs
  • 安装依赖组件
  • 安装、设置docker

每台机器都需要操作

#安装工具
yum -y install net-tools

# 如果下载不行,设置一个repo
# sed -i ‘s/mirrorlist/#mirrorlist/g’ /etc/yum.repos.d/CentOS-
# sed -i ‘s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g’ /etc/yum.repos.d/CentOS-

##关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service

##时间同步
yum install ntpdate -y
ntpdate pool.ntp.org
timedatectl set-timezone Asia/Shanghai

# 将 SELinux 设置为 permissive 模式(相当于将其禁用)
sudo setenforce 0
sudo sed -i ‘s/^SELINUX=enforcing$/SELINUX=permissive/’ /etc/selinux/config

#关闭swap
swapoff -a
sed -ri ‘s/.swap./#&/’ /etc/fstab

#允许 iptables 检查桥接流量
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

sudo sysctl –system

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
安装Docker
sudo yum remove docker*
sudo yum install -y yum-utils

#配置docker的yum地址
sudo yum-config-manager </span>
–add-repo </span>
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

#安装指定版本
sudo yum install -y docker-ce-20.10.7 docker-ce-cli-20.10.7 containerd.io-1.4.6

#安装
sudo yum install -y socat conntrack nfs-utils

# 启动&开机启动docker
systemctl enable docker –now

# docker加速配置
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF’
{
“registry-mirrors”: [“https://m7qysq7c.mirror.aliyuncs.com”],
“exec-opts”: [“native.cgroupdriver=systemd”],
“log-driver”: “json-file”,
“log-opts”: {
“max-size”: “100m”
},
“storage-driver”: “overlay2”
}
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

完成后可以制作镜像

安装实例选择 k8s_base_image_2,已经完成部分设置
在这里插入图片描述

首次安装-选取一台master
export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.7 sh -
chmod +x kk
./kk create config --with-kubesphere v3.3.2 --with-kubernetes v1.22.12 -f config-sample.yaml

 
 
  • 1
  • 2
  • 3
  • 4

修改部分配置

config.yaml
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: master1, address: 172.31.0.239, internalAddress: 172.31.0.239, user: root, password: "Hailiao$123"}
  - {name: master2, address: 172.31.0.237, internalAddress: 172.31.0.237, user: root, password: "Hailiao$123"}
  - {name: master3, address: 172.31.0.238, internalAddress: 172.31.0.238, user: root, password: "Hailiao$123"}
  - {name: node1, address: 172.31.0.243, internalAddress: 172.31.0.243, user: root, password: "Hailiao$123"}
  roleGroups:
    etcd:
    - master1
    - master2
    - master3
    control-plane: 
    - master1
    - master2
    - master3
    worker:
    - node1
  controlPlaneEndpoint:
    ## Internal loadbalancer for apiservers 
    ## internalLoadbalancer: haproxy
	# 阿里云的负载均衡
    domain: lb.kubesphere.local
    address: "1xx.xx.xx.xx"
    port: 6443
  kubernetes:
    version: v1.22.12
    clusterName: cluster.local
    autoRenewCerts: true
    containerManager: docker
  etcd:
    type: kubekey
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
    ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni
    multusCNI:
      enabled: false
  registry:
    privateRegistry: ""
    namespaceOverride: ""
    registryMirrors: []
    insecureRegistries: []
  addons:
  - name: nfs-client
    namespace: kube-system
    sources:
      chart:
        name: nfs-client-provisioner
        repo: https://charts.kubesphere.io/main
        valuesFile: /root/nfs-client.yaml

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55

没有全部复制,主要是完成了nfs初始化使用nas

nfs-client.yaml
nfs:
  server: "xxx.nas.aliyuncs.com"    # 阿里云Nas地址.
  path: "/new_ks_data"    # Replace the exported directory with your own.
storageClass:
  defaultClass: true

 
 
  • 1
  • 2
  • 3
  • 4
  • 5

运行安装

./kk create cluster -f config.yaml

 
 
  • 1
选择这个镜像后,只需要设置hostname和hosts

每台机器使用内网ip互通

每台机器配置自己的hostname 每个机器分别执行 hostnamectl set-hostname xxx (node1~6)

hostnamectl set-hostname node1  # node1 就是对应的主机名称

vim /etc/hosts

# 添加hosts信息
172.31.0.239 master1
172.31.0.237 master2
172.31.0.238 master3
172.31.0.243 node1
# 对应添加更多node主机名称

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值