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.

106 lines
4.6 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 latter relies on a 3rd side reverse proxies, like Nginx or HAProxy, to
  7. achieve the same goal.
  8. Etcd
  9. ----
  10. The `etcd_access_endpoint` fact provides an access pattern for clients. And the
  11. `etcd_multiaccess` (defaults to `True`) group var controlls that behavior.
  12. It makes deployed components to access the etcd cluster members
  13. directly: `http://ip1:2379, http://ip2:2379,...`. This mode assumes the clients
  14. do a loadbalancing and handle HA for connections. Note, a pod definition of a
  15. flannel networking plugin always uses a single `--etcd-server` endpoint!
  16. Kube-apiserver
  17. --------------
  18. K8s components require a loadbalancer to access the apiservers via a reverse
  19. proxy. Kargo includes support for an nginx-based proxy that resides on each
  20. non-master Kubernetes node. This is referred to as localhost loadbalancing. It
  21. is less efficient than a dedicated load balancer because it creates extra
  22. health checks on the Kubernetes apiserver, but is more practical for scenarios
  23. where an external LB or virtual IP management is inconvenient. This option is
  24. configured by the variable `loadbalancer_apiserver_localhost` (defaults to `False`).
  25. You may also define the port the local internal loadbalancer users by changing,
  26. `nginx_kube_apiserver_port`. This defaults to the value of `kube_apiserver_port`.
  27. It is also import to note that Kargo will only configure kubelet and kube-proxy
  28. on non-master nodes to use the local internal loadbalancer.
  29. If you choose to NOT use the local internal loadbalancer, you will need to configure
  30. your own loadbalancer to achieve HA. Note that deploying a loadbalancer is up to
  31. a user and is not covered by ansible roles in Kargo. By default, it only configures
  32. a non-HA endpoint, which points to the `access_ip` or IP address of the first server
  33. node in the `kube-master` group. It can also configure clients to use endpoints
  34. for a given loadbalancer type. The following diagram shows how traffic to the
  35. apiserver is directed.
  36. ![Image](figures/loadbalancer_localhost.png?raw=true)
  37. Note: Kubernetes master nodes still use insecure localhost access because
  38. there are bugs in Kubernetes <1.5.0 in using TLS auth on master role
  39. services. This makes backends receiving unencrypted traffic and may be a
  40. security issue when interconnecting different nodes, or maybe not, if those
  41. belong to the isolated management network without external access.
  42. A user may opt to use an external loadbalancer (LB) instead. An external LB
  43. provides access for external clients, while the internal LB accepts client
  44. connections only to the localhost.
  45. Given a frontend `VIP` address and `IP1, IP2` addresses of backends, here is
  46. an example configuration for a HAProxy service acting as an external LB:
  47. ```
  48. listen kubernetes-apiserver-https
  49. bind <VIP>:8383
  50. option ssl-hello-chk
  51. mode tcp
  52. timeout client 3h
  53. timeout server 3h
  54. server master1 <IP1>:443
  55. server master2 <IP2>:443
  56. balance roundrobin
  57. ```
  58. And the corresponding example global vars config:
  59. ```
  60. apiserver_loadbalancer_domain_name: "lb-apiserver.kubernetes.local"
  61. loadbalancer_apiserver:
  62. address: <VIP>
  63. port: 8383
  64. ```
  65. This domain name, or default "lb-apiserver.kubernetes.local", will be inserted
  66. into the `/etc/hosts` file of all servers in the `k8s-cluster` group. Note that
  67. the HAProxy service should as well be HA and requires a VIP management, which
  68. is out of scope of this doc. Specifying an external LB overrides any internal
  69. localhost LB configuration.
  70. Note: In order to achieve HA for HAProxy instances, those must be running on
  71. the each node in the `k8s-cluster` group as well, but require no VIP, thus
  72. no VIP management.
  73. Access endpoints are evaluated automagically, as the following:
  74. | Endpoint type | kube-master | non-master |
  75. |------------------------------|---------------|---------------------|
  76. | Local LB | http://lc:p | https://lc:nsp |
  77. | External LB, no internal | https://lb:lp | https://lb:lp |
  78. | No ext/int LB (default) | http://lc:p | https://m[0].aip:sp |
  79. Where:
  80. * `m[0]` - the first node in the `kube-master` group;
  81. * `lb` - LB FQDN, `apiserver_loadbalancer_domain_name`;
  82. * `lc` - localhost;
  83. * `p` - insecure port, `kube_apiserver_insecure_port`
  84. * `nsp` - nginx secure port, `nginx_kube_apiserver_port`;
  85. * `sp` - secure port, `kube_apiserver_port`;
  86. * `lp` - LB port, `loadbalancer_apiserver.port`, defers to the secure port;
  87. * `ip` - the node IP, defers to the ansible IP;
  88. * `aip` - `access_ip`, defers to the ip.