Skip to content

Commit

Permalink
add calico bgp
Browse files Browse the repository at this point in the history
  • Loading branch information
defo89 committed Oct 7, 2024
1 parent 52f0a24 commit 4b8679a
Show file tree
Hide file tree
Showing 14 changed files with 662 additions and 1 deletion.
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,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 }}

Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bgp:
logSeverityScreen: Info
nodeToNodeMeshEnabled: false
listenPort: 179
bindMode: NodeIP
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.
// +required
ASNumber int `json:"asNumber"`

// 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.
// +required
PeerIP string `json:"peerIP"`

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

// NodeSelector is a key-value pair to select nodes that should have this peering.
// +optional
NodeSelector string `json:"nodeSelector,omitempty"`
}
Loading

0 comments on commit 4b8679a

Please sign in to comment.