Allow setting MTU for calico networking

This commit does the following two changes:

1. Changes the default calico mtu to 8198.
2. Enables setting the mtu explicitly in the config as:
```
  networking:
    calico:
      mtu: 2048
```

Testing done:

1. Created cluster on AWS with networking set to calico. No additional details were provided. Verified that the mtu was set to 8198. Also verified that the FELIX_IPINIPMTU environment variable was set to 8198.
2. Created a cluster explicitly setting the calico mtu to 2048. Verified that the mtu for the 'cali*' interfaces inside the pods was set to 2048. Also, verified that the FELIX_IPINIPMTU environment variable was set to 2048.
3. make test passed.

Closes #4042
This commit is contained in:
Shri Javadekar 2018-06-25 13:30:23 -07:00
parent 3489ea317e
commit e4638de5f4
9 changed files with 43 additions and 3 deletions

View File

@ -83,6 +83,8 @@ type CalicoNetworkingSpec struct {
PrometheusGoMetricsEnabled bool `json:"prometheusGoMetricsEnabled,omitempty"`
// PrometheusProcessMetricsEnabled enables Prometheus process metrics collection
PrometheusProcessMetricsEnabled bool `json:"prometheusProcessMetricsEnabled,omitempty"`
// MTU to be set in the cni-network-config for calico.
MTU *int32 `json:"mtu,omitempty"`
}
// CanalNetworkingSpec declares that we want Canal networking

View File

@ -83,6 +83,8 @@ type CalicoNetworkingSpec struct {
PrometheusGoMetricsEnabled bool `json:"prometheusGoMetricsEnabled,omitempty"`
// PrometheusProcessMetricsEnabled enables Prometheus process metrics collection
PrometheusProcessMetricsEnabled bool `json:"prometheusProcessMetricsEnabled,omitempty"`
// MTU to be set in the cni-network-config for calico.
MTU *int32 `json:"mtu,omitempty"`
}
// CanalNetworkingSpec declares that we want Canal networking

View File

@ -425,6 +425,7 @@ func autoConvert_v1alpha1_CalicoNetworkingSpec_To_kops_CalicoNetworkingSpec(in *
out.PrometheusMetricsPort = in.PrometheusMetricsPort
out.PrometheusGoMetricsEnabled = in.PrometheusGoMetricsEnabled
out.PrometheusProcessMetricsEnabled = in.PrometheusProcessMetricsEnabled
out.MTU = in.MTU
return nil
}
@ -440,6 +441,7 @@ func autoConvert_kops_CalicoNetworkingSpec_To_v1alpha1_CalicoNetworkingSpec(in *
out.PrometheusMetricsPort = in.PrometheusMetricsPort
out.PrometheusGoMetricsEnabled = in.PrometheusGoMetricsEnabled
out.PrometheusProcessMetricsEnabled = in.PrometheusProcessMetricsEnabled
out.MTU = in.MTU
return nil
}

View File

@ -280,6 +280,15 @@ func (in *CNINetworkingSpec) DeepCopy() *CNINetworkingSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CalicoNetworkingSpec) DeepCopyInto(out *CalicoNetworkingSpec) {
*out = *in
if in.MTU != nil {
in, out := &in.MTU, &out.MTU
if *in == nil {
*out = nil
} else {
*out = new(int32)
**out = **in
}
}
return
}
@ -2826,7 +2835,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
*out = nil
} else {
*out = new(CalicoNetworkingSpec)
**out = **in
(*in).DeepCopyInto(*out)
}
}
if in.Canal != nil {

View File

@ -83,6 +83,8 @@ type CalicoNetworkingSpec struct {
PrometheusGoMetricsEnabled bool `json:"prometheusGoMetricsEnabled,omitempty"`
// PrometheusProcessMetricsEnabled enables Prometheus process metrics collection
PrometheusProcessMetricsEnabled bool `json:"prometheusProcessMetricsEnabled,omitempty"`
// MTU to be set in the cni-network-config for calico.
MTU *int32 `json:"mtu,omitempty"`
}
// CanalNetworkingSpec declares that we want Canal networking

View File

@ -461,6 +461,7 @@ func autoConvert_v1alpha2_CalicoNetworkingSpec_To_kops_CalicoNetworkingSpec(in *
out.PrometheusMetricsPort = in.PrometheusMetricsPort
out.PrometheusGoMetricsEnabled = in.PrometheusGoMetricsEnabled
out.PrometheusProcessMetricsEnabled = in.PrometheusProcessMetricsEnabled
out.MTU = in.MTU
return nil
}
@ -476,6 +477,7 @@ func autoConvert_kops_CalicoNetworkingSpec_To_v1alpha2_CalicoNetworkingSpec(in *
out.PrometheusMetricsPort = in.PrometheusMetricsPort
out.PrometheusGoMetricsEnabled = in.PrometheusGoMetricsEnabled
out.PrometheusProcessMetricsEnabled = in.PrometheusProcessMetricsEnabled
out.MTU = in.MTU
return nil
}

View File

@ -253,6 +253,15 @@ func (in *CNINetworkingSpec) DeepCopy() *CNINetworkingSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CalicoNetworkingSpec) DeepCopyInto(out *CalicoNetworkingSpec) {
*out = *in
if in.MTU != nil {
in, out := &in.MTU, &out.MTU
if *in == nil {
*out = nil
} else {
*out = new(int32)
**out = **in
}
}
return
}
@ -2907,7 +2916,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
*out = nil
} else {
*out = new(CalicoNetworkingSpec)
**out = **in
(*in).DeepCopyInto(*out)
}
}
if in.Canal != nil {

View File

@ -269,6 +269,15 @@ func (in *CNINetworkingSpec) DeepCopy() *CNINetworkingSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CalicoNetworkingSpec) DeepCopyInto(out *CalicoNetworkingSpec) {
*out = *in
if in.MTU != nil {
in, out := &in.MTU, &out.MTU
if *in == nil {
*out = nil
} else {
*out = new(int32)
**out = **in
}
}
return
}
@ -3102,7 +3111,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
*out = nil
} else {
*out = new(CalicoNetworkingSpec)
**out = **in
(*in).DeepCopyInto(*out)
}
}
if in.Canal != nil {

View File

@ -32,6 +32,7 @@ data:
"etcd_scheme": "https",
{{- end }}
"log_level": "info",
"mtu": {{- or .Networking.Calico.MTU 8981 }},
"ipam": {
"type": "calico-ipam"
},
@ -216,6 +217,8 @@ spec:
value: "{{- or .Networking.Calico.PrometheusProcessMetricsEnabled "true" }}"
- name: FELIX_HEALTHENABLED
value: "true"
- name: FELIX_IPINIPMTU
value: "{{- or .Networking.Calico.MTU 8981 }}"
securityContext:
privileged: true
volumeMounts: