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.

85 lines
3.1 KiB

Support for disabling apiserver insecure port This allows `kube_apiserver_insecure_port` to be set to 0 (disabled). It's working, but so far I have had to: 1. Make the `uri` module "Wait for apiserver up" checks use `kube_apiserver_port` (HTTPS) 2. Add apiserver client cert/key to the "Wait for apiserver up" checks 3. Update apiserver liveness probe to use HTTPS ports 4. Set `kube_api_anonymous_auth` to true to allow liveness probe to hit apiserver's /healthz over HTTPS (livenessProbes can't use client cert/key unfortunately) 5. RBAC has to be enabled. Anonymous requests are in the `system:unauthenticated` group which is granted access to /healthz by one of RBAC's default ClusterRoleBindings. An equivalent ABAC rule could allow this as well. Changes 1 and 2 should work for everyone, but 3, 4, and 5 require new coupling of currently independent configuration settings. So I also added a new settings check. Options: 1. The problem goes away if you have both anonymous-auth and RBAC enabled. This is how kubeadm does it. This may be the best way to go since RBAC is already on by default but anonymous auth is not. 2. Include conditional templates to set a different liveness probe for possible combinations of `kube_apiserver_insecure_port = 0`, RBAC, and `kube_api_anonymous_auth` (won't be possible to cover every case without a guaranteed authorizer for the secure port) 3. Use basic auth headers for the liveness probe (I really don't like this, it adds a new dependency on basic auth which I'd also like to leave independently configurable, and it requires encoded passwords in the apiserver manifest) Option 1 seems like the clear winner to me, but is there a reason we wouldn't want anonymous-auth on by default? The apiserver binary defaults anonymous-auth to true, but kubespray's default was false.
7 years ago
  1. ---
  2. - name: Stop if ansible version is too low
  3. assert:
  4. that:
  5. - ansible_version.full|version_compare('2.3.0', '>=')
  6. run_once: yes
  7. - name: Stop if non systemd OS type
  8. assert:
  9. that: ansible_service_mgr == "systemd"
  10. ignore_errors: "{{ ignore_assert_errors }}"
  11. - name: Stop if unknown OS
  12. assert:
  13. that: ansible_distribution in ['RedHat', 'CentOS', 'Fedora', 'Ubuntu', 'Debian', 'CoreOS', 'Container Linux by CoreOS']
  14. ignore_errors: "{{ ignore_assert_errors }}"
  15. - name: Stop if unknown network plugin
  16. assert:
  17. that: network_plugin in ['calico', 'canal', 'flannel', 'weave', 'cloud']
  18. when: network_plugin is defined
  19. ignore_errors: "{{ ignore_assert_errors }}"
  20. - name: Stop if incompatible network plugin and cloudprovider
  21. assert:
  22. that: network_plugin != 'calico'
  23. msg: "Azure and Calico are not compatible. See https://github.com/projectcalico/calicoctl/issues/949 for details."
  24. when: cloud_provider is defined and cloud_provider == 'azure'
  25. ignore_errors: "{{ ignore_assert_errors }}"
  26. # simplify this items-list when https://github.com/ansible/ansible/issues/15753 is resolved
  27. - name: "Stop if known booleans are set as strings (Use JSON format on CLI: -e \"{'key': true }\")"
  28. assert:
  29. that: item.value|type_debug == 'bool'
  30. msg: "{{item.value}} isn't a bool"
  31. run_once: yes
  32. with_items:
  33. - { name: kubeadm_enabled, value: "{{ kubeadm_enabled }}" }
  34. - { name: download_run_once, value: "{{ download_run_once }}" }
  35. - { name: deploy_netchecker, value: "{{ deploy_netchecker }}" }
  36. - { name: download_always_pull, value: "{{ download_always_pull }}" }
  37. - { name: efk_enabled, value: "{{ efk_enabled }}" }
  38. - { name: helm_enabled, value: "{{ helm_enabled }}" }
  39. - { name: openstack_lbaas_enabled, value: "{{ openstack_lbaas_enabled }}" }
  40. - { name: rbac_enabled, value: "{{ rbac_enabled }}" }
  41. ignore_errors: "{{ ignore_assert_errors }}"
  42. - name: Stop if even number of etcd hosts
  43. assert:
  44. that: groups.etcd|length is not divisibleby 2
  45. ignore_errors: "{{ ignore_assert_errors }}"
  46. - name: Stop if memory is too small for masters
  47. assert:
  48. that: ansible_memtotal_mb >= 1500
  49. ignore_errors: "{{ ignore_assert_errors }}"
  50. when: inventory_hostname in groups['kube-master']
  51. - name: Stop if memory is too small for nodes
  52. assert:
  53. that: ansible_memtotal_mb >= 1024
  54. ignore_errors: "{{ ignore_assert_errors }}"
  55. when: inventory_hostname in groups['kube-node']
  56. - name: Stop if ip var does not match local ips
  57. assert:
  58. that: ip in ansible_all_ipv4_addresses
  59. ignore_errors: "{{ ignore_assert_errors }}"
  60. when: ip is defined
  61. - name: Stop if access_ip is not pingable
  62. command: ping -c1 {{ access_ip }}
  63. when: access_ip is defined
  64. ignore_errors: "{{ ignore_assert_errors }}"
  65. - name: Stop if swap enabled
  66. assert:
  67. that: ansible_swaptotal_mb == 0
  68. when: kubelet_fail_swap_on|default(true)
  69. ignore_errors: "{{ ignore_assert_errors }}"
  70. - name: Stop if RBAC and anonymous-auth are not enabled when insecure port is disabled
  71. assert:
  72. that: rbac_enabled and kube_api_anonymous_auth
  73. when: kube_apiserver_insecure_port == 0
  74. ignore_errors: "{{ ignore_assert_errors }}"