Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Calico BGP support for load balancer #51

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
description: Helm chart for Calico BGP
name: calico-bgp
version: 0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.bgp.enabled }}
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 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.bgp.enabled }}
{{- 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 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bgp:
enabled: false
logSeverityScreen: Info
nodeToNodeMeshEnabled: false
listenPort: 179
bindMode: NodeIP
asNumber:
peers: []
3 changes: 3 additions & 0 deletions charts/internal/shoot-system-components/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ cloud-controller-manager:

metallb:
enabled: false

calico-bgp:
enabled: false
150 changes: 150 additions & 0 deletions hack/api-reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,142 @@ string
</tr>
</tbody>
</table>
<h3 id="metal.provider.extensions.gardener.cloud/v1alpha1.BgpPeer">BgpPeer
</h3>
<p>
(<em>Appears on:</em>
<a href="#metal.provider.extensions.gardener.cloud/v1alpha1.CalicoBgpConfig">CalicoBgpConfig</a>)
</p>
<p>
<p>BgpPeer contains configuration for BGPPeer resource.</p>
</p>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>peerIP</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>PeerIP contains IP address of BGP peer followed by an optional port number to peer with.</p>
</td>
</tr>
<tr>
<td>
<code>asNumber</code></br>
<em>
int
</em>
</td>
<td>
<em>(Optional)</em>
<p>ASNumber contains the AS number of the BGP peer.</p>
</td>
</tr>
<tr>
<td>
<code>nodeSelector</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>NodeSelector is a key-value pair to select nodes that should have this peering.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="metal.provider.extensions.gardener.cloud/v1alpha1.CalicoBgpConfig">CalicoBgpConfig
</h3>
<p>
(<em>Appears on:</em>
<a href="#metal.provider.extensions.gardener.cloud/v1alpha1.LoadBalancerConfig">LoadBalancerConfig</a>)
</p>
<p>
<p>CalicoBgpConfig contains BGP configuration settings for calico.</p>
</p>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>asNumber</code></br>
<em>
int
</em>
</td>
<td>
<em>(Optional)</em>
<p>ASNumber is the default AS number used by a node.</p>
</td>
</tr>
<tr>
<td>
<code>serviceLoadBalancerIPs</code></br>
<em>
[]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ServiceLoadBalancerIPs are the CIDR blocks for Kubernetes Service LoadBalancer IPs.</p>
</td>
</tr>
<tr>
<td>
<code>serviceExternalIPs</code></br>
<em>
[]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ServiceExternalIPs are the CIDR blocks for Kubernetes Service External IPs.</p>
</td>
</tr>
<tr>
<td>
<code>serviceClusterIPs</code></br>
<em>
[]string
</em>
</td>
<td>
<em>(Optional)</em>
<p>ServiceClusterIPs are the CIDR blocks from which service cluster IPs are allocated.</p>
</td>
</tr>
<tr>
<td>
<code>bgpPeer</code></br>
<em>
<a href="#metal.provider.extensions.gardener.cloud/v1alpha1.BgpPeer">
[]BgpPeer
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>BGPPeer contains configuration for BGPPeer resource.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="metal.provider.extensions.gardener.cloud/v1alpha1.CloudControllerManagerConfig">CloudControllerManagerConfig
</h3>
<p>
Expand Down Expand Up @@ -257,6 +393,20 @@ MetallbConfig
<p>MetallbConfig contains configuration settings for metallb.</p>
</td>
</tr>
<tr>
<td>
<code>calicoBgpConfig</code></br>
<em>
<a href="#metal.provider.extensions.gardener.cloud/v1alpha1.CalicoBgpConfig">
CalicoBgpConfig
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>CalicoBgpConfig contains configuration settings for calico.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="metal.provider.extensions.gardener.cloud/v1alpha1.MachineImage">MachineImage
Expand Down
33 changes: 33 additions & 0 deletions pkg/apis/metal/types_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type CloudControllerManagerConfig struct {
type LoadBalancerConfig struct {
// MetallbConfig contains configuration settings for metallb.
MetallbConfig *MetallbConfig

// CalicoBgpConfig contains configuration settings for calico.
CalicoBgpConfig *CalicoBgpConfig
}

// MetallbConfig contains configuration settings for metallb.
Expand All @@ -44,3 +47,33 @@ type MetallbConfig struct {
// EnableL2Advertisement enables L2 advertisement.
EnableL2Advertisement bool
}

// CalicoBgpConfig contains BGP configuration settings for calico.
type CalicoBgpConfig struct {
// ASNumber is the default AS number used by a node.
ASNumber int

// ServiceLoadBalancerIPs are the CIDR blocks for Kubernetes Service LoadBalancer IPs.
ServiceLoadBalancerIPs []string

// ServiceExternalIPs are the CIDR blocks for Kubernetes Service External IPs.
ServiceExternalIPs []string

// ServiceClusterIPs are the CIDR blocks from which service cluster IPs are allocated.
ServiceClusterIPs []string

// BGPPeer contains configuration for BGPPeer resource.
BgpPeer []BgpPeer
}

// BgpPeer contains configuration for BGPPeer resource.
type BgpPeer struct {
// PeerIP contains IP address of BGP peer followed by an optional port number to peer with.
PeerIP string

// ASNumber contains the AS number of the BGP peer.
ASNumber int

// NodeSelector is a key-value pair to select nodes that should have this peering.
NodeSelector string
}
42 changes: 42 additions & 0 deletions pkg/apis/metal/v1alpha1/types_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type LoadBalancerConfig struct {
// MetallbConfig contains configuration settings for metallb.
// +optional
MetallbConfig *MetallbConfig `json:"metallbConfig,omitempty"`

// CalicoBgpConfig contains configuration settings for calico.
// +optional
CalicoBgpConfig *CalicoBgpConfig `json:"calicoBgpConfig,omitempty"`
}

// MetallbConfig contains configuration settings for metallb.
Expand All @@ -51,3 +55,41 @@ type MetallbConfig struct {
// +optional
EnableL2Advertisement bool `json:"enableL2Advertisement,omitempty"`
}

// CalicoBgpConfig contains BGP configuration settings for calico.
type CalicoBgpConfig struct {
// ASNumber is the default AS number used by a node.
// +optional
ASNumber int `json:"asNumber,omitempty"`

// ServiceLoadBalancerIPs are the CIDR blocks for Kubernetes Service LoadBalancer IPs.
// +optional
ServiceLoadBalancerIPs []string `json:"serviceLoadBalancerIPs,omitempty"`

// ServiceExternalIPs are the CIDR blocks for Kubernetes Service External IPs.
// +optional
ServiceExternalIPs []string `json:"serviceExternalIPs,omitempty"`

// ServiceClusterIPs are the CIDR blocks from which service cluster IPs are allocated.
// +optional
ServiceClusterIPs []string `json:"serviceClusterIPs,omitempty"`

// BGPPeer contains configuration for BGPPeer resource.
// +optional
BgpPeer []BgpPeer `json:"bgpPeer,omitempty"`
}

// BgpPeer contains configuration for BGPPeer resource.
type BgpPeer struct {
// PeerIP contains IP address of BGP peer followed by an optional port number to peer with.
// +optional
PeerIP string `json:"peerIP,omitempty"`

// ASNumber contains the AS number of the BGP peer.
// +optional
ASNumber int `json:"asNumber,omitempty"`

// NodeSelector is a key-value pair to select nodes that should have this peering.
// +optional
NodeSelector string `json:"nodeSelector,omitempty"`
}
26 changes: 19 additions & 7 deletions pkg/apis/metal/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading