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.

201 lines
6.8 KiB

  1. # Cilium
  2. ## Kube-proxy replacement with Cilium
  3. Cilium can run without kube-proxy by setting `cilium_kube_proxy_replacement`
  4. to `strict`.
  5. Without kube-proxy, cilium needs to know the address of the kube-apiserver
  6. and this must be set globally for all cilium components (agents and operators).
  7. Hence, in this configuration in Kubespray, Cilium will always contact
  8. the external loadbalancer (even from a node in the control plane)
  9. and if there is no external load balancer It will ignore any local load
  10. balancer deployed by Kubespray and **only contacts the first master**.
  11. ## Cilium Operator
  12. Unlike some operators, Cilium Operator does not exist for installation purposes.
  13. > The Cilium Operator is responsible for managing duties in the cluster which should logically be handled once for the entire cluster, rather than once for each node in the cluster.
  14. ### Adding custom flags to the Cilium Operator
  15. You can set additional cilium-operator container arguments using `cilium_operator_custom_args`.
  16. This is an advanced option, and you should only use it if you know what you are doing.
  17. Accepts an array or a string.
  18. ```yml
  19. cilium_operator_custom_args: ["--foo=bar", "--baz=qux"]
  20. ```
  21. or
  22. ```yml
  23. cilium_operator_custom_args: "--foo=bar"
  24. ```
  25. You do not need to add a custom flag to enable debugging. Instead, feel free to use the `CILIUM_DEBUG` variable.
  26. ### Adding extra volumes and mounting them
  27. You can use `cilium_operator_extra_volumes` to add extra volumes to the Cilium Operator, and use `cilium_operator_extra_volume_mounts` to mount those volumes.
  28. This is an advanced option, and you should only use it if you know what you are doing.
  29. ```yml
  30. cilium_operator_extra_volumes:
  31. - configMap:
  32. name: foo
  33. name: foo-mount-path
  34. cilium_operator_extra_volume_mounts:
  35. - mountPath: /tmp/foo/bar
  36. name: foo-mount-path
  37. readOnly: true
  38. ```
  39. ## Choose Cilium version
  40. ```yml
  41. cilium_version: v1.12.1
  42. ```
  43. ## Add variable to config
  44. Use following variables:
  45. Example:
  46. ```yml
  47. cilium_config_extra_vars:
  48. enable-endpoint-routes: true
  49. ```
  50. ## Change Identity Allocation Mode
  51. Cilium assigns an identity for each endpoint. This identity is used to enforce basic connectivity between endpoints.
  52. Cilium currently supports two different identity allocation modes:
  53. - "crd" stores identities in kubernetes as CRDs (custom resource definition).
  54. - These can be queried with `kubectl get ciliumid`
  55. - "kvstore" stores identities in an etcd kvstore.
  56. ## Enable Transparent Encryption
  57. Cilium supports the transparent encryption of Cilium-managed host traffic and
  58. traffic between Cilium-managed endpoints either using IPsec or Wireguard.
  59. Wireguard option is only available in Cilium 1.10.0 and newer.
  60. ### IPsec Encryption
  61. For further information, make sure to check the official [Cilium documentation.](https://docs.cilium.io/en/stable/gettingstarted/encryption-ipsec/)
  62. To enable IPsec encryption, you just need to set three variables.
  63. ```yml
  64. cilium_encryption_enabled: true
  65. cilium_encryption_type: "ipsec"
  66. ```
  67. The third variable is `cilium_ipsec_key.` You need to create a secret key string for this variable.
  68. Kubespray does not automate this process.
  69. Cilium documentation currently recommends creating a key using the following command:
  70. ```shell
  71. echo "3 rfc4106(gcm(aes)) $(echo $(dd if=/dev/urandom count=20 bs=1 2> /dev/null | xxd -p -c 64)) 128"
  72. ```
  73. Note that Kubespray handles secret creation. So you only need to pass the key as the `cilium_ipsec_key` variable.
  74. ### Wireguard Encryption
  75. For further information, make sure to check the official [Cilium documentation.](https://docs.cilium.io/en/stable/gettingstarted/encryption-wireguard/)
  76. To enable Wireguard encryption, you just need to set two variables.
  77. ```yml
  78. cilium_encryption_enabled: true
  79. cilium_encryption_type: "wireguard"
  80. ```
  81. Kubespray currently supports Linux distributions with Wireguard Kernel mode on Linux 5.6 and newer.
  82. ## Bandwidth Manager
  83. Cilium’s bandwidth manager supports the kubernetes.io/egress-bandwidth Pod annotation.
  84. Bandwidth enforcement currently does not work in combination with L7 Cilium Network Policies.
  85. In case they select the Pod at egress, then the bandwidth enforcement will be disabled for those Pods.
  86. Bandwidth Manager requires a v5.1.x or more recent Linux kernel.
  87. For further information, make sure to check the official [Cilium documentation.](https://docs.cilium.io/en/v1.12/gettingstarted/bandwidth-manager/)
  88. To use this function, set the following parameters
  89. ```yml
  90. cilium_enable_bandwidth_manager: true
  91. ```
  92. ## Install Cilium Hubble
  93. k8s-net-cilium.yml:
  94. ```yml
  95. cilium_enable_hubble: true ## enable support hubble in cilium
  96. cilium_hubble_install: true ## install hubble-relay, hubble-ui
  97. cilium_hubble_tls_generate: true ## install hubble-certgen and generate certificates
  98. ```
  99. To validate that Hubble UI is properly configured, set up a port forwarding for hubble-ui service:
  100. ```shell script
  101. kubectl port-forward -n kube-system svc/hubble-ui 12000:80
  102. ```
  103. and then open [http://localhost:12000/](http://localhost:12000/).
  104. ## Hubble metrics
  105. ```yml
  106. cilium_enable_hubble_metrics: true
  107. cilium_hubble_metrics:
  108. - dns
  109. - drop
  110. - tcp
  111. - flow
  112. - icmp
  113. - http
  114. ```
  115. [More](https://docs.cilium.io/en/v1.9/operations/metrics/#hubble-exported-metrics)
  116. ## Upgrade considerations
  117. ### Rolling-restart timeouts
  118. Cilium relies on the kernel's BPF support, which is extremely fast at runtime but incurs a compilation penalty on initialization and update.
  119. As a result, the Cilium DaemonSet pods can take a significant time to start, which scales with the number of nodes and endpoints in your cluster.
  120. As part of cluster.yml, this DaemonSet is restarted, and Kubespray's [default timeouts for this operation](../roles/network_plugin/cilium/defaults/main.yml)
  121. are not appropriate for large clusters.
  122. This means that you will likely want to update these timeouts to a value more in-line with your cluster's number of nodes and their respective CPU performance.
  123. This is configured by the following values:
  124. ```yaml
  125. # Configure how long to wait for the Cilium DaemonSet to be ready again
  126. cilium_rolling_restart_wait_retries_count: 30
  127. cilium_rolling_restart_wait_retries_delay_seconds: 10
  128. ```
  129. The total time allowed (count * delay) should be at least `($number_of_nodes_in_cluster * $cilium_pod_start_time)` for successful rolling updates. There are no
  130. drawbacks to making it higher and giving yourself a time buffer to accommodate transient slowdowns.
  131. Note: To find the `$cilium_pod_start_time` for your cluster, you can simply restart a Cilium pod on a node of your choice and look at how long it takes for it
  132. to become ready.
  133. Note 2: The default CPU requests/limits for Cilium pods is set to a very conservative 100m:500m which will likely yield very slow startup for Cilium pods. You
  134. probably want to significantly increase the CPU limit specifically if short bursts of CPU from Cilium are acceptable to you.