精简example hosts配置文件及配置项

pull/641/head
gjmzj 2019-05-29 22:49:04 +08:00
parent d17d938dfc
commit 8cf349b271
11 changed files with 54 additions and 476 deletions

View File

@ -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 domianset '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."

View File

@ -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_INSTALLyes表示新建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"

View File

@ -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_INSTALLyes表示新建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"

View File

@ -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_INSTALLyes表示新建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"

View File

@ -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 domianset '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"

View File

@ -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 domianset '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."

View File

@ -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_INSTALLyes表示新建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"

View File

@ -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 domianset '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"

View File

@ -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

View File

@ -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

View File

@ -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