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.

124 lines
4.8 KiB

  1. HA endpoints for K8s
  2. ====================
  3. The following components require a highly available endpoints:
  4. * etcd cluster,
  5. * kube-apiserver service instances.
  6. The former provides the
  7. [etcd-proxy](https://coreos.com/etcd/docs/latest/proxy.html) service to access
  8. the cluster members in HA fashion.
  9. The latter relies on a 3rd side reverse proxies, like Nginx or HAProxy, to
  10. achieve the same goal.
  11. Etcd
  12. ----
  13. Etcd proxies are deployed on each node in the `k8s-cluster` group. A proxy is
  14. a separate etcd process. It has a `localhost:2379` frontend and all of the etcd
  15. cluster members as backends. Note that the `access_ip` is used as the backend
  16. IP, if specified. Frontend endpoints cannot be accessed externally as they are
  17. bound to a localhost only.
  18. The `etcd_access_endpoint` fact provides an access pattern for clients. And the
  19. `etcd_multiaccess` (defaults to `false`) group var controlls that behavior.
  20. When enabled, it makes deployed components to access the etcd cluster members
  21. directly: `http://ip1:2379, http://ip2:2379,...`. This mode assumes the clients
  22. do a loadbalancing and handle HA for connections. Note, a pod definition of a
  23. flannel networking plugin always uses a single `--etcd-server` endpoint!
  24. Kube-apiserver
  25. --------------
  26. K8s components require a loadbalancer to access the apiservers via a reverse
  27. proxy. A kube-proxy does not support multiple apiservers for the time being so
  28. you will need to configure your own loadbalancer to achieve HA. Note that
  29. deploying a loadbalancer is up to a user and is not covered by ansible roles
  30. in Kargo. By default, it only configures a non-HA endpoint, which points to
  31. the `access_ip` or IP address of the first server node in the `kube-master`
  32. group. It can also configure clients to use endpoints for a given loadbalancer
  33. type.
  34. A loadbalancer (LB) may be an external or internal one. An external LB
  35. provides access for external clients, while the internal LB accepts client
  36. connections only to the localhost, similarly to the etcd-proxy HA endpoints.
  37. Given a frontend `VIP` address and `IP1, IP2` addresses of backends, here is
  38. an example configuration for a HAProxy service acting as an external LB:
  39. ```
  40. listen kubernetes-apiserver-https
  41. bind <VIP>:8383
  42. option ssl-hello-chk
  43. mode tcp
  44. timeout client 3h
  45. timeout server 3h
  46. server master1 <IP1>:443
  47. server master2 <IP2>:443
  48. balance roundrobin
  49. ```
  50. And the corresponding example global vars config:
  51. ```
  52. apiserver_loadbalancer_domain_name: "lb-apiserver.kubernetes.local"
  53. loadbalancer_apiserver:
  54. address: <VIP>
  55. port: 8383
  56. ```
  57. This domain name, or default "lb-apiserver.kubernetes.local", will be inserted
  58. into the `/etc/hosts` file of all servers in the `k8s-cluster` group. Note that
  59. the HAProxy service should as well be HA and requires a VIP management, which
  60. is out of scope of this doc.
  61. The internal LB may be the case if you do not want to operate a VIP management
  62. HA stack and require no external and no secure access to the K8s API. The group
  63. var `loadbalancer_apiserver_localhost` (defaults to `false`) controls that
  64. deployment layout. When enabled, it is expected each node in the `k8s-cluster`
  65. group to run a loadbalancer that listens the localhost frontend and has all
  66. of the apiservers as backends. Here is an example configuration for a HAProxy
  67. service acting as an internal LB:
  68. ```
  69. listen kubernetes-apiserver-http
  70. bind localhost:8080
  71. mode tcp
  72. timeout client 3h
  73. timeout server 3h
  74. server master1 <IP1>:8080
  75. server master2 <IP2>:8080
  76. balance leastconn
  77. ```
  78. And the corresponding example global vars config:
  79. ```
  80. loadbalancer_apiserver_localhost: true
  81. ```
  82. This var overrides an external LB configuration, if any. Note that for this
  83. example, the `kubernetes-apiserver-http` endpoint has backends receiving
  84. unencrypted traffic, which may be a security issue when interconnecting
  85. different nodes, or may be not, if those belong to the isolated management
  86. network without external access.
  87. In order to achieve HA for HAProxy instances, those must be running on the
  88. each node in the `k8s-cluster` group as well, but require no VIP, thus
  89. no VIP management.
  90. Access endpoints are evaluated automagically, as the following:
  91. | Endpoint type | kube-master | non-master |
  92. |------------------------------|---------------|---------------------|
  93. | Local LB (overrides ext) | http://lc:p | http://lc:p |
  94. | External LB, no internal | https://lb:lp | https://lb:lp |
  95. | No ext/int LB (default) | http://lc:p | https://m[0].aip:sp |
  96. Where:
  97. * `m[0]` - the first node in the `kube-master` group;
  98. * `lb` - LB FQDN, `apiserver_loadbalancer_domain_name`;
  99. * `lc` - localhost;
  100. * `p` - insecure port, `kube_apiserver_insecure_port`
  101. * `sp` - secure port, `kube_apiserver_port`;
  102. * `lp` - LB port, `loadbalancer_apiserver.port`, defers to the secure port;
  103. * `ip` - the node IP, defers to the ansible IP;
  104. * `aip` - `access_ip`, defers to the ip.