Skip to content

Commit 12507da

Browse files
Add support for Hubble flowlogs config
1 parent 63cdf87 commit 12507da

File tree

3 files changed

+776
-0
lines changed

3 files changed

+776
-0
lines changed

roles/network_plugin/cilium/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,5 @@ cilium_certgen_args:
352352

353353
cilium_enable_host_firewall: false
354354
cilium_policy_audit_mode: false
355+
356+
# hubble_flowlogs_config: {}
Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
---
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: cilium-config
6+
namespace: kube-system
7+
data:
8+
identity-allocation-mode: {{ cilium_identity_allocation_mode }}
9+
10+
{% if cilium_identity_allocation_mode == "kvstore" %}
11+
# This etcd-config contains the etcd endpoints of your cluster. If you use
12+
# TLS please make sure you follow the tutorial in https://cilium.link/etcd-config
13+
etcd-config: |-
14+
---
15+
endpoints:
16+
{% for ip_addr in etcd_access_addresses.split(',') %}
17+
- {{ ip_addr }}
18+
{% endfor %}
19+
20+
# In case you want to use TLS in etcd, uncomment the 'ca-file' line
21+
# and create a kubernetes secret by following the tutorial in
22+
# https://cilium.link/etcd-config
23+
{% if cilium_version | regex_replace('v') is version('1.17.0', '>=') %}
24+
trusted-ca-file: "{{ cilium_cert_dir }}/ca_cert.crt"
25+
{% else %}
26+
ca-file: "{{ cilium_cert_dir }}/ca_cert.crt"
27+
{% endif %}
28+
29+
# In case you want client to server authentication, uncomment the following
30+
# lines and create a kubernetes secret by following the tutorial in
31+
# https://cilium.link/etcd-config
32+
key-file: "{{ cilium_cert_dir }}/key.pem"
33+
cert-file: "{{ cilium_cert_dir }}/cert.crt"
34+
35+
# kvstore
36+
# https://docs.cilium.io/en/latest/cmdref/kvstore/
37+
kvstore: etcd
38+
kvstore-opt: '{"etcd.config": "/var/lib/etcd-config/etcd.config"}'
39+
{% endif %}
40+
41+
# If you want metrics enabled in all of your Cilium agents, set the port for
42+
# which the Cilium agents will have their metrics exposed.
43+
# This option deprecates the "prometheus-serve-addr" in the
44+
# "cilium-metrics-config" ConfigMap
45+
# NOTE that this will open the port on ALL nodes where Cilium pods are
46+
# scheduled.
47+
{% if cilium_enable_prometheus %}
48+
prometheus-serve-addr: ":{{ cilium_agent_scrape_port }}"
49+
operator-prometheus-serve-addr: ":{{ cilium_operator_scrape_port }}"
50+
enable-metrics: "true"
51+
{% endif %}
52+
53+
# If you want to run cilium in debug mode change this value to true
54+
debug: "{{ cilium_debug }}"
55+
enable-ipv4: "{{ cilium_enable_ipv4 }}"
56+
enable-ipv6: "{{ cilium_enable_ipv6 }}"
57+
# If a serious issue occurs during Cilium startup, this
58+
# invasive option may be set to true to remove all persistent
59+
# state. Endpoints will not be restored using knowledge from a
60+
# prior Cilium run, so they may receive new IP addresses upon
61+
# restart. This also triggers clean-cilium-bpf-state.
62+
clean-cilium-state: "false"
63+
# If you want to clean cilium BPF state, set this to true;
64+
# Removes all BPF maps from the filesystem. Upon restart,
65+
# endpoints are restored with the same IP addresses, however
66+
# any ongoing connections may be disrupted briefly.
67+
# Loadbalancing decisions will be reset, so any ongoing
68+
# connections via a service may be loadbalanced to a different
69+
# backend after restart.
70+
clean-cilium-bpf-state: "false"
71+
72+
# Users who wish to specify their own custom CNI configuration file must set
73+
# custom-cni-conf to "true", otherwise Cilium may overwrite the configuration.
74+
custom-cni-conf: "false"
75+
76+
{% if cilium_version is version('1.14.0', '>=') %}
77+
# Tell the agent to generate and write a CNI configuration file
78+
write-cni-conf-when-ready: /host/etc/cni/net.d/05-cilium.conflist
79+
cni-exclusive: "{{ cilium_cni_exclusive }}"
80+
cni-log-file: "{{ cilium_cni_log_file }}"
81+
{% endif %}
82+
83+
# If you want cilium monitor to aggregate tracing for packets, set this level
84+
# to "low", "medium", or "maximum". The higher the level, the less packets
85+
# that will be seen in monitor output.
86+
monitor-aggregation: "{{ cilium_monitor_aggregation }}"
87+
88+
# ct-global-max-entries-* specifies the maximum number of connections
89+
# supported across all endpoints, split by protocol: tcp or other. One pair
90+
# of maps uses these values for IPv4 connections, and another pair of maps
91+
# use these values for IPv6 connections.
92+
#
93+
# If these values are modified, then during the next Cilium startup the
94+
# tracking of ongoing connections may be disrupted. This may lead to brief
95+
# policy drops or a change in loadbalancing decisions for a connection.
96+
#
97+
# For users upgrading from Cilium 1.2 or earlier, to minimize disruption
98+
# during the upgrade process, comment out these options.
99+
bpf-ct-global-tcp-max: "524288"
100+
bpf-ct-global-any-max: "262144"
101+
102+
# Pre-allocation of map entries allows per-packet latency to be reduced, at
103+
# the expense of up-front memory allocation for the entries in the maps. The
104+
# default value below will minimize memory usage in the default installation;
105+
# users who are sensitive to latency may consider setting this to "true".
106+
#
107+
# This option was introduced in Cilium 1.4. Cilium 1.3 and earlier ignore
108+
# this option and behave as though it is set to "true".
109+
#
110+
# If this value is modified, then during the next Cilium startup the restore
111+
# of existing endpoints and tracking of ongoing connections may be disrupted.
112+
# This may lead to policy drops or a change in loadbalancing decisions for a
113+
# connection for some time. Endpoints may need to be recreated to restore
114+
# connectivity.
115+
#
116+
# If this option is set to "false" during an upgrade from 1.3 or earlier to
117+
# 1.4 or later, then it may cause one-time disruptions during the upgrade.
118+
preallocate-bpf-maps: "{{ cilium_preallocate_bpf_maps }}"
119+
120+
# Regular expression matching compatible Istio sidecar istio-proxy
121+
# container image names
122+
sidecar-istio-proxy-image: "cilium/istio_proxy"
123+
124+
# Encapsulation mode for communication between nodes
125+
# Possible values:
126+
# - disabled
127+
# - vxlan (default)
128+
# - geneve
129+
{% if cilium_version is version('1.14.0', '<') %}
130+
tunnel: "{{ cilium_tunnel_mode }}"
131+
{% elif cilium_version is version('1.14.0', '>=') and cilium_tunnel_mode == 'disabled' %}
132+
routing-mode: 'native'
133+
{% elif cilium_version is version('1.14.0', '>=') and cilium_tunnel_mode != 'disabled' %}
134+
routing-mode: 'tunnel'
135+
tunnel-protocol: "{{ cilium_tunnel_mode }}"
136+
{% endif %}
137+
138+
## DSR setting
139+
bpf-lb-mode: "{{ cilium_loadbalancer_mode }}"
140+
141+
# l2
142+
enable-l2-announcements: "{{ cilium_l2announcements }}"
143+
144+
# Enable Bandwidth Manager
145+
# Cilium's bandwidth manager supports the kubernetes.io/egress-bandwidth Pod annotation.
146+
# Bandwidth enforcement currently does not work in combination with L7 Cilium Network Policies.
147+
# In case they select the Pod at egress, then the bandwidth enforcement will be disabled for those Pods.
148+
# Bandwidth Manager requires a v5.1.x or more recent Linux kernel.
149+
{% if cilium_enable_bandwidth_manager %}
150+
enable-bandwidth-manager: "true"
151+
{% endif %}
152+
153+
# Host Firewall and Policy Audit Mode
154+
enable-host-firewall: "{{ cilium_enable_host_firewall | capitalize }}"
155+
policy-audit-mode: "{{ cilium_policy_audit_mode | capitalize }}"
156+
157+
# Name of the cluster. Only relevant when building a mesh of clusters.
158+
cluster-name: "{{ cilium_cluster_name }}"
159+
160+
# Unique ID of the cluster. Must be unique across all conneted clusters and
161+
# in the range of 1 and 255. Only relevant when building a mesh of clusters.
162+
#cluster-id: 1
163+
{% if cilium_cluster_id is defined %}
164+
cluster-id: "{{ cilium_cluster_id }}"
165+
{% endif %}
166+
167+
# `wait-bpf-mount` is removed after v1.10.4
168+
# https://github.com/cilium/cilium/commit/d2217045cb3726a7f823174e086913b69b8090da
169+
{% if cilium_version is version('1.10.4', '<') %}
170+
# wait-bpf-mount makes init container wait until bpf filesystem is mounted
171+
wait-bpf-mount: "false"
172+
{% endif %}
173+
174+
# `kube-proxy-replacement=partial|strict|disabled` is deprecated since january 2024 and unsupported in 1.16.
175+
# Replaced by `kube-proxy-replacement=true|false`
176+
# https://github.com/cilium/cilium/pull/31286
177+
{% if cilium_version is version('1.16', '<') %}
178+
kube-proxy-replacement: "{{ cilium_kube_proxy_replacement }}"
179+
{% else %}
180+
kube-proxy-replacement: "{% if (cilium_kube_proxy_replacement == 'strict') or (cilium_kube_proxy_replacement | bool) or (cilium_kube_proxy_replacement | string | lower == 'true') %}true{% else %}false{% endif %}"
181+
{% endif %}
182+
183+
# `native-routing-cidr` is deprecated in 1.10, removed in 1.12.
184+
# Replaced by `ipv4-native-routing-cidr`
185+
# https://github.com/cilium/cilium/pull/16695
186+
{% if cilium_version is version('1.12', '<') %}
187+
native-routing-cidr: "{{ cilium_native_routing_cidr }}"
188+
{% else %}
189+
{% if cilium_native_routing_cidr | length %}
190+
ipv4-native-routing-cidr: "{{ cilium_native_routing_cidr }}"
191+
{% endif %}
192+
{% if cilium_native_routing_cidr_ipv6 | length %}
193+
ipv6-native-routing-cidr: "{{ cilium_native_routing_cidr_ipv6 }}"
194+
{% endif %}
195+
{% endif %}
196+
197+
auto-direct-node-routes: "{{ cilium_auto_direct_node_routes }}"
198+
199+
operator-api-serve-addr: "{{ cilium_operator_api_serve_addr }}"
200+
201+
# Hubble settings
202+
{% if cilium_enable_hubble %}
203+
enable-hubble: "true"
204+
{% if cilium_enable_hubble_metrics %}
205+
hubble-metrics-server: ":{{ cilium_hubble_scrape_port }}"
206+
hubble-metrics:
207+
{% for hubble_metrics_cycle in cilium_hubble_metrics %}
208+
{{ hubble_metrics_cycle }}
209+
{% endfor %}
210+
{% endif %}
211+
{% if cilium_hubble_event_buffer_capacity is defined %}
212+
hubble-event-buffer-capacity: "{{ cilium_hubble_event_buffer_capacity }}"
213+
{% endif %}
214+
{% if cilium_hubble_event_queue_size is defined %}
215+
hubble-event-queue-size: "{{ cilium_hubble_event_queue_size }}"
216+
{% endif %}
217+
hubble-listen-address: ":4244"
218+
{% if cilium_enable_hubble and cilium_hubble_install %}
219+
hubble-disable-tls: "{% if cilium_hubble_tls_generate %}false{% else %}true{% endif %}"
220+
hubble-tls-cert-file: /var/lib/cilium/tls/hubble/server.crt
221+
hubble-tls-key-file: /var/lib/cilium/tls/hubble/server.key
222+
hubble-tls-client-ca-files: /var/lib/cilium/tls/hubble/client-ca.crt
223+
{% endif %}
224+
{% endif %}
225+
226+
# IP Masquerade Agent
227+
enable-ip-masq-agent: "{{ cilium_ip_masq_agent_enable }}"
228+
229+
{% for key, value in cilium_config_extra_vars.items() %}
230+
{{ key }}: "{{ value }}"
231+
{% endfor %}
232+
233+
# Enable transparent network encryption
234+
{% if cilium_encryption_enabled %}
235+
{% if cilium_encryption_type == "ipsec" %}
236+
enable-ipsec: "true"
237+
ipsec-key-file: /etc/ipsec/keys
238+
encrypt-node: "{{ cilium_ipsec_node_encryption }}"
239+
{% endif %}
240+
241+
{% if cilium_encryption_type == "wireguard" %}
242+
enable-wireguard: "true"
243+
enable-wireguard-userspace-fallback: "{{ cilium_wireguard_userspace_fallback }}"
244+
{% endif %}
245+
{% endif %}
246+
247+
# IPAM settings
248+
ipam: "{{ cilium_ipam_mode }}"
249+
{% if cilium_ipam_mode == "cluster-pool" %}
250+
cluster-pool-ipv4-cidr: "{{ cilium_pool_cidr | default(kube_pods_subnet) }}"
251+
cluster-pool-ipv4-mask-size: "{{ cilium_pool_mask_size | default(kube_network_node_prefix) }}"
252+
{% if cilium_enable_ipv6 %}
253+
cluster-pool-ipv6-cidr: "{{ cilium_pool_cidr_ipv6 | default(kube_pods_subnet_ipv6) }}"
254+
cluster-pool-ipv6-mask-size: "{{ cilium_pool_mask_size_ipv6 | default(kube_network_node_prefix_ipv6) }}"
255+
{% endif %}
256+
{% endif %}
257+
258+
agent-health-port: "{{ cilium_agent_health_port }}"
259+
260+
{% if cilium_version is version('1.11', '>=') and cilium_cgroup_host_root != '' %}
261+
cgroup-root: "{{ cilium_cgroup_host_root }}"
262+
{% endif %}
263+
264+
bpf-map-dynamic-size-ratio: "{{ cilium_bpf_map_dynamic_size_ratio }}"
265+
266+
enable-ipv4-masquerade: "{{ cilium_enable_ipv4_masquerade }}"
267+
enable-ipv6-masquerade: "{{ cilium_enable_ipv6_masquerade }}"
268+
269+
enable-bpf-masquerade: "{{ cilium_enable_bpf_masquerade }}"
270+
271+
enable-host-legacy-routing: "{{ cilium_enable_host_legacy_routing }}"
272+
273+
enable-remote-node-identity: "{{ cilium_enable_remote_node_identity }}"
274+
275+
enable-well-known-identities: "{{ cilium_enable_well_known_identities }}"
276+
277+
monitor-aggregation-flags: "{{ cilium_monitor_aggregation_flags }}"
278+
279+
enable-bpf-clock-probe: "{{ cilium_enable_bpf_clock_probe }}"
280+
281+
enable-bgp-control-plane: "{{ cilium_enable_bgp_control_plane }}"
282+
283+
disable-cnp-status-updates: "{{ cilium_disable_cnp_status_updates }}"
284+
285+
{% if hubble_flowlogs_config is defined %}
286+
hubble-flowlogs-config-path: /flowlog-config/flowlogs.yaml
287+
{% endif %}
288+
289+
{% if cilium_ip_masq_agent_enable %}
290+
---
291+
apiVersion: v1
292+
kind: ConfigMap
293+
metadata:
294+
name: ip-masq-agent
295+
namespace: kube-system
296+
data:
297+
config: |
298+
nonMasqueradeCIDRs:
299+
{% for cidr in cilium_non_masquerade_cidrs %}
300+
- {{ cidr }}
301+
{% endfor %}
302+
masqLinkLocal: {{ cilium_masq_link_local | bool }}
303+
resyncInterval: "{{ cilium_ip_masq_resync_interval }}"
304+
{% endif %}
305+
306+
{% if hubble_flowlogs_config is defined %}
307+
---
308+
apiVersion: v1
309+
kind: ConfigMap
310+
metadata:
311+
name: cilium-flowlog-config
312+
namespace: kube-system
313+
data:
314+
flowlogs.yaml: |
315+
{{ hubble_flowlogs_config | to_yaml | indent(4) }}
316+
{% endif %}

0 commit comments

Comments
 (0)