-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for deploying
CiliumLoadBalancerIPPool
and `CiliumBGPPe…
…eringPolicy`
- Loading branch information
Showing
6 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,8 @@ parameters: | |
|
||
bgp: | ||
enabled: false | ||
peerings: {} | ||
loadbalancer_ip_pools: {} | ||
|
||
olm: | ||
source: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local com = import 'lib/commodore.libjsonnet'; | ||
local kap = import 'lib/kapitan.libjsonnet'; | ||
local kube = import 'lib/kube.libjsonnet'; | ||
|
||
local inv = kap.inventory(); | ||
local params = inv.parameters.cilium; | ||
|
||
local CiliumLoadBalancerIPPool(name) = | ||
kube._Object('cilium.io/v2alpha1', 'CiliumLoadBalancerIPPool', name); | ||
|
||
local CiliumBGPPeeringPolicy(name) = | ||
kube._Object('cilium.io/v2alpha1', 'CiliumBGPPeeringPolicy', name); | ||
|
||
local render_peering(name, peering) = | ||
local render_vrouter(config) = config { | ||
neighbors: std.objectValues(std.mapWithKey( | ||
function(peerAddr, n) n { | ||
peerAddress: peerAddr, | ||
}, | ||
super.neighbors | ||
)), | ||
}; | ||
{ | ||
spec: { | ||
nodeSelector: std.get(peering, 'nodeSelector', {}), | ||
virtualRouters: std.map( | ||
render_vrouter, | ||
std.objectValues(peering.virtualRouters) | ||
), | ||
} + com.makeMergeable(std.get(peering, 'spec', {})), | ||
}; | ||
|
||
local peerings = com.generateResources( | ||
std.mapWithKey(render_peering, params.bgp.peerings), | ||
CiliumBGPPeeringPolicy | ||
); | ||
|
||
local render_ip_pool(name, pool) = | ||
{ | ||
spec: { | ||
cidrs: std.objectValues(pool.cidrs), | ||
serviceSelector: std.get(pool, 'serviceSelector', {}), | ||
} + com.makeMergeable(std.get(pool, 'spec', {})), | ||
}; | ||
|
||
local lb_ip_pools = com.generateResources( | ||
std.mapWithKey(render_ip_pool, params.bgp.loadbalancer_ip_pools), | ||
CiliumLoadBalancerIPPool, | ||
); | ||
|
||
{ | ||
[if params.bgp.enabled && std.length(peerings) > 0 then | ||
'40_bgp_peerings']: peerings, | ||
[if params.bgp.enabled && std.length(lb_ip_pools) > 0 then | ||
'40_loadbalancer_ip_pools']: lb_ip_pools, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/golden/bgp-control-plane/cilium/cilium/40_bgp_peerings.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: cilium.io/v2alpha1 | ||
kind: CiliumBGPPeeringPolicy | ||
metadata: | ||
annotations: {} | ||
labels: | ||
name: lb-services | ||
name: lb-services | ||
spec: | ||
nodeSelector: | ||
matchLabels: | ||
node-role.kubernetes.io/infra: '' | ||
virtualRouters: | ||
- exportPodCIDR: false | ||
localASN: 64512 | ||
neighbors: | ||
- peerASN: 64512 | ||
peerAddress: 192.0.2.2/32 | ||
- peerASN: 64512 | ||
peerAddress: 192.0.2.3/32 | ||
serviceSelector: | ||
matchLabels: | ||
syn.tools/load-balancer-class: cilium | ||
- localASN: 64513 | ||
neighbors: | ||
- peerASN: 64513 | ||
peerAddress: 192.0.2.100/32 |
28 changes: 28 additions & 0 deletions
28
tests/golden/bgp-control-plane/cilium/cilium/40_loadbalancer_ip_pools.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: cilium.io/v2alpha1 | ||
kind: CiliumLoadBalancerIPPool | ||
metadata: | ||
annotations: {} | ||
labels: | ||
name: lb-services | ||
name: lb-services | ||
spec: | ||
cidrs: | ||
- cidr: 198.51.100.32/27 | ||
- start: 203.0.113.10 | ||
stop: 203.0.113.20 | ||
serviceSelector: | ||
matchLabels: | ||
syn.tools/load-balancer-class: cilium | ||
--- | ||
apiVersion: cilium.io/v2alpha1 | ||
kind: CiliumLoadBalancerIPPool | ||
metadata: | ||
annotations: {} | ||
labels: | ||
name: lb-services-2 | ||
name: lb-services-2 | ||
spec: | ||
cidrs: | ||
- cidr: 203.0.113.32/27 | ||
enabled: false | ||
serviceSelector: {} |