Skip to content

Commit 35e6444

Browse files
authored
Merge pull request #111 from projectsyn/migrate-egressgatewaypolicies
Deploy IsovalentEgressGatewayPolicy resources when deploying Cilium EE
2 parents 21d4c79 + 98723cc commit 35e6444

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

component/egress-gateway-policies.jsonnet

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,24 @@ local CiliumEgressGatewayPolicy(name) =
1414
},
1515
};
1616

17+
local IsovalentEgressGatewayPolicy(name) =
18+
kube._Object('isovalent.com/v1', 'IsovalentEgressGatewayPolicy', name) {
19+
metadata+: {
20+
annotations+: {
21+
'argocd.argoproj.io/sync-options': 'SkipDryRunOnMissingResource=true',
22+
},
23+
},
24+
};
25+
26+
local EgressGatewayPolicy(name) =
27+
if params.release == 'enterprise' then
28+
IsovalentEgressGatewayPolicy(name)
29+
else
30+
CiliumEgressGatewayPolicy(name);
1731

1832
local policies = com.generateResources(
1933
params.egress_gateway.policies,
20-
CiliumEgressGatewayPolicy
34+
EgressGatewayPolicy
2135
);
2236

2337
// Convert an IPv4 address in A.B.C.D format that's already been split into an
@@ -101,7 +115,7 @@ local NamespaceEgressPolicy =
101115
debug: 'start=%d, end=%d, ip=%d' % [ start, end, ip ],
102116
};
103117

104-
CiliumEgressGatewayPolicy(namespace) {
118+
EgressGatewayPolicy(namespace) {
105119
metadata+: {
106120
annotations+: {
107121
'cilium.syn.tools/description':

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

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,19 @@ See the https://docs.isovalent.com/operations-guide[Isovalent Cilium Enterprise
198198

199199
This section allows users to configure the [Cilium EgressGatewayPolicy] feature.
200200

201+
[TIP]
202+
====
203+
When deploying Cilium OSS, the component will generate `CiliumEgressGatewayPolicy` resources.
204+
205+
When deploying Cilium EE, the component will generate `IsovalentEgressGatewayPolicy` resources.
206+
====
207+
208+
[NOTE]
209+
====
210+
The current implementation (and therefore examples shown here) has only been tested with Cilium EE.
211+
Please refer to the https://docs.cilium.io/en/stable/network/egress-gateway/#example-policy[example policy in the upstream documentation] for Cilium OSS.
212+
====
213+
201214
=== `egress_gateway.enabled`
202215

203216
[horizontal]
@@ -226,11 +239,14 @@ type:: object
226239
default:: `{}`
227240

228241
This parameter allows users to deploy `CiliumEgressGatewayPolicy` resources.
229-
Each key-value pair in the parameter is converted to a `CiliumEgressGatewayPolicy` resource.
242+
When deploying Cilium EE, the parameter will generate `IsovalentEgressGatewayPolicy` resources instead.
243+
244+
Each key-value pair in the parameter is converted to a `CiliumEgressGatewayPolicy` (or `IsovalentEgressGatewayPolicy`) resource.
230245
Entries can be removed by setting the value to `null`.
231246

232247
==== Example
233248

249+
NOTE: The examples are written for Cilium EE's `IsovalentEgressGatewayPolicy` resources.
234250

235251
[source,yaml]
236252
----
@@ -261,8 +277,8 @@ The component configuration shown above is rendered as follows by the component:
261277

262278
[source,yaml]
263279
----
264-
apiVersion: cilium.io/v2
265-
kind: CiliumEgressGatewayPolicy
280+
apiVersion: isovalent.com/v1
281+
kind: IsovalentEgressGatewayPolicy
266282
metadata:
267283
annotations:
268284
syn.tools/description: |
@@ -302,9 +318,9 @@ See also the documentation for https://hub.syn.tools/openshift4-nodes/references
302318
type:: object
303319
default:: `{}`
304320

305-
This parameter allows users to configure `CiliumEgressGatewayPolicy` resources which assign a single egress IP to a namespace according to the design selected in https://kb.vshn.ch/oc4/explanations/decisions/cloudscale-cilium-egressip.html[Floating egress IPs with Cilium on cloudscale].
321+
This parameter allows users to configure `CiliumEgressGatewayPolicy` (or `IsovalentEgressGatewayPolicy`) resources which assign a single egress IP to a namespace according to the design selected in https://kb.vshn.ch/oc4/explanations/decisions/cloudscale-cilium-egressip.html[Floating egress IPs with Cilium on cloudscale].
306322

307-
Each entry in the parameter is intended to describe a group of dummy interfaces that can be used in `CiliumEgressGatewayPolicy` resources.
323+
Each entry in the parameter is intended to describe a group of dummy interfaces that can be used in `CiliumEgressGatewayPolicy` (or `IsovalentEgressGatewayPolicy`) resources.
308324
The component expects that each value is an object with fields `egress_range`, `node_selector`, `namespace_egress_ips`, and `shadow_ranges`.
309325

310326
NOTE: Field `shadow_ranges` is optional, see the section on <<_shadow_ranges,shadow ranges>> for more details.
@@ -338,7 +354,7 @@ The easiest option to do so is to define a link-local route for `192.0.2.0/25` o
338354

339355
==== Policy generation
340356

341-
The component will generate one `CiliumEgressGatewayPolicy` for each key-value pair in field `namespace_egress_ips` for each egress range.
357+
The component will generate one `CiliumEgressGatewayPolicy` (or `IsovalentEgressGatewayPolicy`) for each key-value pair in field `namespace_egress_ips` for each egress range.
342358

343359
NOTE: The compilation will abort with an error if the same namespace appears in multiple egress range definitions.
344360

@@ -387,12 +403,12 @@ egress_ip_ranges:
387403
infra-bar: 198.51.100.64 - 198.51.100.95
388404
----
389405

390-
The configuration shown above results in the two `CiliumEgressGatewayPolicy` resources shown below.
406+
The configuration shown above results in the two `IsovalentEgressGatewayPolicy` resources shown below.
391407

392408
[source,yaml]
393409
----
394-
apiVersion: cilium.io/v2
395-
kind: CiliumEgressGatewayPolicy
410+
apiVersion: isovalent.com/v1
411+
kind: IsovalentEgressGatewayPolicy
396412
metadata:
397413
annotations: <1>
398414
cilium.syn.tools/description: Generated policy to assign egress IP 192.0.2.61
@@ -417,8 +433,8 @@ spec:
417433
matchLabels:
418434
io.kubernetes.pod.namespace: bar <6>
419435
---
420-
apiVersion: cilium.io/v2
421-
kind: CiliumEgressGatewayPolicy
436+
apiVersion: isovalent.com/v1
437+
kind: IsovalentEgressGatewayPolicy
422438
metadata:
423439
annotations: <1>
424440
cilium.syn.tools/description: Generated policy to assign egress IP 192.0.2.32
@@ -445,7 +461,7 @@ spec:
445461
----
446462
<1> The component adds a number of annotations that contain the input data that was used to generate the policy.
447463
Additionally, the component adds an annotation that gives a human-readable description of the policy.
448-
<2> The namespace name is used as the name for the `CiliumEgressGatewayPolicy` resource.
464+
<2> The namespace name is used as the name for the `IsovalentEgressGatewayPolicy` resource.
449465
<3> The policy always masquerades all traffic from the namespace with the defined egress IP.
450466
<4> The policy uses the key in `egress_ip_ranges` and the offset of the selected egress IP into the range to generate the name of the dummy interface that's expected to be assigned the shadow IPs that map to the egress IP.
451467
<5> The policy uses the node selector that's defined in the parameter.
@@ -500,7 +516,7 @@ spec:
500516
----
501517
<1> The contents of the ConfigMap are generated in the format that the systemd unit managed by component `openshift4-nodes` expects.
502518
<2> The DaemonSet mounts the `eip-shadow-ranges` ConfigMap as a volume.
503-
<3> The DaemonSet is scheduled using the same node selector that's used for the `CiliumEgressGatewayPolicy` resources
519+
<3> The DaemonSet is scheduled using the same node selector that's used for the `IsovalentEgressGatewayPolicy` resources
504520

505521
== Example
506522

0 commit comments

Comments
 (0)