Skip to content

Commit

Permalink
Make Weave MTU configurable with default config for jumbo frames
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjennings committed May 22, 2017
1 parent 251eed3 commit c637bb7
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 19 deletions.
5 changes: 4 additions & 1 deletion cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e
case "kopeio-vxlan", "kopeio":
cluster.Spec.Networking.Kopeio = &api.KopeioNetworkingSpec{}
case "weave":
cluster.Spec.Networking.Weave = &api.WeaveNetworkingSpec{}
// AWS supports "jumbo frames" of 9001 bytes and weave adds up to 87 bytes overhead
// sets the default to the largest number that leaves enough overhead and is divisible by 4
jumboFrameMTUSize := int32(8912)
cluster.Spec.Networking.Weave = &api.WeaveNetworkingSpec{MTU: &jumboFrameMTUSize}
case "flannel":
cluster.Spec.Networking.Flannel = &api.FlannelNetworkingSpec{}
case "calico":
Expand Down
39 changes: 21 additions & 18 deletions docs/networking.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
Kubernetes Operations (kops) currently supports 4 networking modes:

* `kubenet` kubernetes native networking via a CNI plugin. This is the default.
* `cni` Container Network Interface(CNI) style networking, often installed via a Daemonset.
* `cni` Container Network Interface(CNI) style networking, often installed via a Daemonset. Kops can configure
several CNI networking providers out of the box, detailed below.
* `classic` kubernetes native networking, done in-process.
* `external` networking is done via a Daemonset. This is used in some custom implementations.

You are able to specify your networking type via command line switch or in your yaml file.
The `--networking` option accepts one of the four values above, or one of the supported CNI options given below.

If `--networking` is left undefined `kubenet` is installed.

### kops Default Networking

Kubernetes Operations (kops) uses `kubenet` networking by default. This sets up networking on AWS using VPC
Expand Down Expand Up @@ -62,17 +68,11 @@ CNI networking providers are not part of the Kubernetes project, we do not maint
their installation processes. With that in mind, we do not support problems with
different CNI providers but support configuring Kubernetes to run CNI providers.

## Specifying network option for cluster creation

You are able to specify your networking type via command line switch or in your yaml file.
The `--networking` option accepts the three different values defined above: `kubenet`, `cni`,
`classic`, and `external`. If `--networking` is left undefined `kubenet` is installed.

### Weave Example for CNI

#### Installation Weave on a new Cluster
#### Installing Weave on a new Cluster

The following command sets up a cluster, in HA mode, that is ready for a CNI installation.
The following command sets up a cluster, in HA mode, with Weave as the CNI and networking policy provider:

```console
$ export $ZONE=mylistofzones
Expand All @@ -81,21 +81,24 @@ $ kops create cluster \
--master-zones $ZONES \
--master-size m4.large \
--node-size m4.large \
--networking cni \
--networking weave \
--yes \
--name myclustername.mydns.io
```

Once the cluster is stable, which you can check with a `kubectl cluster-info` command, the next
step is to install CNI networking. Most of the CNI network providers are
moving to installing their components plugins via a Daemonset. For instance weave will
install with the following command:
The above daemonset installation requires K8s 1.4.x or above.

#### Configuring Weave MTU

```console
$ kubectl create -f https://git.io/weave-kube
```
The default configuration for Weave sets the MTU size to support jumbo frames (which AWS VPC supports).
To change the default configuration, edit the cluster with `kops edit cluster <name>` and update `mtu`.

The above daemonset installation requires K8s 1.4.x or above.
```
spec:
networking:
weave:
mtu: 8912
```

### Calico Example for CNI and Network Policy

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kops/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type KopeioNetworkingSpec struct {

// Weave declares that we want Weave networking
type WeaveNetworkingSpec struct {
MTU *int32 `json:"mtu,omitempty"`
}

// Flannel declares that we want Flannel networking
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kops/v1alpha1/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type KopeioNetworkingSpec struct {

// Weave declares that we want Weave networking
type WeaveNetworkingSpec struct {
MTU *int32 `json:"mtu,omitempty"`
}

// Flannel declares that we want Flannel networking
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha1/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@ func Convert_kops_RBACAuthorizationSpec_To_v1alpha1_RBACAuthorizationSpec(in *ko
}

func autoConvert_v1alpha1_WeaveNetworkingSpec_To_kops_WeaveNetworkingSpec(in *WeaveNetworkingSpec, out *kops.WeaveNetworkingSpec, s conversion.Scope) error {
out.MTU = in.MTU
return nil
}

Expand All @@ -1773,6 +1774,7 @@ func Convert_v1alpha1_WeaveNetworkingSpec_To_kops_WeaveNetworkingSpec(in *WeaveN
}

func autoConvert_kops_WeaveNetworkingSpec_To_v1alpha1_WeaveNetworkingSpec(in *kops.WeaveNetworkingSpec, out *WeaveNetworkingSpec, s conversion.Scope) error {
out.MTU = in.MTU
return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/apis/kops/v1alpha2/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type KopeioNetworkingSpec struct {

// Weave declares that we want Weave networking
type WeaveNetworkingSpec struct {
MTU *int32 `json:"mtu,omitempty"`
}

// Flannel declares that we want Flannel networking
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,7 @@ func Convert_kops_TopologySpec_To_v1alpha2_TopologySpec(in *kops.TopologySpec, o
}

func autoConvert_v1alpha2_WeaveNetworkingSpec_To_kops_WeaveNetworkingSpec(in *WeaveNetworkingSpec, out *kops.WeaveNetworkingSpec, s conversion.Scope) error {
out.MTU = in.MTU
return nil
}

Expand All @@ -1927,6 +1928,7 @@ func Convert_v1alpha2_WeaveNetworkingSpec_To_kops_WeaveNetworkingSpec(in *WeaveN
}

func autoConvert_kops_WeaveNetworkingSpec_To_v1alpha2_WeaveNetworkingSpec(in *kops.WeaveNetworkingSpec, out *WeaveNetworkingSpec, s conversion.Scope) error {
out.MTU = in.MTU
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ spec:
limits:
cpu: 100m
memory: 200Mi
env:
- name: IPALLOC_RANGE
value: {{ .NonMasqueradeCIDR }}
- name: WEAVE_MTU
value: "{{ .Networking.Weave.MTU }}"
- name: weave-npc
image: weaveworks/weave-npc:1.9.4
resources:
Expand All @@ -108,6 +113,11 @@ spec:
memory: 200Mi
securityContext:
privileged: true
env:
- name: IPALLOC_RANGE
value: {{ .NonMasqueradeCIDR }}
- name: WEAVE_MTU
value: "{{ .Networking.Weave.MTU }}"
restartPolicy: Always
tolerations:
- key: node-role.kubernetes.io/master
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ spec:
limits:
cpu: 100m
memory: 200Mi
env:
- name: IPALLOC_RANGE
value: {{ .NonMasqueradeCIDR }}
- name: WEAVE_MTU
value: "{{ .Networking.Weave.MTU }}"
- name: weave-npc
image: weaveworks/weave-npc:1.9.4
resources:
Expand All @@ -69,6 +74,11 @@ spec:
memory: 200Mi
securityContext:
privileged: true
env:
- name: IPALLOC_RANGE
value: {{ .NonMasqueradeCIDR }}
- name: WEAVE_MTU
value: "{{ .Networking.Weave.MTU }}"
restartPolicy: Always
volumes:
- name: weavedb
Expand Down

0 comments on commit c637bb7

Please sign in to comment.