You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

460 lines
18 KiB

6 years ago
6 years ago
  1. ---
  2. # Use proxycommand if bastion host is in group all
  3. # This change obseletes editing ansible.cfg file depending on bastion existance
  4. ansible_ssh_common_args: "{% if 'bastion' in groups['all'] %} -o ProxyCommand='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -W %h:%p {{ hostvars['bastion']['ansible_user'] }}@{{ hostvars['bastion']['ansible_host'] }} {% if ansible_ssh_private_key_file is defined %}-i {{ ansible_ssh_private_key_file }}{% endif %} ' {% endif %}"
  5. kube_api_anonymous_auth: false
  6. # Default value, but will be set to true automatically if detected
  7. is_atomic: false
  8. # optional disable the swap
  9. disable_swap: true
  10. ## Change this to use another Kubernetes version, e.g. a current beta release
  11. kube_version: v1.12.2
  12. ## Kube Proxy mode One of ['iptables','ipvs']
  13. kube_proxy_mode: iptables
  14. # Kube-proxy nodeport address.
  15. # cidr to bind nodeport services. Flag --nodeport-addresses on kube-proxy manifest
  16. kube_proxy_nodeport_addresses: false
  17. # kube_proxy_nodeport_addresses_cidr: 10.0.1.0/24
  18. # Set to true to allow pre-checks to fail and continue deployment
  19. ignore_assert_errors: false
  20. # nginx-proxy configure
  21. nginx_config_dir: "/etc/nginx"
  22. # Directory where the binaries will be installed
  23. bin_dir: /usr/local/bin
  24. docker_bin_dir: /usr/bin
  25. etcd_data_dir: /var/lib/etcd
  26. # Where the binaries will be downloaded.
  27. # Note: ensure that you've enough disk space (about 1G)
  28. local_release_dir: "/tmp/releases"
  29. # Random shifts for retrying failed ops like pushing/downloading
  30. retry_stagger: 5
  31. # DNS configuration.
  32. # Kubernetes cluster name, also will be used as DNS domain
  33. cluster_name: cluster.local
  34. # Subdomains of DNS domain to be resolved via /etc/resolv.conf for hostnet pods
  35. ndots: 2
  36. # Can be dnsmasq_kubedns, kubedns, manual or none
  37. dns_mode: kubedns
  38. # Should be set to a cluster IP if using a custom cluster DNS
  39. # manual_dns_server: 10.x.x.x
  40. # Can be docker_dns, host_resolvconf or none
  41. resolvconf_mode: docker_dns
  42. # Deploy netchecker app to verify DNS resolve as an HTTP service
  43. deploy_netchecker: false
  44. # Ip address of the kubernetes skydns service
  45. skydns_server: "{{ kube_service_addresses|ipaddr('net')|ipaddr(3)|ipaddr('address') }}"
  46. skydns_server_secondary: "{{ kube_service_addresses|ipaddr('net')|ipaddr(4)|ipaddr('address') }}"
  47. dnsmasq_dns_server: "{{ kube_service_addresses|ipaddr('net')|ipaddr(2)|ipaddr('address') }}"
  48. dns_domain: "{{ cluster_name }}"
  49. kube_dns_servers:
  50. kubedns: ["{{skydns_server}}"]
  51. coredns: ["{{skydns_server}}"]
  52. coredns_dual: "{{[skydns_server] + [ skydns_server_secondary ]}}"
  53. manual: ["{{manual_dns_server}}"]
  54. dnsmasq_kubedns: ["{{dnsmasq_dns_server}}"]
  55. dns_servers: "{{kube_dns_servers[dns_mode]}}"
  56. # Kubernetes configuration dirs and system namespace.
  57. # Those are where all the additional config stuff goes
  58. # the kubernetes normally puts in /srv/kubernetes.
  59. # This puts them in a sane location and namespace.
  60. # Editing those values will almost surely break something.
  61. kube_config_dir: /etc/kubernetes
  62. kube_script_dir: "{{ bin_dir }}/kubernetes-scripts"
  63. kube_manifest_dir: "{{ kube_config_dir }}/manifests"
  64. # This is where all the cert scripts and certs will be located
  65. kube_cert_dir: "{{ kube_config_dir }}/ssl"
  66. # This is where all of the bearer tokens will be stored
  67. kube_token_dir: "{{ kube_config_dir }}/tokens"
  68. # This is where to save basic auth file
  69. kube_users_dir: "{{ kube_config_dir }}/users"
  70. # This is the group that the cert creation scripts chgrp the
  71. # cert files to. Not really changeable...
  72. kube_cert_group: kube-cert
  73. # Cluster Loglevel configuration
  74. kube_log_level: 2
  75. # Users to create for basic auth in Kubernetes API via HTTP
  76. kube_api_pwd: "changeme"
  77. kube_users:
  78. kube:
  79. pass: "{{kube_api_pwd}}"
  80. role: admin
  81. # Choose network plugin (cilium, calico, weave or flannel)
  82. # Can also be set to 'cloud', which lets the cloud provider setup appropriate routing
  83. kube_network_plugin: calico
  84. kube_network_plugin_multus: false
  85. # Determines if calico-rr group exists
  86. peer_with_calico_rr: "{{ 'calico-rr' in groups and groups['calico-rr']|length > 0 }}"
  87. # Set to false to disable calico-upgrade
  88. calico_upgrade_enabled: true
  89. # Kubernetes internal network for services, unused block of space.
  90. kube_service_addresses: 10.233.0.0/18
  91. # internal network. When used, it will assign IP
  92. # addresses from this range to individual pods.
  93. # This network must be unused in your network infrastructure!
  94. kube_pods_subnet: 10.233.64.0/18
  95. # internal network node size allocation (optional). This is the size allocated
  96. # to each node on your network. With these defaults you should have
  97. # room for 64 nodes with 254 pods per node.
  98. # Example: Up to 256 nodes, 100 pods per node (/16 network):
  99. # - kube_service_addresses: 10.233.0.0/17
  100. # - kube_pods_subnet: 10.233.128.0/17
  101. # - kube_network_node_prefix: 25
  102. # Example: Up to 4096 nodes, 100 pods per node (/12 network):
  103. # - kube_service_addresses: 10.192.0.0/13
  104. # - kube_pods_subnet: 10.200.0.0/13
  105. # - kube_network_node_prefix: 25
  106. kube_network_node_prefix: 24
  107. # The virtual cluster IP, real host IPs and ports the API Server will be
  108. # listening on.
  109. # NOTE: loadbalancer_apiserver_localhost somewhat alters the final API enpdoint
  110. # access IP value (automatically evaluated below)
  111. kube_apiserver_ip: "{{ kube_service_addresses|ipaddr('net')|ipaddr(1)|ipaddr('address') }}"
  112. kube_apiserver_bind_address: 0.0.0.0
  113. # https
  114. kube_apiserver_port: 6443
  115. # http
  116. kube_apiserver_insecure_bind_address: 127.0.0.1
  117. kube_apiserver_insecure_port: 8080
  118. # dynamic kubelet configuration
  119. dynamic_kubelet_configuration: false
  120. # define kubelet config dir for dynamic kubelet
  121. # kubelet_config_dir:
  122. default_kubelet_config_dir: "{{ kube_config_dir }}/dynamic_kubelet_dir"
  123. dynamic_kubelet_configuration_dir: "{{ kubelet_config_dir | default(default_kubelet_config_dir) }}"
  124. # Aggregator
  125. kube_api_aggregator_routing: false
  126. # Profiling
  127. kube_profiling: false
  128. # Container for runtime
  129. container_manager: docker
  130. ## Uncomment this if you want to force overlay/overlay2 as docker storage driver
  131. ## Please note that overlay2 is only supported on newer kernels
  132. # docker_storage_options: -s overlay2
  133. ## Enable docker_container_storage_setup, it will configure devicemapper driver on Centos7 or RedHat7.
  134. docker_container_storage_setup: false
  135. ## It must be define a disk path for docker_container_storage_setup_devs.
  136. ## Otherwise docker-storage-setup will be executed incorrectly.
  137. # docker_container_storage_setup_devs: /dev/vdb
  138. ## Uncomment this if you have more than 3 nameservers, then we'll only use the first 3.
  139. docker_dns_servers_strict: false
  140. # Path used to store Docker data
  141. docker_daemon_graph: "/var/lib/docker"
  142. ## Used to set docker daemon iptables options to true
  143. docker_iptables_enabled: "false"
  144. # Docker log options
  145. # Rotate container stderr/stdout logs at 50m and keep last 5
  146. docker_log_opts: "--log-opt max-size=50m --log-opt max-file=5"
  147. ## An obvious use case is allowing insecure-registry access to self hosted registries.
  148. ## Can be ipaddress and domain_name.
  149. ## example define 172.19.16.11 or mirror.registry.io
  150. # docker_insecure_registries:
  151. # - mirror.registry.io
  152. # - 172.19.16.11
  153. ## Add other registry,example China registry mirror.
  154. # docker_registry_mirrors:
  155. # - https://registry.docker-cn.com
  156. # - https://mirror.aliyuncs.com
  157. ## If non-empty will override default system MounFlags value.
  158. ## This option takes a mount propagation flag: shared, slave
  159. ## or private, which control whether mounts in the file system
  160. ## namespace set up for docker will receive or propagate mounts
  161. ## and unmounts. Leave empty for system default
  162. # docker_mount_flags:
  163. ## A string of extra options to pass to the docker daemon.
  164. ## This string should be exactly as you wish it to appear.
  165. docker_options: >-
  166. {%- if docker_insecure_registries is defined -%}
  167. {{ docker_insecure_registries | map('regex_replace', '^(.*)$', '--insecure-registry=\1' ) | list | join(' ') }}
  168. {%- endif %}
  169. {% if docker_registry_mirrors is defined -%}
  170. {{ docker_registry_mirrors | map('regex_replace', '^(.*)$', '--registry-mirror=\1' ) | list | join(' ') }}
  171. {%- endif %}
  172. --graph={{ docker_daemon_graph }} {{ docker_log_opts }}
  173. {%- if ansible_architecture == "aarch64" and ansible_os_family == "RedHat" %}
  174. --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current
  175. --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd
  176. --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --signature-verification=false
  177. {%- endif -%}
  178. # Settings for containerized control plane (etcd/kubelet/secrets)
  179. etcd_deployment_type: docker
  180. kubelet_deployment_type: docker
  181. cert_management: script
  182. helm_deployment_type: host
  183. # Enable kubeadm deployment (experimental)
  184. kubeadm_enabled: false
  185. # Make a copy of kubeconfig on the host that runs Ansible in {{ inventory_dir }}/artifacts
  186. kubeconfig_localhost: false
  187. # Download kubectl onto the host that runs Ansible in {{ bin_dir }}
  188. kubectl_localhost: false
  189. # Define credentials_dir here so it can be overridden
  190. credentials_dir: "{{ inventory_dir }}/credentials"
  191. # K8s image pull policy (imagePullPolicy)
  192. k8s_image_pull_policy: IfNotPresent
  193. # Kubernetes dashboard
  194. # RBAC required. see docs/getting-started.md for access details.
  195. dashboard_enabled: true
  196. # Addons which can be enabled
  197. helm_enabled: false
  198. registry_enabled: false
  199. enable_network_policy: true
  200. local_volume_provisioner_enabled: "{{ local_volumes_enabled | default('false') }}"
  201. persistent_volumes_enabled: false
  202. cephfs_provisioner_enabled: false
  203. ingress_nginx_enabled: false
  204. cert_manager_enabled: false
  205. ## When OpenStack is used, Cinder version can be explicitly specified if autodetection fails (Fixed in 1.9: https://github.com/kubernetes/kubernetes/issues/50461)
  206. # openstack_blockstorage_version: "v1/v2/auto (default)"
  207. openstack_blockstorage_ignore_volume_az: "{{ volume_cross_zone_attachment | default('false') }}"
  208. ## When OpenStack is used, if LBaaSv2 is available you can enable it with the following 2 variables.
  209. openstack_lbaas_enabled: false
  210. # openstack_lbaas_subnet_id: "Neutron subnet ID (not network ID) to create LBaaS VIP"
  211. ## To enable automatic floating ip provisioning, specify a subnet.
  212. # openstack_lbaas_floating_network_id: "Neutron network ID (not subnet ID) to get floating IP from, disabled by default"
  213. ## Override default LBaaS behavior
  214. # openstack_lbaas_use_octavia: False
  215. # openstack_lbaas_method: "ROUND_ROBIN"
  216. # openstack_lbaas_provider: "haproxy"
  217. openstack_lbaas_create_monitor: "yes"
  218. openstack_lbaas_monitor_delay: "1m"
  219. openstack_lbaas_monitor_timeout: "30s"
  220. openstack_lbaas_monitor_max_retries: "3"
  221. openstack_cacert: "{{ lookup('env','OS_CACERT') }}"
  222. ## List of authorization modes that must be configured for
  223. ## the k8s cluster. Only 'AlwaysAllow', 'AlwaysDeny', 'Node' and
  224. ## 'RBAC' modes are tested. Order is important.
  225. authorization_modes: ['Node', 'RBAC']
  226. rbac_enabled: "{{ 'RBAC' in authorization_modes or kubeadm_enabled }}"
  227. # When enabled, API bearer tokens (including service account tokens) can be used to authenticate to the kubelet’s HTTPS endpoint
  228. kubelet_authentication_token_webhook: true
  229. # When enabled, access to the kubelet API requires authorization by delegation to the API server
  230. kubelet_authorization_mode_webhook: false
  231. ## v1.11 feature
  232. feature_gate_v1_11:
  233. - "PersistentLocalVolumes={{ local_volume_provisioner_enabled | string }}"
  234. - "VolumeScheduling={{ local_volume_provisioner_enabled | string }}"
  235. - "MountPropagation={{ local_volume_provisioner_enabled | string }}"
  236. ## v1.12 feature
  237. feature_gate_v1_12: []
  238. ## List of key=value pairs that describe feature gates for
  239. ## the k8s cluster.
  240. kube_feature_gates: |-
  241. {%- if kube_version is version('v1.12.0', '<') -%}
  242. {{ feature_gate_v1_11 }}
  243. {%- else -%}
  244. {{ feature_gate_v1_12 }}
  245. {%- endif %}
  246. # Local volume provisioner storage classes
  247. local_volume_provisioner_storage_classes:
  248. - name: "{{ local_volume_provisioner_storage_class | default('local-storage') }}"
  249. host_dir: "{{ local_volume_provisioner_base_dir | default ('/mnt/disks') }}"
  250. mount_dir: "{{ local_volume_provisioner_mount_dir | default('/mnt/disks') }}"
  251. # weave's network password for encryption
  252. # if null then no network encryption
  253. # you can use --extra-vars to pass the password in command line
  254. weave_password: EnterPasswordHere
  255. # Weave uses consensus mode by default
  256. # Enabling seed mode allow to dynamically add or remove hosts
  257. # https://www.weave.works/docs/net/latest/ipam/
  258. weave_mode_seed: false
  259. # This two variable are automatically changed by the weave's role in group_vars/k8s-cluster.yml.
  260. # Do not manually change these values
  261. weave_seed: uninitialized
  262. weave_peers: uninitialized
  263. # Contiv L3 BGP Mode
  264. contiv_peer_with_uplink_leaf: false
  265. contiv_global_as: "65002"
  266. contiv_global_neighbor_as: "500"
  267. ## Set no_proxy to all assigned cluster IPs and hostnames
  268. no_proxy: >-
  269. {%- if http_proxy is defined or https_proxy is defined %}
  270. {%- if loadbalancer_apiserver is defined -%}
  271. {{ apiserver_loadbalancer_domain_name| default('') }},
  272. {{ loadbalancer_apiserver.address | default('') }},
  273. {%- endif -%}
  274. {%- for item in (groups['k8s-cluster'] + groups['etcd'] + groups['calico-rr']|default([]))|unique -%}
  275. {{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item]['ansible_default_ipv4']['address'])) }},
  276. {%- if (item != hostvars[item]['ansible_hostname']) -%}
  277. {{ hostvars[item]['ansible_hostname'] }},
  278. {{ hostvars[item]['ansible_hostname'] }}.{{ dns_domain }},
  279. {%- endif -%}
  280. {{ item }},{{ item }}.{{ dns_domain }},
  281. {%- endfor -%}
  282. {%- if additional_no_proxy is defined -%}
  283. {{ additional_no_proxy }},
  284. {%- endif -%}
  285. 127.0.0.1,localhost
  286. {%- endif %}
  287. proxy_env:
  288. http_proxy: "{{ http_proxy| default ('') }}"
  289. https_proxy: "{{ https_proxy| default ('') }}"
  290. no_proxy: "{{ no_proxy| default ('') }}"
  291. ssl_ca_dirs: >-
  292. [
  293. {% if ansible_os_family in ['CoreOS', 'Container Linux by CoreOS'] -%}
  294. '/usr/share/ca-certificates',
  295. {% elif ansible_os_family == 'RedHat' -%}
  296. '/etc/pki/tls',
  297. '/etc/pki/ca-trust',
  298. {% elif ansible_os_family == 'Debian' -%}
  299. '/usr/share/ca-certificates',
  300. {% endif -%}
  301. ]
  302. # Vars for pointing to kubernetes api endpoints
  303. is_kube_master: "{{ inventory_hostname in groups['kube-master'] }}"
  304. kube_apiserver_count: "{{ groups['kube-master'] | length }}"
  305. kube_apiserver_address: "{{ ip | default(ansible_default_ipv4['address']) }}"
  306. kube_apiserver_access_address: "{{ access_ip | default(kube_apiserver_address) }}"
  307. first_kube_master: "{{ hostvars[groups['kube-master'][0]]['access_ip'] | default(hostvars[groups['kube-master'][0]]['ip'] | default(hostvars[groups['kube-master'][0]]['ansible_default_ipv4']['address'])) }}"
  308. loadbalancer_apiserver_localhost: "{{ loadbalancer_apiserver is not defined }}"
  309. # applied if only external loadbalancer_apiserver is defined, otherwise ignored
  310. apiserver_loadbalancer_domain_name: "lb-apiserver.kubernetes.local"
  311. kube_apiserver_endpoint: |-
  312. {% if not is_kube_master and loadbalancer_apiserver_localhost -%}
  313. https://localhost:{{ nginx_kube_apiserver_port|default(kube_apiserver_port) }}
  314. {%- elif is_kube_master -%}
  315. https://{{ kube_apiserver_bind_address | regex_replace('0\.0\.0\.0','127.0.0.1') }}:{{ kube_apiserver_port }}
  316. {%- else -%}
  317. {%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.port is defined -%}
  318. https://{{ apiserver_loadbalancer_domain_name|default('lb-apiserver.kubernetes.local') }}:{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
  319. {%- else -%}
  320. https://{{ first_kube_master }}:{{ kube_apiserver_port }}
  321. {%- endif -%}
  322. {%- endif %}
  323. kube_apiserver_insecure_endpoint: >-
  324. http://{{ kube_apiserver_insecure_bind_address | regex_replace('0\.0\.0\.0','127.0.0.1') }}:{{ kube_apiserver_insecure_port }}
  325. kube_apiserver_client_cert: |-
  326. {% if kubeadm_enabled -%}
  327. {{ kube_cert_dir }}/ca.crt
  328. {%- else -%}
  329. {{ kube_cert_dir }}/apiserver.pem
  330. {%- endif %}
  331. kube_apiserver_client_key: |-
  332. {% if kubeadm_enabled -%}
  333. {{ kube_cert_dir }}/ca.key
  334. {%- else -%}
  335. {{ kube_cert_dir }}/apiserver-key.pem
  336. {%- endif %}
  337. # Set to true to deploy etcd-events cluster
  338. etcd_events_cluster_enabled: false
  339. # Vars for pointing to etcd endpoints
  340. is_etcd_master: "{{ inventory_hostname in groups['etcd'] }}"
  341. etcd_address: "{{ ip | default(ansible_default_ipv4['address']) }}"
  342. etcd_access_address: "{{ access_ip | default(etcd_address) }}"
  343. etcd_events_access_address: "{{ access_ip | default(etcd_address) }}"
  344. etcd_peer_url: "https://{{ etcd_access_address }}:2380"
  345. etcd_client_url: "https://{{ etcd_access_address }}:2379"
  346. etcd_events_peer_url: "https://{{ etcd_events_access_address }}:2382"
  347. etcd_events_client_url: "https://{{ etcd_events_access_address }}:2381"
  348. etcd_access_addresses: |-
  349. {% for item in groups['etcd'] -%}
  350. https://{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item]['ansible_default_ipv4']['address'])) }}:2379{% if not loop.last %},{% endif %}
  351. {%- endfor %}
  352. etcd_events_access_addresses_list: |-
  353. [
  354. {% for item in groups['etcd'] -%}
  355. 'https://{{ hostvars[item]['access_ip'] | default(hostvars[item]['ip'] | default(hostvars[item]['ansible_default_ipv4']['address'])) }}:2381'{% if not loop.last %},{% endif %}
  356. {%- endfor %}
  357. ]
  358. etcd_events_access_addresses: "{{etcd_events_access_addresses_list | join(',')}}"
  359. etcd_events_access_addresses_semicolon: "{{etcd_events_access_addresses_list | join(';')}}"
  360. # user should set etcd_member_name in inventory/mycluster/hosts.ini
  361. etcd_member_name: |-
  362. {% for host in groups['etcd'] %}
  363. {% if inventory_hostname == host %}{{ hostvars[host].etcd_member_name | default("etcd" + loop.index|string) }}{% endif %}
  364. {% endfor %}
  365. etcd_peer_addresses: |-
  366. {% for item in groups['etcd'] -%}
  367. {{ hostvars[item].etcd_member_name | default("etcd" + loop.index|string) }}=https://{{ hostvars[item].access_ip | default(hostvars[item].ip | default(hostvars[item].ansible_default_ipv4['address'])) }}:2380{% if not loop.last %},{% endif %}
  368. {%- endfor %}
  369. etcd_events_peer_addresses: |-
  370. {% for item in groups['etcd'] -%}
  371. {{ hostvars[item].etcd_member_name | default("etcd" + loop.index|string) }}-events=https://{{ hostvars[item].access_ip | default(hostvars[item].ip | default(hostvars[item].ansible_default_ipv4['address'])) }}:2382{% if not loop.last %},{% endif %}
  372. {%- endfor %}
  373. podsecuritypolicy_enabled: false
  374. etcd_heartbeat_interval: "250"
  375. etcd_election_timeout: "5000"
  376. etcd_snapshot_count: "10000"
  377. certificates_key_size: 2048
  378. certificates_duration: 36500
  379. pip_extra_args: |-
  380. {%- set pip_extra_args_list = [] -%}
  381. {%- if pyrepo_index is defined -%}
  382. {%- set DO = pip_extra_args_list.append('--index-url %s' | format(pyrepo_index)) -%}
  383. {%- if pyrepo_cert is defined -%}
  384. {%- set DO = pip_extra_args_list.append('--cert %s' | format(pyrepo_cert)) -%}
  385. {%- endif -%}
  386. {%- endif -%}
  387. {{ pip_extra_args_list|join(' ') }}