From 4b8679a085c1a285de0c75429c14ff69ddf92462 Mon Sep 17 00:00:00 2001
From: Dmitri Fedotov
Date: Mon, 7 Oct 2024 18:01:53 +0300
Subject: [PATCH] add calico bgp
---
.../charts/calico-bgp/Chart.yaml | 4 +
.../templates/bgpconfiguration.yaml | 29 ++++
.../charts/calico-bgp/templates/bgppeer.yaml | 14 ++
.../charts/calico-bgp/values.yaml | 5 +
.../shoot-system-components/values.yaml | 3 +
hack/api-reference/api.md | 150 ++++++++++++++++++
pkg/apis/metal/types_controlplane.go | 33 ++++
pkg/apis/metal/v1alpha1/types_controlplane.go | 42 +++++
.../metal/v1alpha1/zz_generated.conversion.go | 74 +++++++++
.../metal/v1alpha1/zz_generated.deepcopy.go | 57 +++++++
pkg/apis/metal/zz_generated.deepcopy.go | 57 +++++++
pkg/controller/controlplane/valuesprovider.go | 73 ++++++++-
.../controlplane/valuesprovider_test.go | 118 ++++++++++++++
pkg/metal/types.go | 4 +
14 files changed, 662 insertions(+), 1 deletion(-)
create mode 100644 charts/internal/shoot-system-components/charts/calico-bgp/Chart.yaml
create mode 100644 charts/internal/shoot-system-components/charts/calico-bgp/templates/bgpconfiguration.yaml
create mode 100644 charts/internal/shoot-system-components/charts/calico-bgp/templates/bgppeer.yaml
create mode 100644 charts/internal/shoot-system-components/charts/calico-bgp/values.yaml
diff --git a/charts/internal/shoot-system-components/charts/calico-bgp/Chart.yaml b/charts/internal/shoot-system-components/charts/calico-bgp/Chart.yaml
new file mode 100644
index 0000000..3724431
--- /dev/null
+++ b/charts/internal/shoot-system-components/charts/calico-bgp/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: Helm chart for Calico BGP
+name: calico-bgp
+version: 0.1.0
diff --git a/charts/internal/shoot-system-components/charts/calico-bgp/templates/bgpconfiguration.yaml b/charts/internal/shoot-system-components/charts/calico-bgp/templates/bgpconfiguration.yaml
new file mode 100644
index 0000000..b2453e8
--- /dev/null
+++ b/charts/internal/shoot-system-components/charts/calico-bgp/templates/bgpconfiguration.yaml
@@ -0,0 +1,29 @@
+apiVersion: crd.projectcalico.org/v1
+kind: BGPConfiguration
+metadata:
+ name: default
+spec:
+ logSeverityScreen: {{ .Values.bgp.logSeverityScreen }}
+ nodeToNodeMeshEnabled: {{ .Values.bgp.nodeToNodeMeshEnabled }}
+ asNumber: {{ required ".Values.bgp.asNumber is required" .Values.bgp.asNumber }}
+ {{ if .Values.bgp.serviceLoadBalancerIPs }}
+ serviceLoadBalancerIPs:
+ {{- range $cidr := .Values.bgp.serviceLoadBalancerIPs }}
+ - cidr: {{ $cidr }}
+ {{- end }}
+ {{- end }}
+ {{ if .Values.bgp.serviceExternalIPs }}
+ serviceExternalIPs:
+ {{- range $cidr := .Values.bgp.serviceExternalIPs }}
+ - cidr: {{ $cidr }}
+ {{- end }}
+ {{- end }}
+ {{ if .Values.bgp.serviceClusterIPs }}
+ serviceClusterIPs:
+ {{- range $cidr := .Values.bgp.serviceClusterIPs }}
+ - cidr: {{ $cidr }}
+ {{- end }}
+ {{- end }}
+ listenPort: {{ .Values.bgp.listenPort }}
+ bindMode: {{ .Values.bgp.bindMode }}
+
diff --git a/charts/internal/shoot-system-components/charts/calico-bgp/templates/bgppeer.yaml b/charts/internal/shoot-system-components/charts/calico-bgp/templates/bgppeer.yaml
new file mode 100644
index 0000000..e3a0ad9
--- /dev/null
+++ b/charts/internal/shoot-system-components/charts/calico-bgp/templates/bgppeer.yaml
@@ -0,0 +1,14 @@
+{{- if .Values.bgp.peers }}
+{{- range $peer := .Values.bgp.peers }}
+apiVersion: crd.projectcalico.org/v1
+kind: BGPPeer
+metadata:
+ name: bgppeer-{{ $peer.peerIP }}-{{ $peer.asNumber }}
+spec:
+ asNumber: ${{ required ".peer.asNumber is required" peer.asNumber }}
+ {{- if $peer.nodeSelector }}
+ nodeSelector: {{ $peer.nodeSelector }}
+ {{- end }}
+ peerIP: ${{ required ".peer.peerIP is required" peer.peerIP }}
+{{- end }}
+{{- end }}
diff --git a/charts/internal/shoot-system-components/charts/calico-bgp/values.yaml b/charts/internal/shoot-system-components/charts/calico-bgp/values.yaml
new file mode 100644
index 0000000..532b38a
--- /dev/null
+++ b/charts/internal/shoot-system-components/charts/calico-bgp/values.yaml
@@ -0,0 +1,5 @@
+bgp:
+ logSeverityScreen: Info
+ nodeToNodeMeshEnabled: false
+ listenPort: 179
+ bindMode: NodeIP
diff --git a/charts/internal/shoot-system-components/values.yaml b/charts/internal/shoot-system-components/values.yaml
index ac42ceb..74c8ddf 100644
--- a/charts/internal/shoot-system-components/values.yaml
+++ b/charts/internal/shoot-system-components/values.yaml
@@ -3,3 +3,6 @@ cloud-controller-manager:
metallb:
enabled: false
+
+calico-bgp:
+ enabled: false
diff --git a/hack/api-reference/api.md b/hack/api-reference/api.md
index 8355b88..e5523c4 100644
--- a/hack/api-reference/api.md
+++ b/hack/api-reference/api.md
@@ -180,6 +180,142 @@ string
+
+
+(Appears on:
+CalicoBgpConfig)
+
+
+
BgpPeer contains configuration for BGPPeer resource.
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+peerIP
+
+string
+
+ |
+
+(Optional)
+ PeerIP contains IP address of BGP peer followed by an optional port number to peer with.
+ |
+
+
+
+asNumber
+
+int
+
+ |
+
+(Optional)
+ ASNumber contains the AS number of the BGP peer.
+ |
+
+
+
+nodeSelector
+
+string
+
+ |
+
+(Optional)
+ NodeSelector is a key-value pair to select nodes that should have this peering.
+ |
+
+
+
+
+
+(Appears on:
+LoadBalancerConfig)
+
+
+
CalicoBgpConfig contains BGP configuration settings for calico.
+
+
+
+
+Field |
+Description |
+
+
+
+
+
+asNumber
+
+int
+
+ |
+
+(Optional)
+ ASNumber is the default AS number used by a node.
+ |
+
+
+
+serviceLoadBalancerIPs
+
+[]string
+
+ |
+
+(Optional)
+ ServiceLoadBalancerIPs are the CIDR blocks for Kubernetes Service LoadBalancer IPs.
+ |
+
+
+
+serviceExternalIPs
+
+[]string
+
+ |
+
+(Optional)
+ ServiceExternalIPs are the CIDR blocks for Kubernetes Service External IPs.
+ |
+
+
+
+serviceClusterIPs
+
+[]string
+
+ |
+
+(Optional)
+ ServiceClusterIPs are the CIDR blocks from which service cluster IPs are allocated.
+ |
+
+
+
+bgpPeer
+
+
+[]BgpPeer
+
+
+ |
+
+(Optional)
+ BGPPeer contains configuration for BGPPeer resource.
+ |
+
+
+
@@ -257,6 +393,20 @@ MetallbConfig
MetallbConfig contains configuration settings for metallb.
+
+
+calicoBgpConfig
+
+
+CalicoBgpConfig
+
+
+ |
+
+(Optional)
+ CalicoBgpConfig contains configuration settings for calico.
+ |
+