Skip to content

Commit 019cf2a

Browse files
authored
Merge pull request #12101 from tico88612/refactor/cilium-install
Refactor Cilium CNI installation
2 parents 571e747 + 1266527 commit 019cf2a

32 files changed

+249
-2082
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Note:
119119
- Network Plugin
120120
- [cni-plugins](https://github.com/containernetworking/plugins) 1.4.1
121121
- [calico](https://github.com/projectcalico/calico) 3.29.3
122-
- [cilium](https://github.com/cilium/cilium) 1.15.9
122+
- [cilium](https://github.com/cilium/cilium) 1.17.3
123123
- [flannel](https://github.com/flannel-io/flannel) 0.22.0
124124
- [kube-ovn](https://github.com/alauda/kube-ovn) 1.12.21
125125
- [kube-router](https://github.com/cloudnativelabs/kube-router) 2.1.1

docs/CNI/cilium.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ cilium_operator_extra_volume_mounts:
237237
## Choose Cilium version
238238

239239
```yml
240-
cilium_version: "1.15.9"
240+
cilium_version: "1.17.3"
241241
```
242242

243243
## Add variable to config

roles/kubespray_defaults/defaults/main/download.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ flannel_cni_version: 1.1.2
113113
weave_version: 2.8.7
114114
cni_version: "{{ (cni_binary_checksums['amd64'] | dict2items)[0].key }}"
115115

116-
cilium_version: "1.15.9"
116+
cilium_version: "1.17.3"
117117
cilium_cli_version: "{{ (ciliumcli_binary_checksums['amd64'] | dict2items)[0].key }}"
118118
cilium_enable_hubble: false
119119

@@ -261,13 +261,13 @@ cilium_operator_image_tag: "v{{ cilium_version }}"
261261
cilium_hubble_relay_image_repo: "{{ quay_image_repo }}/cilium/hubble-relay"
262262
cilium_hubble_relay_image_tag: "v{{ cilium_version }}"
263263
cilium_hubble_certgen_image_repo: "{{ quay_image_repo }}/cilium/certgen"
264-
cilium_hubble_certgen_image_tag: "v0.1.8"
264+
cilium_hubble_certgen_image_tag: "v0.2.1"
265265
cilium_hubble_ui_image_repo: "{{ quay_image_repo }}/cilium/hubble-ui"
266-
cilium_hubble_ui_image_tag: "v0.11.0"
266+
cilium_hubble_ui_image_tag: "v0.13.2"
267267
cilium_hubble_ui_backend_image_repo: "{{ quay_image_repo }}/cilium/hubble-ui-backend"
268-
cilium_hubble_ui_backend_image_tag: "v0.11.0"
269-
cilium_hubble_envoy_image_repo: "{{ docker_image_repo }}/envoyproxy/envoy"
270-
cilium_hubble_envoy_image_tag: "v1.22.5"
268+
cilium_hubble_ui_backend_image_tag: "v0.13.2"
269+
cilium_hubble_envoy_image_repo: "{{ quay_image_repo }}/cilium/cilium-envoy"
270+
cilium_hubble_envoy_image_tag: "v1.32.5-1744305768-f9ddca7dcd91f7ca25a505560e655c47d3dec2cf"
271271
kube_ovn_container_image_repo: "{{ docker_image_repo }}/kubeovn/kube-ovn"
272272
kube_ovn_container_image_tag: "v{{ kube_ovn_version }}"
273273
kube_ovn_vpc_container_image_repo: "{{ docker_image_repo }}/kubeovn/vpc-nat-gateway"

roles/kubespray_defaults/vars/main/checksums.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,11 @@ calicoctl_binary_checksums:
556556
3.27.0: sha256:3de46d8bc30c6f9d9387d484ed62a5655c1f204b1b831b5a90f0a0d1c1ffd752
557557
ciliumcli_binary_checksums:
558558
arm64:
559+
0.18.3: sha256:e0588268fc9ab6e0b7a363c4e15ecf69ed2a4cade956ab272745262e456f0e54
560+
0.18.2: sha256:db3fae09ba005d6d345858655777bb5c972c9c841f98dc3fad3455d3084dba61
561+
0.18.1: sha256:e6556fc7ccd071d7612446945d361c869dfeb423e0738147e0b46b2550bc2bf9
562+
0.18.0: sha256:fd20a79875c8089694fb9b5dc3a0bf89d51711f9239637931ff0ace76ce78816
563+
0.17.0: sha256:dee29ad27f3958882b450019e2021698282e8fcf8b136c27397798102cc1ad13
559564
0.16.24: sha256:cf7f1276bbcf4aa5e6347d5619efe990cf1340d5898f8405931e277a1f76c670
560565
0.16.23: sha256:7973302bead01c3f2e1d0f03e2766a0d6e76d3c52c666c750b9871a28b9afb32
561566
0.16.22: sha256:b70c15e40b36ac34d59597f2448c5b4e0033964c517f926dbb9654aa07fb1e5b
@@ -591,6 +596,11 @@ ciliumcli_binary_checksums:
591596
0.15.16: sha256:86ed6a2e796c39dd00072e7c141fc35b68d63392d1ac5e183a7ce9d7263e23a0
592597
0.15.15: sha256:5c1693ea163b094a92ebc6997b6e678cc8c24a52040c22433b58b419de74b28f
593598
amd64:
599+
0.18.3: sha256:5fe565f3b98b5846b867319aa76bc057fca37894d80db56edc20e4e809d10b25
600+
0.18.2: sha256:1b4bd5fd5c96ab1195cd4eb56841c983a21149c62ee39922b7955f1cd0eda23a
601+
0.18.1: sha256:c472639d460173e8d807a3f57048f9d1bcdb325e9edba320550d7ec62b72f956
602+
0.18.0: sha256:3ac8bd270763e40a7853c73f8c7ec9e49707e1723801884a083dc25469b6b4ba
603+
0.17.0: sha256:4ba0687ff7d47e182a7328409fb0eae123e64fa6099cd6f8b9bf240c0012ecf4
594604
0.16.24: sha256:019c9c765222b3db5786f7b3a0bff2cd62944a8ce32681acfb47808330f405a7
595605
0.16.23: sha256:e7cd3b982eca9b6214226536a147490ebb6ea3caad40d5a724daeea0bec5e3be
596606
0.16.22: sha256:8bd9faae272aef2e75c686a55de782018013098b66439a1ee0c8ff1e05c5d32c

roles/network_plugin/cilium/defaults/main.yml

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
cilium_min_version_required: "1.10"
2+
cilium_min_version_required: "1.15"
33
# Log-level
44
cilium_debug: false
55

6-
cilium_mtu: ""
6+
cilium_mtu: "0"
77
cilium_enable_ipv4: "{{ ipv4_stack }}"
88
cilium_enable_ipv6: "{{ ipv6_stack }}"
99

1010
# Enable l2 announcement from cilium to replace Metallb Ref: https://docs.cilium.io/en/v1.14/network/l2-announcements/
1111
cilium_l2announcements: false
1212

1313
# Cilium agent health port
14-
cilium_agent_health_port: "{%- if cilium_version is version('1.11.6', '>=') -%}9879{%- else -%}9876{%- endif -%}"
14+
cilium_agent_health_port: "9879"
1515

1616
# Identity allocation mode selects how identities are shared between cilium
1717
# nodes by setting how they are stored. The options are "crd" or "kvstore".
@@ -26,7 +26,7 @@ cilium_agent_health_port: "{%- if cilium_version is version('1.11.6', '>=') -%}9
2626
# - --synchronize-k8s-nodes
2727
# - --identity-allocation-mode=kvstore
2828
# - Ref: https://docs.cilium.io/en/stable/internals/cilium_operator/#kvstore-operations
29-
cilium_identity_allocation_mode: kvstore
29+
cilium_identity_allocation_mode: crd
3030

3131
# Etcd SSL dirs
3232
cilium_cert_dir: /etc/cilium/certs
@@ -55,20 +55,20 @@ cilium_enable_prometheus: false
5555
cilium_enable_portmap: false
5656
# Monitor aggregation level (none/low/medium/maximum)
5757
cilium_monitor_aggregation: medium
58-
# Kube Proxy Replacement mode (strict/partial)
59-
cilium_kube_proxy_replacement: partial
58+
# Kube Proxy Replacement mode (true/false)
59+
cilium_kube_proxy_replacement: false
60+
61+
# If not defined `cilium_dns_proxy_enable_transparent_mode`, it will following the Cilium behavior.
62+
# When Cilium is configured to replace kube-proxy, it automatically enables dnsProxy, which will conflict with nodelocaldns.
63+
# You can set `false` avoid conflict with nodelocaldns.
64+
# https://github.com/cilium/cilium/issues/33144
65+
# cilium_dns_proxy_enable_transparent_mode:
6066

6167
# If upgrading from Cilium < 1.5, you may want to override some of these options
6268
# to prevent service disruptions. See also:
6369
# http://docs.cilium.io/en/stable/install/upgrade/#changes-that-may-require-action
6470
cilium_preallocate_bpf_maps: false
6571

66-
# `cilium_tofqdns_enable_poller` is deprecated in 1.8, removed in 1.9
67-
cilium_tofqdns_enable_poller: false
68-
69-
# `cilium_enable_legacy_services` is deprecated in 1.6, removed in 1.9
70-
cilium_enable_legacy_services: false
71-
7272
# Auto direct nodes routes can be used to advertise pods routes in your cluster
7373
# without any tunelling (with `cilium_tunnel_mode` sets to `disabled`).
7474
# This works only if you have a L2 connectivity between all your nodes.
@@ -100,8 +100,8 @@ cilium_encryption_enabled: false
100100
cilium_encryption_type: "ipsec"
101101

102102
# Enable encryption for pure node to node traffic.
103-
# This option is only effective when `cilium_encryption_type` is set to `ipsec`.
104-
cilium_ipsec_node_encryption: false
103+
# This option is only effective when `cilium_encryption_type` is set to `wireguard`.
104+
cilium_encryption_node_encryption: false
105105

106106
# If your kernel or distribution does not support WireGuard, Cilium agent can be configured to fall back on the user-space implementation.
107107
# When this flag is enabled and Cilium detects that the kernel has no native support for WireGuard,
@@ -115,6 +115,7 @@ cilium_wireguard_userspace_fallback: false
115115
# In case they select the Pod at egress, then the bandwidth enforcement will be disabled for those Pods.
116116
# Bandwidth Manager requires a v5.1.x or more recent Linux kernel.
117117
cilium_enable_bandwidth_manager: false
118+
cilium_enable_bandwidth_manager_bbr: false
118119

119120
# IP Masquerade Agent
120121
# https://docs.cilium.io/en/stable/concepts/networking/masquerading/
@@ -137,6 +138,7 @@ cilium_non_masquerade_cidrs:
137138
### Indicates whether to masquerade traffic to the link local prefix.
138139
### If the masqLinkLocal is not set or set to false, then 169.254.0.0/16 is appended to the non-masquerade CIDRs list.
139140
cilium_masq_link_local: false
141+
cilium_masq_link_local_ipv6: false
140142
### A time interval at which the agent attempts to reload config from disk
141143
cilium_ip_masq_resync_interval: 60s
142144

@@ -145,10 +147,10 @@ cilium_ip_masq_resync_interval: 60s
145147
cilium_enable_hubble: false
146148
### Enable Hubble-ui
147149
cilium_enable_hubble_ui: "{{ cilium_enable_hubble }}"
148-
### Enable Hubble Metrics
150+
### Enable Hubble Metrics (deprecated)
149151
cilium_enable_hubble_metrics: false
150152
### if cilium_enable_hubble_metrics: true
151-
cilium_hubble_metrics: {}
153+
cilium_hubble_metrics: []
152154
# - dns
153155
# - drop
154156
# - tcp
@@ -160,12 +162,25 @@ cilium_hubble_install: false
160162
### Enable auto generate certs if cilium_hubble_install: true
161163
cilium_hubble_tls_generate: false
162164

165+
cilium_hubble_export_file_max_backups: "5"
166+
cilium_hubble_export_file_max_size_mb: "10"
167+
168+
cilium_hubble_export_dynamic_enabled: false
169+
cilium_hubble_export_dynamic_config_content:
170+
- name: all
171+
fieldMask: []
172+
includeFilters: []
173+
excludeFilters: []
174+
filePath: "/var/run/cilium/hubble/events.log"
175+
163176
### Capacity of Hubble events buffer. The provided value must be one less than an integer power of two and no larger than 65535
164177
### (ie: 1, 3, ..., 2047, 4095, ..., 65535) (default 4095)
165178
# cilium_hubble_event_buffer_capacity: 4095
166179
### Buffer size of the channel to receive monitor events.
167180
# cilium_hubble_event_queue_size: 50
168181

182+
cilium_gateway_api_enabled: false
183+
169184
# The default IP address management mode is "Cluster Scope".
170185
# https://docs.cilium.io/en/stable/concepts/networking/ipam/
171186
cilium_ipam_mode: cluster-pool
@@ -190,7 +205,8 @@ cilium_ipam_mode: cluster-pool
190205

191206

192207
# Extra arguments for the Cilium agent
193-
cilium_agent_custom_args: []
208+
cilium_agent_custom_args: [] # deprecated
209+
cilium_agent_extra_args: []
194210

195211
# For adding and mounting extra volumes to the cilium agent
196212
cilium_agent_extra_volumes: []
@@ -214,13 +230,19 @@ cilium_operator_extra_volumes: []
214230
cilium_operator_extra_volume_mounts: []
215231

216232
# Extra arguments for the Cilium Operator
217-
cilium_operator_custom_args: []
233+
cilium_operator_custom_args: [] # deprecated
234+
cilium_operator_extra_args: []
218235

219236
# Tolerations of the cilium operator
220237
cilium_operator_tolerations:
221238
- operator: "Exists"
222239

240+
# Unique ID of the cluster. Must be unique across all connected
241+
# clusters and in the range of 1 to 255. Only required for Cluster Mesh,
242+
# may be 0 if Cluster Mesh is not used.
243+
cilium_cluster_id: 0
223244
# Name of the cluster. Only relevant when building a mesh of clusters.
245+
# The "default" name cannot be used if the Cluster ID is different from 0.
224246
cilium_cluster_name: default
225247

226248
# Make Cilium take ownership over the `/etc/cni/net.d` directory on the node, renaming all non-Cilium CNI configurations to `*.cilium_bak`.
@@ -263,7 +285,7 @@ cilium_enable_bpf_masquerade: false
263285
# host stack (true) or directly and more efficiently out of BPF (false) if
264286
# the kernel supports it. The latter has the implication that it will also
265287
# bypass netfilter in the host namespace.
266-
cilium_enable_host_legacy_routing: true
288+
cilium_enable_host_legacy_routing: false
267289

268290
# -- Enable use of the remote node identity.
269291
# ref: https://docs.cilium.io/en/v1.7/install/upgrade/#configmap-remote-node-identity
@@ -307,9 +329,9 @@ cilium_rolling_restart_wait_retries_count: 30
307329
cilium_rolling_restart_wait_retries_delay_seconds: 10
308330

309331
# Cilium changed the default metrics exporter ports in 1.12
310-
cilium_agent_scrape_port: "{{ cilium_version is version('1.12', '>=') | ternary('9962', '9090') }}"
311-
cilium_operator_scrape_port: "{{ cilium_version is version('1.12', '>=') | ternary('9963', '6942') }}"
312-
cilium_hubble_scrape_port: "{{ cilium_version is version('1.12', '>=') | ternary('9965', '9091') }}"
332+
cilium_agent_scrape_port: "9962"
333+
cilium_operator_scrape_port: "9963"
334+
cilium_hubble_scrape_port: "9965"
313335

314336
# Cilium certgen args for generate certificate for hubble mTLS
315337
cilium_certgen_args:
@@ -328,26 +350,5 @@ cilium_certgen_args:
328350
hubble-relay-client-cert-secret-name: hubble-relay-client-certs
329351
hubble-relay-server-cert-generate: false
330352

331-
# A list of extra rules variables to add to clusterrole for cilium operator, formatted like:
332-
# cilium_clusterrole_rules_operator_extra_vars:
333-
# - apiGroups:
334-
# - '""'
335-
# resources:
336-
# - pods
337-
# verbs:
338-
# - delete
339-
# - apiGroups:
340-
# - '""'
341-
# resources:
342-
# - nodes
343-
# verbs:
344-
# - list
345-
# - watch
346-
# resourceNames:
347-
# - toto
348-
cilium_clusterrole_rules_operator_extra_vars: []
349353
cilium_enable_host_firewall: false
350354
cilium_policy_audit_mode: false
351-
352-
cilium_hubble_export_file_max_backups: "5"
353-
cilium_hubble_export_file_max_size_mb: "10"

roles/network_plugin/cilium/tasks/apply.yml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
---
2-
- name: Cilium | Start Resources
3-
kube:
4-
name: "{{ item.item.name }}"
5-
namespace: "kube-system"
6-
kubectl: "{{ bin_dir }}/kubectl"
7-
resource: "{{ item.item.type }}"
8-
filename: "{{ kube_config_dir }}/{{ item.item.name }}-{{ item.item.file }}"
9-
state: "latest"
10-
loop: "{{ cilium_node_manifests.results }}"
11-
when: inventory_hostname == groups['kube_control_plane'][0] and not item is skipped
2+
- name: Cilium | Install
3+
command: "{{ bin_dir }}/cilium install --version {{ cilium_version }} -f {{ kube_config_dir }}/cilium-values.yaml"
4+
when: inventory_hostname == groups['kube_control_plane'][0]
125

136
- name: Cilium | Wait for pods to run
147
command: "{{ kubectl }} -n kube-system get pods -l k8s-app=cilium -o jsonpath='{.items[?(@.status.containerStatuses[0].ready==false)].metadata.name}'" # noqa literal-compare
@@ -19,19 +12,6 @@
1912
failed_when: false
2013
when: inventory_hostname == groups['kube_control_plane'][0]
2114

22-
- name: Cilium | Hubble install
23-
kube:
24-
name: "{{ item.item.name }}"
25-
namespace: "kube-system"
26-
kubectl: "{{ bin_dir }}/kubectl"
27-
resource: "{{ item.item.type }}"
28-
filename: "{{ kube_config_dir }}/addons/hubble/{{ item.item.name }}-{{ item.item.file }}"
29-
state: "latest"
30-
loop: "{{ cilium_hubble_manifests.results }}"
31-
when:
32-
- inventory_hostname == groups['kube_control_plane'][0] and not item is skipped
33-
- cilium_enable_hubble and cilium_hubble_install
34-
3515
- name: Cilium | Wait for CiliumLoadBalancerIPPool CRD to be present
3616
command: "{{ kubectl }} wait --for condition=established --timeout=60s crd/ciliumloadbalancerippools.cilium.io"
3717
register: cillium_lbippool_crd_ready

roles/network_plugin/cilium/tasks/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
msg: "cilium_encryption_type must be either 'ipsec' or 'wireguard'"
4949
when: cilium_encryption_enabled
5050

51-
- name: Stop if cilium_version is < 1.10.0
51+
- name: Stop if cilium_version is < {{ cilium_min_version_required }}
5252
assert:
5353
that: cilium_version is version(cilium_min_version_required, '>=')
5454
msg: "cilium_version is too low. Minimum version {{ cilium_min_version_required }}"

roles/network_plugin/cilium/tasks/install.yml

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,64 +30,20 @@
3030
when:
3131
- cilium_identity_allocation_mode == "kvstore"
3232

33-
- name: Cilium | Create hubble dir
34-
file:
35-
path: "{{ kube_config_dir }}/addons/hubble"
36-
state: directory
37-
owner: root
38-
group: root
39-
mode: "0755"
40-
when:
41-
- inventory_hostname == groups['kube_control_plane'][0]
42-
- cilium_hubble_install
43-
44-
- name: Cilium | Create Cilium node manifests
33+
- name: Cilium | Enable portmap addon
4534
template:
46-
src: "{{ item.name }}/{{ item.file }}.j2"
47-
dest: "{{ kube_config_dir }}/{{ item.name }}-{{ item.file }}"
35+
src: 000-cilium-portmap.conflist.j2
36+
dest: /etc/cni/net.d/000-cilium-portmap.conflist
4837
mode: "0644"
49-
loop:
50-
- {name: cilium, file: config.yml, type: cm}
51-
- {name: cilium-operator, file: crb.yml, type: clusterrolebinding}
52-
- {name: cilium-operator, file: cr.yml, type: clusterrole}
53-
- {name: cilium, file: crb.yml, type: clusterrolebinding}
54-
- {name: cilium, file: cr.yml, type: clusterrole}
55-
- {name: cilium, file: secret.yml, type: secret, when: "{{ cilium_encryption_enabled and cilium_encryption_type == 'ipsec' }}"}
56-
- {name: cilium, file: ds.yml, type: ds}
57-
- {name: cilium-operator, file: deploy.yml, type: deploy}
58-
- {name: cilium-operator, file: sa.yml, type: sa}
59-
- {name: cilium, file: sa.yml, type: sa}
60-
register: cilium_node_manifests
61-
when:
62-
- ('kube_control_plane' in group_names)
63-
- item.when | default(True) | bool
38+
when: cilium_enable_portmap
6439

65-
- name: Cilium | Create Cilium Hubble manifests
40+
- name: Cilium | Render values
6641
template:
67-
src: "{{ item.name }}/{{ item.file }}.j2"
68-
dest: "{{ kube_config_dir }}/addons/hubble/{{ item.name }}-{{ item.file }}"
42+
src: values.yaml.j2
43+
dest: "{{ kube_config_dir }}/cilium-values.yaml"
6944
mode: "0644"
70-
loop:
71-
- {name: hubble, file: config.yml, type: cm}
72-
- {name: hubble, file: crb.yml, type: clusterrolebinding}
73-
- {name: hubble, file: cr.yml, type: clusterrole}
74-
- {name: hubble, file: cronjob.yml, type: cronjob, when: "{{ cilium_hubble_tls_generate }}"}
75-
- {name: hubble, file: deploy.yml, type: deploy}
76-
- {name: hubble, file: job.yml, type: job, when: "{{ cilium_hubble_tls_generate }}"}
77-
- {name: hubble, file: sa.yml, type: sa}
78-
- {name: hubble, file: service.yml, type: service}
79-
register: cilium_hubble_manifests
8045
when:
8146
- inventory_hostname == groups['kube_control_plane'][0]
82-
- cilium_enable_hubble and cilium_hubble_install
83-
- item.when | default(True) | bool
84-
85-
- name: Cilium | Enable portmap addon
86-
template:
87-
src: 000-cilium-portmap.conflist.j2
88-
dest: /etc/cni/net.d/000-cilium-portmap.conflist
89-
mode: "0644"
90-
when: cilium_enable_portmap
9147

9248
- name: Cilium | Copy Ciliumcli binary from download dir
9349
copy:

0 commit comments

Comments
 (0)