Skip to content

Commit c50d4bd

Browse files
authored
Merge pull request #156 from projectsyn/feat/shadow-ranges-daemonset-custom-nodesel
Add support to configure a custom node selector for the shadow ranges DaemonSet
2 parents 6c2f1e6 + 5040317 commit c50d4bd

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

class/defaults.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ parameters:
9494
enabled: false
9595
policies: {}
9696
generate_shadow_ranges_configmap: false
97+
shadow_ranges_daemonset_node_selector: {}
9798
egress_ip_ranges: {}
9899

99100
l2_announcements:

component/egress-gateway-policies.jsonnet

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ local egress_ip_shadow_ranges =
287287
{}
288288
);
289289

290-
local daemonsets = [
290+
local make_daemonset(ds_configs, sel_hash) =
291291
kube.DaemonSet(
292292
'eip-shadow-ranges-%s' % std.substr(
293293
sel_hash, std.length(sel_hash) - 5, 5
@@ -318,7 +318,7 @@ local egress_ip_shadow_ranges =
318318
},
319319
},
320320
},
321-
nodeSelector: daemonset_configs[sel_hash],
321+
nodeSelector: ds_configs[sel_hash],
322322
volumes_: {
323323
shadow_ranges: {
324324
configMap: {
@@ -329,9 +329,23 @@ local egress_ip_shadow_ranges =
329329
},
330330
},
331331
},
332-
}
333-
for sel_hash in std.objectFields(daemonset_configs)
334-
];
332+
};
333+
334+
local daemonsets =
335+
if std.length(params.egress_gateway.shadow_ranges_daemonset_node_selector) == 0 then [
336+
make_daemonset(daemonset_configs, sel_hash)
337+
for sel_hash in std.objectFields(daemonset_configs)
338+
] else
339+
local sel_hash =
340+
std.md5(std.manifestJsonMinified(
341+
params.egress_gateway.shadow_ranges_daemonset_node_selector
342+
));
343+
[
344+
make_daemonset({
345+
[sel_hash]:
346+
params.egress_gateway.shadow_ranges_daemonset_node_selector,
347+
}, sel_hash),
348+
];
335349

336350
[ configmap ] + daemonsets;
337351

docs/modules/ROOT/pages/references/parameters.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,21 @@ Additionally, the component will deploy one or more DaemonSets (depending on the
336336

337337
See also the documentation for https://hub.syn.tools/openshift4-nodes/references/parameters.html#_egressinterfaces[parameter `egressInterfaces` in openshift4-nodes].
338338

339+
=== `egress_gateway.shadow_ranges_daemonset_node_selector`
340+
341+
[horizontal]
342+
type:: object
343+
default:: `{}`
344+
345+
This parameter can be set when the DaemonSet that mounts the shadow ranges ConfigMap (see parameter `generate_shadow_ranges_configmap`) should run on a larger set of nodes than the ones indicated by each `egress_ip_ranges` entry's `node_selector`.
346+
347+
The contents of this parameter are used as-is for the DaemonSet's `spec.template.spec.nodeSelector`.
348+
349+
An example configuration where this parameter is useful is when only a subset of nodes in an OpenShift machine config pool are designated egress nodes with an associated shadow range.
350+
In this case, we must ensure that all nodes in the machine config pool can read the shadow ranges ConfigMap, but at the same time we must ensure that policies generated via `egress_ip_ranges.<group>.namespace_egress_ips` only select the nodes that have a shadow range assigned.
351+
352+
NOTE: When setting this parameter, it's the user's responsibility to ensure that the provided DaemonSet node selector selects all nodes that are designated egress nodes.
353+
339354
=== `egress_gateway.egress_ip_ranges`
340355

341356
[horizontal]

0 commit comments

Comments
 (0)