一、环境准备
1、三台8核/16G内存/500G高速硬盘服务器和三台16核/32G内存/500G高速硬盘服务器 2、CentOS 7 3、关闭selinux和关闭防火墙 4、升级系统内核(参考:https://www.cnblogs.com/a120608yby/p/10169364.html) 二、配置免密登录# 创建密钥对 ssh-keygen 复制密钥到所有节点包括自身 ssh-copy-id 所有节点的IP地址三、部署 1、下载源码、二进制文件或离线镜像
export release=3.5.2 wget https://github.com/easzlab/kubeasz/releases/download/${release}/ezdown chmod +x ./ezdown
2、下载kubeasz代码、二进制、默认容器镜像
# 国内环境 ./ezdown -D # 海外环境 ./ezdown -D -m standard
3、创建集群
# 容器化运行kubeasz ./ezdown -S # 创建新集群 k8s-01 docker exec -it kubeasz ezctl new k8s-01 # 配置/etc/kubeasz/clusters/k8s-01/hosts和/etc/kubeasz/clusters/k8s-01/config.yml # vim hosts # 'etcd' cluster should have odd member(s) (1,3,5,...) [etcd] 172.16.0.1 172.16.0.2 172.16.0.3 # master node(s), set unique 'k8s_nodename' for each node # CAUTION: 'k8s_nodename' must consist of lower case alphanumeric characters, '-' or '.', # and must start and end with an alphanumeric character [kube_master] 172.16.0.1 k8s_nodename='master-01' 172.16.0.2 k8s_nodename='master-02' 172.16.0.3 k8s_nodename='master-03' # work node(s), set unique 'k8s_nodename' for each node # CAUTION: 'k8s_nodename' must consist of lower case alphanumeric characters, '-' or '.', # and must start and end with an alphanumeric character [kube_node] 172.16.0.4 k8s_nodename='worker-01' 172.16.0.5 k8s_nodename='worker-02' 172.16.0.6 k8s_nodename='worker-03' # [optional] harbor server, a private docker registry # 'NEW_INSTALL': 'true' to install a harbor server; 'false' to integrate with existed one [harbor] #192.168.1.8 NEW_INSTALL=false # [optional] loadbalance for accessing k8s from outside [ex_lb] #192.168.1.6 LB_ROLE=backup EX_APISERVER_VIP=192.168.1.250 EX_APISERVER_PORT=8443 #192.168.1.7 LB_ROLE=master EX_APISERVER_VIP=192.168.1.250 EX_APISERVER_PORT=8443 # [optional] ntp server for the cluster [chrony] #192.168.1.1 [all:vars] # --------- Main Variables --------------- # Secure port for apiservers SECURE_PORT="6443" # Cluster container-runtime supported: docker, containerd # if k8s version >= 1.24, docker is not supported CONTAINER_RUNTIME="containerd" # Network plugins supported: calico, flannel, kube-router, cilium, kube-ovn CLUSTER_NETWORK="calico" # Service proxy mode of kube-proxy: 'iptables' or 'ipvs' PROXY_MODE="ipvs" # K8S Service CIDR, not overlap with node(host) networking SERVICE_CIDR="10.68.0.0/16" # Cluster CIDR (Pod CIDR), not overlap with node(host) networking CLUSTER_CIDR="10.20.0.0/16" # NodePort Range NODE_PORT_RANGE="30000-32767" # Cluster DNS Domain CLUSTER_DNS_DOMAIN="cluster.local" # -------- Additional Variables (don't change the default value right now) --- # Binaries Directory bin_dir="/opt/kube/bin" # Deploy Directory (kubeasz workspace) base_dir="/etc/kubeasz" # Directory for a specific cluster cluster_dir="{{ base_dir }}/clusters/k8s-01" # CA and other components cert/key Directory ca_dir="/etc/kubernetes/ssl" # Default 'k8s_nodename' is empty k8s_nodename=''
4、安装集群
# 一键安装 docker exec -it kubeasz ezctl setup k8s-01 all
参考:https://github.com/easzlab/kubeasz
标签:node,01,nodename,Kubernetes,kubeasz,最佳,172.16,k8s From: https://www.cnblogs.com/a120608yby/p/17141560.html