From 8cf349b27122b8fef7ab90bf42a967f66afd6385 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Wed, 29 May 2019 22:49:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80example=20hosts=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=8F=8A=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sts.allinone.example.en => hosts.allinone} | 36 +++------ example/hosts.allinone.example | 67 ---------------- example/hosts.cloud.example | 67 ---------------- example/hosts.m-masters.example | 77 ------------------ example/hosts.m-masters.example.en | 78 ------------------- ...osts.cloud.example.en => hosts.multi-node} | 44 +++++------ example/hosts.s-master.example | 68 ---------------- example/hosts.s-master.example.en | 69 ---------------- roles/cluster-addon/tasks/main.yml | 8 ++ roles/kube-master/tasks/main.yml | 8 ++ roles/kube-node/tasks/main.yml | 8 ++ 11 files changed, 54 insertions(+), 476 deletions(-) rename example/{hosts.allinone.example.en => hosts.allinone} (52%) delete mode 100644 example/hosts.allinone.example delete mode 100644 example/hosts.cloud.example delete mode 100644 example/hosts.m-masters.example delete mode 100644 example/hosts.m-masters.example.en rename example/{hosts.cloud.example.en => hosts.multi-node} (55%) delete mode 100644 example/hosts.s-master.example delete mode 100644 example/hosts.s-master.example.en diff --git a/example/hosts.allinone.example.en b/example/hosts.allinone similarity index 52% rename from example/hosts.allinone.example.en rename to example/hosts.allinone index c289ade..a78af90 100644 --- a/example/hosts.allinone.example.en +++ b/example/hosts.allinone @@ -1,38 +1,32 @@ -# 'deploy' node, which the ansible-playbooks usually run on -# variable 'NTP_ENABLED(=yes/no)' enables/disables the NTP server 'chrony' -[deploy] -192.168.1.1 NTP_ENABLED=no - -# 'etcd' cluster must have odd member(s) (1,3,5,...) +# 'etcd' cluster should have odd member(s) (1,3,5,...) # variable 'NODE_NAME' is the distinct name of a member in 'etcd' cluster [etcd] 192.168.1.1 NODE_NAME=etcd1 +# master node(s) [kube-master] 192.168.1.1 +# work node(s) [kube-node] 192.168.1.1 -# set 'NEW_INSTALL': 'yes' to install a harbor server; 'no' to integrate with existed one -# if not using domian,set 'HARBOR_DOMAIN=""' +# [optional] harbor server, a private docker registry +# 'NEW_INSTALL': 'yes' to install a harbor server; 'no' to integrate with existed one [harbor] #192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no -# [optional] loadbalance for services with type 'NodePort' +# [optional] loadbalance for accessing k8s from outside [ex-lb] -#192.168.1.6 LB_ROLE=backup EX_VIP=192.168.1.250 -#192.168.1.7 LB_ROLE=master EX_VIP=192.168.1.250 +#192.168.1.6 LB_ROLE=backup EX_APISERVER_VIP=192.168.1.250 +#192.168.1.7 LB_ROLE=master EX_APISERVER_VIP=192.168.1.250 + +# [optional] ntp server for cluster +[chrony] +#192.168.1.1 [all:vars] # --------- Main Variables --------------- -# Cluster Deployment Mode: allinone, single-master, multi-master -DEPLOY_MODE=allinone - -# Cluster's Master IP, auto generated -MASTER_IP="{{ groups['kube-master'][0] }}" -KUBE_APISERVER="https://{{ MASTER_IP }}:6443" - # Cluster container-runtime supported: docker, containerd CONTAINER_RUNTIME="docker" @@ -48,12 +42,6 @@ CLUSTER_CIDR="172.20.0.0/16" # NodePort Range NODE_PORT_RANGE="20000-40000" -# Kubernetes SVC IP (usually assigned with the first available IP of 'SERVICE_CIDR') -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# Cluster DNS Server's IP (assigned with an available IP of 'SERVICE_CIDR') -CLUSTER_DNS_SVC_IP="10.68.0.2" - # Cluster DNS Domain CLUSTER_DNS_DOMAIN="cluster.local." diff --git a/example/hosts.allinone.example b/example/hosts.allinone.example deleted file mode 100644 index cc689e7..0000000 --- a/example/hosts.allinone.example +++ /dev/null @@ -1,67 +0,0 @@ -# 集群部署节点:一般为运行ansible 脚本的节点 -# 变量 NTP_ENABLED (=yes/no) 设置集群是否安装 chrony 时间同步 -[deploy] -192.168.1.1 NTP_ENABLED=no - -# etcd集群请提供如下NODE_NAME,注意etcd集群必须是1,3,5,7...奇数个节点 -[etcd] -192.168.1.1 NODE_NAME=etcd1 - -[kube-master] -192.168.1.1 - -[kube-node] -192.168.1.1 - -# 参数 NEW_INSTALL:yes表示新建,no表示使用已有harbor服务器 -# 如果不使用域名,可以设置 HARBOR_DOMAIN="" -[harbor] -#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no - -# 【可选】外部负载均衡,用于自有环境负载转发 NodePort 暴露的服务等 -[ex-lb] -#192.168.1.6 LB_ROLE=backup EX_VIP=192.168.1.250 -#192.168.1.7 LB_ROLE=master EX_VIP=192.168.1.250 - -[all:vars] -# ---------集群主要参数--------------- -#集群部署模式:allinone, single-master, multi-master -DEPLOY_MODE=allinone - -#集群 MASTER IP,自动生成 -MASTER_IP="{{ groups['kube-master'][0] }}" -KUBE_APISERVER="https://{{ MASTER_IP }}:6443" - -# 集群容器运行时,支持 docker, containerd -CONTAINER_RUNTIME="docker" - -# 集群网络插件,目前支持calico, flannel, kube-router, cilium, kube-ovn -CLUSTER_NETWORK="flannel" - -# 服务网段 (Service CIDR),注意不要与内网已有网段冲突 -SERVICE_CIDR="10.68.0.0/16" - -# POD 网段 (Cluster CIDR),注意不要与内网已有网段冲突 -CLUSTER_CIDR="172.20.0.0/16" - -# 服务端口范围 (NodePort Range) -NODE_PORT_RANGE="20000-40000" - -# kubernetes 服务 IP (预分配,一般是 SERVICE_CIDR 中第一个IP) -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# 集群 DNS 服务 IP (从 SERVICE_CIDR 中预分配) -CLUSTER_DNS_SVC_IP="10.68.0.2" - -# 集群 DNS 域名 -CLUSTER_DNS_DOMAIN="cluster.local." - -# ---------附加参数-------------------- -#默认二进制文件目录 -bin_dir="/opt/kube/bin" - -#证书目录 -ca_dir="/etc/kubernetes/ssl" - -#部署目录,即 ansible 工作目录 -base_dir="/etc/ansible" diff --git a/example/hosts.cloud.example b/example/hosts.cloud.example deleted file mode 100644 index 4202d4f..0000000 --- a/example/hosts.cloud.example +++ /dev/null @@ -1,67 +0,0 @@ -# 集群部署节点:一般为运行ansible 脚本的节点 -# 变量 NTP_ENABLED (=yes/no) 设置集群是否安装 chrony 时间同步, 公有云上虚机不需要 -[deploy] -192.168.1.1 NTP_ENABLED=no - -# etcd集群请提供如下NODE_NAME,注意etcd集群必须是1,3,5,7...奇数个节点 -[etcd] -192.168.1.1 NODE_NAME=etcd1 -192.168.1.2 NODE_NAME=etcd2 -192.168.1.3 NODE_NAME=etcd3 - -[kube-master] -192.168.1.2 -192.168.1.3 - -[kube-node] -192.168.1.1 -192.168.1.4 - -# 参数 NEW_INSTALL:yes表示新建,no表示使用已有harbor服务器 -# 如果不使用域名,可以设置 HARBOR_DOMAIN="" -[harbor] -#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no - -[all:vars] -# ---------集群主要参数--------------- -#集群部署模式:allinone, single-master, multi-master -DEPLOY_MODE=multi-master - -# 公有云上一般都有提供负载均衡产品,且不允许自己创建lb -# 创建公有云内网负载均衡,然后配置:前端监听 tcp 8443,后端 tcp 6443,后端节点即 master 节点 -MASTER_IP="192.168.1.10" # 即负载均衡内网地址 -KUBE_APISERVER="https://{{ MASTER_IP }}:8443" - -# 集群容器运行时,支持 docker, containerd -CONTAINER_RUNTIME="docker" - -# 集群网络插件,目前支持calico, flannel, kube-router, cilium, kube-ovn -CLUSTER_NETWORK="flannel" - -# 服务网段 (Service CIDR),注意不要与内网已有网段冲突 -SERVICE_CIDR="10.68.0.0/16" - -# POD 网段 (Cluster CIDR),注意不要与内网已有网段冲突 -CLUSTER_CIDR="172.20.0.0/16" - -# 服务端口范围 (NodePort Range) -NODE_PORT_RANGE="20000-40000" - -# kubernetes 服务 IP (预分配,一般是 SERVICE_CIDR 中第一个IP) -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# 集群 DNS 服务 IP (从 SERVICE_CIDR 中预分配) -CLUSTER_DNS_SVC_IP="10.68.0.2" - -# 集群 DNS 域名 -CLUSTER_DNS_DOMAIN="cluster.local." - -# ---------附加参数-------------------- -#默认二进制文件目录 -bin_dir="/opt/kube/bin" - -#证书目录 -ca_dir="/etc/kubernetes/ssl" - -#部署目录,即 ansible 工作目录,建议不要修改 -base_dir="/etc/ansible" diff --git a/example/hosts.m-masters.example b/example/hosts.m-masters.example deleted file mode 100644 index 7b3c8ec..0000000 --- a/example/hosts.m-masters.example +++ /dev/null @@ -1,77 +0,0 @@ -# 集群部署节点:一般为运行ansible 脚本的节点 -# 变量 NTP_ENABLED (=yes/no) 设置集群是否安装 chrony 时间同步 -[deploy] -192.168.1.1 NTP_ENABLED=no - -# etcd集群请提供如下NODE_NAME,注意etcd集群必须是1,3,5,7...奇数个节点 -[etcd] -192.168.1.1 NODE_NAME=etcd1 -192.168.1.2 NODE_NAME=etcd2 -192.168.1.3 NODE_NAME=etcd3 - -[kube-master] -192.168.1.1 -192.168.1.2 - -[kube-node] -192.168.1.3 -192.168.1.4 - -# 参数 NEW_INSTALL:yes表示新建,no表示使用已有harbor服务器 -# 如果不使用域名,可以设置 HARBOR_DOMAIN="" -[harbor] -#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no - -# 负载均衡(目前已支持多于2节点,一般2节点就够了) 安装 haproxy+keepalived -[lb] -192.168.1.1 LB_ROLE=backup -192.168.1.2 LB_ROLE=master - -#【可选】外部负载均衡,用于自有环境负载转发 NodePort 暴露的服务等 -[ex-lb] -#192.168.1.6 LB_ROLE=backup EX_VIP=192.168.1.250 -#192.168.1.7 LB_ROLE=master EX_VIP=192.168.1.250 - -[all:vars] -# ---------集群主要参数--------------- -#集群部署模式:allinone, single-master, multi-master -DEPLOY_MODE=multi-master - -# 集群 MASTER IP即 LB节点VIP地址,为区别与默认apiserver端口,设置VIP监听的服务端口8443 -# 公有云上请使用云负载均衡内网地址和监听端口 -MASTER_IP="192.168.1.10" -KUBE_APISERVER="https://{{ MASTER_IP }}:8443" - -# 集群容器运行时,支持 docker, containerd -CONTAINER_RUNTIME="docker" - -# 集群网络插件,目前支持calico, flannel, kube-router, cilium, kube-ovn -CLUSTER_NETWORK="flannel" - -# 服务网段 (Service CIDR),注意不要与内网已有网段冲突 -SERVICE_CIDR="10.68.0.0/16" - -# POD 网段 (Cluster CIDR),注意不要与内网已有网段冲突 -CLUSTER_CIDR="172.20.0.0/16" - -# 服务端口范围 (NodePort Range) -NODE_PORT_RANGE="20000-40000" - -# kubernetes 服务 IP (预分配,一般是 SERVICE_CIDR 中第一个IP) -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# 集群 DNS 服务 IP (从 SERVICE_CIDR 中预分配) -CLUSTER_DNS_SVC_IP="10.68.0.2" - -# 集群 DNS 域名 -CLUSTER_DNS_DOMAIN="cluster.local." - -# ---------附加参数-------------------- -#默认二进制文件目录 -bin_dir="/opt/kube/bin" - -#证书目录 -ca_dir="/etc/kubernetes/ssl" - -#部署目录,即 ansible 工作目录,建议不要修改 -base_dir="/etc/ansible" diff --git a/example/hosts.m-masters.example.en b/example/hosts.m-masters.example.en deleted file mode 100644 index 54efca0..0000000 --- a/example/hosts.m-masters.example.en +++ /dev/null @@ -1,78 +0,0 @@ -# 'deploy' node, which the ansible-playbooks usually run on -# variable 'NTP_ENABLED(=yes/no)' enables/disables the NTP server 'chrony' -[deploy] -192.168.1.1 NTP_ENABLED=no - -# 'etcd' cluster must have odd member(s) (1,3,5,...) -# variable 'NODE_NAME' is the distinct name of a member in 'etcd' cluster -[etcd] -192.168.1.1 NODE_NAME=etcd1 -192.168.1.2 NODE_NAME=etcd2 -192.168.1.3 NODE_NAME=etcd3 - -[kube-master] -192.168.1.1 -192.168.1.2 - -[kube-node] -192.168.1.3 -192.168.1.4 - -# set 'NEW_INSTALL': 'yes' to install a harbor server; 'no' to integrate with existed one -# if not using domian,set 'HARBOR_DOMAIN=""' -[harbor] -#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no - -# 'loadbalance' node, with 'haproxy+keepalived' installed -[lb] -192.168.1.1 LB_ROLE=backup -192.168.1.2 LB_ROLE=master - -# [optional] loadbalance for services with type 'NodePort' -[ex-lb] -#192.168.1.6 LB_ROLE=backup EX_VIP=192.168.1.250 -#192.168.1.7 LB_ROLE=master EX_VIP=192.168.1.250 - -[all:vars] -# --------- Main Variables --------------- -# Cluster Deployment Mode: allinone, single-master, multi-master -DEPLOY_MODE=multi-master - -# Cluster's Master IP, generated by 'keepalived' daemon on a 'lb' node here -# 'haproxy' daemon listens on port 8443, directs requests to real apiservers on port 6443 -MASTER_IP="192.168.1.10" -KUBE_APISERVER="https://{{ MASTER_IP }}:8443" - -# Cluster container-runtime supported: docker, containerd -CONTAINER_RUNTIME="docker" - -# Network plugins supported: calico, flannel, kube-router, cilium, kube-ovn -CLUSTER_NETWORK="flannel" - -# 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="172.20.0.0/16" - -# NodePort Range -NODE_PORT_RANGE="20000-40000" - -# Kubernetes SVC IP (usually assigned with the first available IP of 'SERVICE_CIDR') -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# Cluster DNS Server's IP (assigned with an available IP of 'SERVICE_CIDR') -CLUSTER_DNS_SVC_IP="10.68.0.2" - -# Cluster DNS Domain -CLUSTER_DNS_DOMAIN="cluster.local." - -# -------- Additional Variables -------------------- -# Binaries Directory -bin_dir="/opt/kube/bin" - -# CA and other components cert/key Directory -ca_dir="/etc/kubernetes/ssl" - -# Deploy Directory (kubeasz workspace), don't change the default value right now -base_dir="/etc/ansible" diff --git a/example/hosts.cloud.example.en b/example/hosts.multi-node similarity index 55% rename from example/hosts.cloud.example.en rename to example/hosts.multi-node index ddd4090..4d4454b 100644 --- a/example/hosts.cloud.example.en +++ b/example/hosts.multi-node @@ -1,38 +1,36 @@ -# 'deploy' node, which the ansible-playbooks usually run on -# variable 'NTP_ENABLED(=yes/no)' enables/disables the NTP server 'chrony' -[deploy] -192.168.1.1 NTP_ENABLED=no - -# 'etcd' cluster must have odd member(s) (1,3,5,...) +# 'etcd' cluster should have odd member(s) (1,3,5,...) # variable 'NODE_NAME' is the distinct name of a member in 'etcd' cluster [etcd] 192.168.1.1 NODE_NAME=etcd1 192.168.1.2 NODE_NAME=etcd2 192.168.1.3 NODE_NAME=etcd3 +# master node(s) [kube-master] -192.168.1.2 -192.168.1.3 - -[kube-node] 192.168.1.1 +192.168.1.2 + +# work node(s) +[kube-node] +192.168.1.3 192.168.1.4 -# set 'NEW_INSTALL': 'yes' to install a harbor server; 'no' to integrate with existed one -# if not using domian,set 'HARBOR_DOMAIN=""' +# [optional] harbor server, a private docker registry +# 'NEW_INSTALL': 'yes' to install a harbor server; 'no' to integrate with existed one [harbor] #192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no +# [optional] loadbalance for accessing k8s from outside +[ex-lb] +#192.168.1.6 LB_ROLE=backup EX_APISERVER_VIP=192.168.1.250 +#192.168.1.7 LB_ROLE=master EX_APISERVER_VIP=192.168.1.250 + +# [optional] ntp server for cluster +[chrony] +#192.168.1.1 + [all:vars] # --------- Main Variables --------------- -# Cluster Deployment Mode: allinone, single-master, multi-master -DEPLOY_MODE=multi-master - -# use loadballance service by the Cloud Providor, no 'lb' nodes needed -# cloud loadballance service: listen on tcp 8443, with kube-masters(apiservers) as backend servers -MASTER_IP="192.168.1.10" -KUBE_APISERVER="https://{{ MASTER_IP }}:8443" - # Cluster container-runtime supported: docker, containerd CONTAINER_RUNTIME="docker" @@ -48,12 +46,6 @@ CLUSTER_CIDR="172.20.0.0/16" # NodePort Range NODE_PORT_RANGE="20000-40000" -# Kubernetes SVC IP (usually assigned with the first available IP of 'SERVICE_CIDR') -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# Cluster DNS Server's IP (assigned with an available IP of 'SERVICE_CIDR') -CLUSTER_DNS_SVC_IP="10.68.0.2" - # Cluster DNS Domain CLUSTER_DNS_DOMAIN="cluster.local." diff --git a/example/hosts.s-master.example b/example/hosts.s-master.example deleted file mode 100644 index 846d48d..0000000 --- a/example/hosts.s-master.example +++ /dev/null @@ -1,68 +0,0 @@ -# 集群部署节点:一般为运行ansible 脚本的节点 -# 变量 NTP_ENABLED (=yes/no) 设置集群是否安装 chrony 时间同步 -[deploy] -192.168.1.1 NTP_ENABLED=no - -# etcd集群请提供如下NODE_NAME,请注意etcd集群必须是1,3,5,7...奇数个节点 -[etcd] -192.168.1.1 NODE_NAME=etcd1 - -[kube-master] -192.168.1.1 - -[kube-node] -192.168.1.2 -192.168.1.3 - -# 参数 NEW_INSTALL:yes表示新建,no表示使用已有harbor服务器 -# 如果不使用域名,可以设置 HARBOR_DOMAIN="" -[harbor] -#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no - -#【可选】外部负载均衡,用于自有环境负载转发 NodePort 暴露的服务等 -[ex-lb] -#192.168.1.6 LB_ROLE=backup EX_VIP=192.168.1.250 -#192.168.1.7 LB_ROLE=master EX_VIP=192.168.1.250 - -[all:vars] -# ---------集群主要参数--------------- -#集群部署模式:allinone, single-master, multi-master -DEPLOY_MODE=single-master - -#集群 MASTER IP,自动生成 -MASTER_IP="{{ groups['kube-master'][0] }}" -KUBE_APISERVER="https://{{ MASTER_IP }}:6443" - -# 集群容器运行时,支持 docker, containerd -CONTAINER_RUNTIME="docker" - -# 集群网络插件,目前支持calico, flannel, kube-router, cilium, kube-ovn -CLUSTER_NETWORK="flannel" - -# 服务网段 (Service CIDR),注意不要与内网已有网段冲突 -SERVICE_CIDR="10.68.0.0/16" - -# POD 网段 (Cluster CIDR),注意不要与内网已有网段冲突 -CLUSTER_CIDR="172.20.0.0/16" - -# 服务端口范围 (NodePort Range) -NODE_PORT_RANGE="20000-40000" - -# kubernetes 服务 IP (预分配,一般是 SERVICE_CIDR 中第一个IP) -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# 集群 DNS 服务 IP (从 SERVICE_CIDR 中预分配) -CLUSTER_DNS_SVC_IP="10.68.0.2" - -# 集群 DNS 域名 -CLUSTER_DNS_DOMAIN="cluster.local." - -# ---------附加参数-------------------- -#默认二进制文件目录 -bin_dir="/opt/kube/bin" - -#证书目录 -ca_dir="/etc/kubernetes/ssl" - -#部署目录,即 ansible 工作目录 -base_dir="/etc/ansible" diff --git a/example/hosts.s-master.example.en b/example/hosts.s-master.example.en deleted file mode 100644 index 155ea2e..0000000 --- a/example/hosts.s-master.example.en +++ /dev/null @@ -1,69 +0,0 @@ -# 'deploy' node, which the ansible-playbooks usually run on -# variable 'NTP_ENABLED(=yes/no)' enables/disables the NTP server 'chrony' -[deploy] -192.168.1.1 NTP_ENABLED=no - -# 'etcd' cluster must have odd member(s) (1,3,5,...) -# variable 'NODE_NAME' is the distinct name of a member in 'etcd' cluster -[etcd] -192.168.1.1 NODE_NAME=etcd1 - -[kube-master] -192.168.1.1 - -[kube-node] -192.168.1.2 -192.168.1.3 - -# set 'NEW_INSTALL': 'yes' to install a harbor server; 'no' to integrate with existed one -# if not using domian,set 'HARBOR_DOMAIN=""' -[harbor] -#192.168.1.8 HARBOR_DOMAIN="harbor.yourdomain.com" NEW_INSTALL=no - -# [optional] loadbalance for services with type 'NodePort' -[ex-lb] -#192.168.1.6 LB_ROLE=backup EX_VIP=192.168.1.250 -#192.168.1.7 LB_ROLE=master EX_VIP=192.168.1.250 - -[all:vars] -# --------- Main Variables --------------- -# Cluster Deployment Mode: allinone, single-master, multi-master -DEPLOY_MODE=single-master - -# Cluster's Master IP, auto generated -MASTER_IP="{{ groups['kube-master'][0] }}" -KUBE_APISERVER="https://{{ MASTER_IP }}:6443" - -# Cluster container-runtime supported: docker, containerd -CONTAINER_RUNTIME="docker" - -# Network plugins supported: calico, flannel, kube-router, cilium, kube-ovn -CLUSTER_NETWORK="flannel" - -# 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="172.20.0.0/16" - -# NodePort Range -NODE_PORT_RANGE="20000-40000" - -# Kubernetes SVC IP (usually assigned with the first available IP of 'SERVICE_CIDR') -CLUSTER_KUBERNETES_SVC_IP="10.68.0.1" - -# Cluster DNS Server's IP (assigned with an available IP of 'SERVICE_CIDR') -CLUSTER_DNS_SVC_IP="10.68.0.2" - -# Cluster DNS Domain -CLUSTER_DNS_DOMAIN="cluster.local." - -# -------- Additional Variables -------------------- -# Binaries Directory -bin_dir="/opt/kube/bin" - -# CA and other components cert/key Directory -ca_dir="/etc/kubernetes/ssl" - -# Deploy Directory (kubeasz workspace), don't change the default value right now -base_dir="/etc/ansible" diff --git a/roles/cluster-addon/tasks/main.yml b/roles/cluster-addon/tasks/main.yml index 0f04b91..5140645 100644 --- a/roles/cluster-addon/tasks/main.yml +++ b/roles/cluster-addon/tasks/main.yml @@ -3,6 +3,14 @@ with_items: - /opt/kube/kube-system +# 设置 dns svc ip (这里选用 SERVICE_CIDR 中第2个IP) +- name: 注册变量 DNS_SVC_IP + shell: echo {{ SERVICE_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+2}' + register: DNS_SVC_IP + +- name: 设置变量 CLUSTER_DNS_SVC_IP + set_fact: CLUSTER_DNS_SVC_IP={{ DNS_SVC_IP.stdout }} + # DNS文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数 - name: 准备 DNS的部署文件 template: src={{ item }}.yaml.j2 dest=/opt/kube/kube-system/{{ item }}.yaml diff --git a/roles/kube-master/tasks/main.yml b/roles/kube-master/tasks/main.yml index 30c24be..d4f1cbc 100644 --- a/roles/kube-master/tasks/main.yml +++ b/roles/kube-master/tasks/main.yml @@ -6,6 +6,14 @@ - kube-scheduler tags: upgrade_k8s +# 设置 kubernetes svc ip (一般是 SERVICE_CIDR 中第一个IP) +- name: 注册变量 KUBERNETES_SVC_IP + shell: echo {{ SERVICE_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+1}' + register: KUBERNETES_SVC_IP + +- name: 设置变量 CLUSTER_KUBERNETES_SVC_IP + set_fact: CLUSTER_KUBERNETES_SVC_IP={{ KUBERNETES_SVC_IP.stdout }} + - name: 创建 kubernetes 证书签名请求 template: src=kubernetes-csr.json.j2 dest={{ ca_dir }}/kubernetes-csr.json tags: change_cert diff --git a/roles/kube-node/tasks/main.yml b/roles/kube-node/tasks/main.yml index 84209fa..30530ad 100644 --- a/roles/kube-node/tasks/main.yml +++ b/roles/kube-node/tasks/main.yml @@ -76,6 +76,14 @@ - name: 准备 cni配置文件 template: src=cni-default.conf.j2 dest=/etc/cni/net.d/10-default.conf +# 设置 dns svc ip (这里选用 SERVICE_CIDR 中第2个IP) +- name: 注册变量 DNS_SVC_IP + shell: echo {{ SERVICE_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+2}' + register: DNS_SVC_IP + +- name: 设置变量 CLUSTER_DNS_SVC_IP + set_fact: CLUSTER_DNS_SVC_IP={{ DNS_SVC_IP.stdout }} + - name: 创建kubelet的systemd unit文件 template: src=kubelet.service.j2 dest=/etc/systemd/system/kubelet.service tags: upgrade_k8s, restart_node