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.

184 lines
6.2 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. ## Install Cilium Hubble
  83. k8s-net-cilium.yml:
  84. ```yml
  85. cilium_enable_hubble: true ## enable support hubble in cilium
  86. cilium_hubble_install: true ## install hubble-relay, hubble-ui
  87. cilium_hubble_tls_generate: true ## install hubble-certgen and generate certificates
  88. ```
  89. To validate that Hubble UI is properly configured, set up a port forwarding for hubble-ui service:
  90. ```shell script
  91. kubectl port-forward -n kube-system svc/hubble-ui 12000:80
  92. ```
  93. and then open [http://localhost:12000/](http://localhost:12000/).
  94. ## Hubble metrics
  95. ```yml
  96. cilium_enable_hubble_metrics: true
  97. cilium_hubble_metrics:
  98. - dns
  99. - drop
  100. - tcp
  101. - flow
  102. - icmp
  103. - http
  104. ```
  105. [More](https://docs.cilium.io/en/v1.9/operations/metrics/#hubble-exported-metrics)
  106. ## Upgrade considerations
  107. ### Rolling-restart timeouts
  108. Cilium relies on the kernel's BPF support, which is extremely fast at runtime but incurs a compilation penalty on initialization and update.
  109. 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.
  110. As part of cluster.yml, this DaemonSet is restarted, and Kubespray's [default timeouts for this operation](../roles/network_plugin/cilium/defaults/main.yml)
  111. are not appropriate for large clusters.
  112. 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.
  113. This is configured by the following values:
  114. ```yaml
  115. # Configure how long to wait for the Cilium DaemonSet to be ready again
  116. cilium_rolling_restart_wait_retries_count: 30
  117. cilium_rolling_restart_wait_retries_delay_seconds: 10
  118. ```
  119. 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
  120. drawbacks to making it higher and giving yourself a time buffer to accommodate transient slowdowns.
  121. 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
  122. to become ready.
  123. 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
  124. probably want to significantly increase the CPU limit specifically if short bursts of CPU from Cilium are acceptable to you.