Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #502 from jiangytcn/feat-calico-mtu
Browse files Browse the repository at this point in the history
feat: configure shoot worker node calico port mtu
  • Loading branch information
rfranzke committed Dec 18, 2019
2 parents 6f88e74 + a6c0b9c commit 4c3d2be
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
# Configure the Calico backend to use.
calico_backend: "{{ .Values.config.backend }}"
# Configure the MTU to use
veth_mtu: "1440"
veth_mtu: "{{ .Values.config.veth_mtu }}"
# The CNI network configuration to install on each node.
cni_network_config: |-
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
global:
podCIDR: ""
config:
veth_mtu: 1440
backend: bird
ipam:
type: "host-local"
Expand Down
2 changes: 2 additions & 0 deletions controllers/networking-calico/docs/usage-as-end-user.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ kind: NetworkConfig
ipam:
type: host-local
cidr: usePodCIDR
vethMTU: 1440
backend: bird
typha:
enabled: true
Expand Down Expand Up @@ -70,6 +71,7 @@ spec:
kind: NetworkConfig
ipam:
type: host-local
vethMTU: 1440
backend: bird
typha:
enabled: false
Expand Down
12 changes: 12 additions & 0 deletions controllers/networking-calico/hack/api-reference/calico.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ Typha
</tr>
<tr>
<td>
<code>vethMTU</code></br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>VethMTU settings used to configure calico port mtu</p>
</td>
</tr>
<tr>
<td>
<code>ipip</code></br>
<em>
<a href="#calico.networking.extensions.gardener.cloud/v1alpha1.IPv4PoolMode">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type NetworkConfig struct {
IPv4 *IPv4
// Typha settings to use for calico-typha component
Typha *Typha
// VethMTU settings used to configure calico port mtu
VethMTU *string

// DEPRECATED.
// IPIP is the IPIP Mode for the IPv4 Pool (e.g. Always, Never, CrossSubnet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ type NetworkConfig struct {
// Typha settings to use for calico-typha component
// +optional
Typha *Typha `json:"typha,omitempty"`
// VethMTU settings used to configure calico port mtu
// +optional
VethMTU *string `json:"vethMTU,omitempty"`

// DEPRECATED.
// IPIP is the IPIP Mode for the IPv4 Pool (e.g. Always, Never, CrossSubnet)
Expand Down

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

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

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

61 changes: 60 additions & 1 deletion controllers/networking-calico/pkg/charts/charts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import (
)

var (
trueVar = true
trueVar = true
mtuVar = "1430"
defaultMtu = "1440"
)

var _ = Describe("Chart package test", func() {
Expand All @@ -55,6 +57,7 @@ var _ = Describe("Chart package test", func() {
networkConfigNil *calicov1alpha1.NetworkConfig
networkConfigBackendNone *calicov1alpha1.NetworkConfig
networkConfigAll *calicov1alpha1.NetworkConfig
networkConfigAllMTU *calicov1alpha1.NetworkConfig
networkConfigDeprecated *calicov1alpha1.NetworkConfig
networkConfigInvalid *calicov1alpha1.NetworkConfig

Expand Down Expand Up @@ -92,6 +95,19 @@ var _ = Describe("Chart package test", func() {
AutoDetectionMethod: &autodetectionMethod,
},
}
networkConfigAllMTU = &calicov1alpha1.NetworkConfig{
Backend: &backendVXLan,
IPAM: &calicov1alpha1.IPAM{
CIDR: &podCIDR,
Type: "host-local",
},
IPv4: &calicov1alpha1.IPv4{
Pool: &poolVXlan,
Mode: &crossSubnet,
AutoDetectionMethod: &autodetectionMethod,
},
VethMTU: &mtuVar,
}
networkConfigDeprecated = &calicov1alpha1.NetworkConfig{
Backend: &backendBird,
IPAM: &calicov1alpha1.IPAM{
Expand Down Expand Up @@ -140,6 +156,7 @@ var _ = Describe("Chart package test", func() {
"typha": map[string]interface{}{
"enabled": trueVar,
},
"veth_mtu": defaultMtu,
"felix": map[string]interface{}{
"ipinip": map[string]interface{}{
"enabled": true,
Expand Down Expand Up @@ -181,6 +198,7 @@ var _ = Describe("Chart package test", func() {
"typha": map[string]interface{}{
"enabled": trueVar,
},
"veth_mtu": defaultMtu,
"felix": map[string]interface{}{
"ipinip": map[string]interface{}{
"enabled": false,
Expand Down Expand Up @@ -222,6 +240,46 @@ var _ = Describe("Chart package test", func() {
"typha": map[string]interface{}{
"enabled": trueVar,
},
"veth_mtu": defaultMtu,
"felix": map[string]interface{}{
"ipinip": map[string]interface{}{
"enabled": true,
},
},
"ipv4": map[string]interface{}{
"pool": string(poolVXlan),
"mode": string(*networkConfigAll.IPv4.Mode),
"autoDetectionMethod": *networkConfigAll.IPv4.AutoDetectionMethod,
},
},
}))
})
It("should correctly compute all of the calico chart values with mtu", func() {
values, err := charts.ComputeCalicoChartValues(network, networkConfigAllMTU)
Expect(err).To(BeNil())
Expect(values).To(Equal(map[string]interface{}{
"images": map[string]interface{}{
"calico-cni": imagevector.CalicoCNIImage(),
"calico-typha": imagevector.CalicoTyphaImage(),
"calico-kube-controllers": imagevector.CalicoKubeControllersImage(),
"calico-node": imagevector.CalicoNodeImage(),
"calico-podtodaemon-flex": imagevector.CalicoFlexVolumeDriverImage(),
"typha-cpa": imagevector.TyphaClusterProportionalAutoscalerImage(),
"typha-cpva": imagevector.TyphaClusterProportionalVerticalAutoscalerImage(),
},
"global": map[string]string{
"podCIDR": network.Spec.PodCIDR,
},
"config": map[string]interface{}{
"backend": string(*networkConfigAll.Backend),
"ipam": map[string]interface{}{
"type": networkConfigAll.IPAM.Type,
"subnet": string(*networkConfigAll.IPAM.CIDR),
},
"typha": map[string]interface{}{
"enabled": trueVar,
},
"veth_mtu": mtuVar,
"felix": map[string]interface{}{
"ipinip": map[string]interface{}{
"enabled": true,
Expand Down Expand Up @@ -263,6 +321,7 @@ var _ = Describe("Chart package test", func() {
"typha": map[string]interface{}{
"enabled": trueVar,
},
"veth_mtu": defaultMtu,
"felix": map[string]interface{}{
"ipinip": map[string]interface{}{
"enabled": true,
Expand Down
7 changes: 7 additions & 0 deletions controllers/networking-calico/pkg/charts/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
const (
hostLocal = "host-local"
usePodCIDR = "usePodCidr"
defaultMTU = "1440"
)

type calicoConfig struct {
Expand All @@ -36,6 +37,7 @@ type calicoConfig struct {
IPv4 ipv4 `json:"ipv4"`
IPAM ipam `json:"ipam"`
Typha typha `json:"typha"`
VethMTU string `json:"veth_mtu"`
}

type felix struct {
Expand Down Expand Up @@ -80,6 +82,7 @@ var defaultCalicoConfig = calicoConfig{
Typha: typha{
Enabled: true,
},
VethMTU: defaultMTU,
}

func newCalicoConfig() calicoConfig {
Expand Down Expand Up @@ -195,5 +198,9 @@ func generateChartValues(config *calicov1alpha1.NetworkConfig) (*calicoConfig, e
c.Typha.Enabled = config.Typha.Enabled
}

if config.VethMTU != nil {
c.VethMTU = *config.VethMTU
}

return &c, nil
}

0 comments on commit 4c3d2be

Please sign in to comment.