Browse code

Make openshift SDN MTU configurable

Ravi Sankar Penta authored on 2015/08/07 05:55:53
Showing 12 changed files
... ...
@@ -376,7 +376,9 @@ func (o CreateNodeConfigOptions) MakeNodeConfig(serverCertFile, serverKeyFile, n
376 376
 
377 377
 		MasterKubeConfig: kubeConfigFile,
378 378
 
379
-		NetworkPluginName: o.NetworkPluginName,
379
+		NetworkConfig: configapi.NodeNetworkConfig{
380
+			NetworkPluginName: o.NetworkPluginName,
381
+		},
380 382
 	}
381 383
 
382 384
 	if o.UseTLS() {
... ...
@@ -46,8 +46,8 @@ type NodeConfig struct {
46 46
 	// DNSIP holds the IP
47 47
 	DNSIP string
48 48
 
49
-	// NetworkPluginName is a string specifying the networking plugin
50
-	NetworkPluginName string
49
+	// NetworkConfig provides network options for the node
50
+	NetworkConfig NodeNetworkConfig
51 51
 
52 52
 	// VolumeDir is the directory that volumes will be stored under
53 53
 	VolumeDirectory string
... ...
@@ -71,6 +71,14 @@ type NodeConfig struct {
71 71
 	KubeletArguments ExtendedArguments
72 72
 }
73 73
 
74
+// NodeNetworkConfig provides network options for the node
75
+type NodeNetworkConfig struct {
76
+	// NetworkPluginName is a string specifying the networking plugin
77
+	NetworkPluginName string
78
+	// Maximum transmission unit for the network packets
79
+	MTU uint
80
+}
81
+
74 82
 // DockerConfig holds Docker related configuration options.
75 83
 type DockerConfig struct {
76 84
 	// ExecHandlerName is the name of the handler to use for executing
... ...
@@ -169,7 +177,7 @@ type MasterConfig struct {
169 169
 	RoutingConfig RoutingConfig
170 170
 
171 171
 	// NetworkConfig to be passed to the compiled in network plugin
172
-	NetworkConfig NetworkConfig
172
+	NetworkConfig MasterNetworkConfig
173 173
 }
174 174
 
175 175
 type ProjectConfig struct {
... ...
@@ -226,8 +234,8 @@ type PolicyConfig struct {
226 226
 	OpenShiftInfrastructureNamespace string
227 227
 }
228 228
 
229
-// NetworkConfig to be passed to the compiled in network plugin
230
-type NetworkConfig struct {
229
+// MasterNetworkConfig to be passed to the compiled in network plugin
230
+type MasterNetworkConfig struct {
231 231
 	NetworkPluginName  string
232 232
 	ClusterNetworkCIDR string
233 233
 	HostSubnetLength   uint
... ...
@@ -43,6 +43,15 @@ func init() {
43 43
 				obj.PodEvictionTimeout = "5m"
44 44
 			}
45 45
 		},
46
+		func(obj *NodeConfig) {
47
+			// Defaults/migrations for NetworkConfig
48
+			if len(obj.NetworkConfig.NetworkPluginName) == 0 {
49
+				obj.NetworkConfig.NetworkPluginName = obj.DeprecatedNetworkPluginName
50
+			}
51
+			if obj.NetworkConfig.MTU == 0 {
52
+				obj.NetworkConfig.MTU = 1450
53
+			}
54
+		},
46 55
 		func(obj *EtcdStorageConfig) {
47 56
 			if len(obj.KubernetesStorageVersion) == 0 {
48 57
 				obj.KubernetesStorageVersion = "v1"
... ...
@@ -89,6 +98,12 @@ func init() {
89 89
 		panic(err)
90 90
 	}
91 91
 	err = newer.Scheme.AddConversionFuncs(
92
+		func(in *NodeConfig, out *newer.NodeConfig, s conversion.Scope) error {
93
+			return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
94
+		},
95
+		func(in *newer.NodeConfig, out *NodeConfig, s conversion.Scope) error {
96
+			return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
97
+		},
92 98
 		func(in *ServingInfo, out *newer.ServingInfo, s conversion.Scope) error {
93 99
 			out.BindAddress = in.BindAddress
94 100
 			out.BindNetwork = in.BindNetwork
... ...
@@ -27,8 +27,11 @@ type NodeConfig struct {
27 27
 	// DNSIP holds the IP
28 28
 	DNSIP string `json:"dnsIP"`
29 29
 
30
-	// NetworkPluginName is a string specifying the networking plugin
31
-	NetworkPluginName string `json:"networkPluginName"`
30
+	// Deprecated and maintained for backward compatibility, use NetworkConfig.NetworkPluginName instead
31
+	DeprecatedNetworkPluginName string `json:"networkPluginName,omitempty"`
32
+
33
+	// NetworkConfig provides network options for the node
34
+	NetworkConfig NodeNetworkConfig `json:"networkConfig"`
32 35
 
33 36
 	// VolumeDirectory is the directory that volumes will be stored under
34 37
 	VolumeDirectory string `json:"volumeDirectory"`
... ...
@@ -52,6 +55,14 @@ type NodeConfig struct {
52 52
 	KubeletArguments ExtendedArguments `json:"kubeletArguments,omitempty"`
53 53
 }
54 54
 
55
+// NodeNetworkConfig provides network options for the node
56
+type NodeNetworkConfig struct {
57
+	// NetworkPluginName is a string specifying the networking plugin
58
+	NetworkPluginName string `json:"networkPluginName"`
59
+	// Maximum transmission unit for the network packets
60
+	MTU uint `json:"mtu"`
61
+}
62
+
55 63
 // DockerConfig holds Docker related configuration options.
56 64
 type DockerConfig struct {
57 65
 	// ExecHandlerName is the name of the handler to use for executing
... ...
@@ -150,7 +161,7 @@ type MasterConfig struct {
150 150
 	RoutingConfig RoutingConfig `json:"routingConfig"`
151 151
 
152 152
 	// NetworkConfig to be passed to the compiled in network plugin
153
-	NetworkConfig NetworkConfig `json:"networkConfig"`
153
+	NetworkConfig MasterNetworkConfig `json:"networkConfig"`
154 154
 }
155 155
 
156 156
 type ProjectConfig struct {
... ...
@@ -207,8 +218,8 @@ type RoutingConfig struct {
207 207
 	Subdomain string `json:"subdomain"`
208 208
 }
209 209
 
210
-// NetworkConfig to be passed to the compiled in network plugin
211
-type NetworkConfig struct {
210
+// MasterNetworkConfig to be passed to the compiled in network plugin
211
+type MasterNetworkConfig struct {
212 212
 	NetworkPluginName  string `json:"networkPluginName"`
213 213
 	ClusterNetworkCIDR string `json:"clusterNetworkCIDR"`
214 214
 	HostSubnetLength   uint   `json:"hostSubnetLength"`
... ...
@@ -26,7 +26,9 @@ imageConfig:
26 26
   latest: false
27 27
 kind: NodeConfig
28 28
 masterKubeConfig: ""
29
-networkPluginName: ""
29
+networkConfig:
30
+  mtu: 0
31
+  networkPluginName: ""
30 32
 nodeName: ""
31 33
 podManifestConfig:
32 34
   fileCheckIntervalSeconds: 0
... ...
@@ -33,6 +33,8 @@ func ValidateNodeConfig(config *api.NodeConfig) fielderrors.ValidationErrorList
33 33
 		allErrs = append(allErrs, ValidatePodManifestConfig(config.PodManifestConfig).Prefix("podManifestConfig")...)
34 34
 	}
35 35
 
36
+	allErrs = append(allErrs, ValidateNetworkConfig(config.NetworkConfig).Prefix("networkConfig")...)
37
+
36 38
 	allErrs = append(allErrs, ValidateDockerConfig(config.DockerConfig).Prefix("dockerConfig")...)
37 39
 
38 40
 	allErrs = append(allErrs, ValidateKubeletExtendedArguments(config.KubeletArguments).Prefix("kubeletArguments")...)
... ...
@@ -40,6 +42,17 @@ func ValidateNodeConfig(config *api.NodeConfig) fielderrors.ValidationErrorList
40 40
 	return allErrs
41 41
 }
42 42
 
43
+func ValidateNetworkConfig(config api.NodeNetworkConfig) fielderrors.ValidationErrorList {
44
+	allErrs := fielderrors.ValidationErrorList{}
45
+
46
+	if len(config.NetworkPluginName) > 0 {
47
+		if config.MTU == 0 {
48
+			allErrs = append(allErrs, fielderrors.NewFieldInvalid("mtu", config.MTU, fmt.Sprintf("must be greater than zero")))
49
+		}
50
+	}
51
+	return allErrs
52
+}
53
+
43 54
 func ValidateDockerConfig(config api.DockerConfig) fielderrors.ValidationErrorList {
44 55
 	allErrs := fielderrors.ValidationErrorList{}
45 56
 
... ...
@@ -112,7 +112,7 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig) (*NodeConfig, error
112 112
 	server.HealthzPort = 0  // no unsecured healthz access
113 113
 	server.ClusterDNS = dnsIP
114 114
 	server.ClusterDomain = options.DNSDomain
115
-	server.NetworkPluginName = options.NetworkPluginName
115
+	server.NetworkPluginName = options.NetworkConfig.NetworkPluginName
116 116
 	server.HostNetworkSources = strings.Join([]string{kubelet.ApiserverSource, kubelet.FileSource}, ",")
117 117
 	server.HTTPCheckFrequency = 0 // no remote HTTP pod creation access
118 118
 	server.FileCheckFrequency = time.Duration(fileCheckInterval) * time.Second
... ...
@@ -240,7 +240,7 @@ func (args MasterArgs) BuildSerializeableMasterConfig() (*configapi.MasterConfig
240 240
 			SecurityAllocator: &configapi.SecurityAllocator{},
241 241
 		},
242 242
 
243
-		NetworkConfig: configapi.NetworkConfig{
243
+		NetworkConfig: configapi.MasterNetworkConfig{
244 244
 			NetworkPluginName:  args.NetworkArgs.NetworkPluginName,
245 245
 			ClusterNetworkCIDR: args.NetworkArgs.ClusterNetworkCIDR,
246 246
 			HostSubnetLength:   args.NetworkArgs.HostSubnetLength,
... ...
@@ -120,7 +120,9 @@ func (args NodeArgs) BuildSerializeableNodeConfig() (*configapi.NodeConfig, erro
120 120
 			Latest: args.ImageFormatArgs.ImageTemplate.Latest,
121 121
 		},
122 122
 
123
-		NetworkPluginName: args.NetworkPluginName,
123
+		NetworkConfig: configapi.NodeNetworkConfig{
124
+			NetworkPluginName: args.NetworkPluginName,
125
+		},
124 126
 
125 127
 		VolumeDirectory:     args.VolumeDir,
126 128
 		AllowDisabledDocker: args.AllowDisabledDocker,
... ...
@@ -245,17 +245,17 @@ func RunSDNController(config *kubernetes.NodeConfig, nodeConfig configapi.NodeCo
245 245
 		glog.Fatal("Failed to get kube client for SDN")
246 246
 	}
247 247
 
248
-	switch nodeConfig.NetworkPluginName {
248
+	switch nodeConfig.NetworkConfig.NetworkPluginName {
249 249
 	case flatsdn.NetworkPluginName():
250 250
 		ch := make(chan struct{})
251 251
 		config.KubeletConfig.StartUpdates = ch
252
-		go flatsdn.Node(oclient, config.Client, nodeConfig.NodeName, "", ch)
252
+		go flatsdn.Node(oclient, config.Client, nodeConfig.NodeName, "", ch, nodeConfig.NetworkConfig.MTU)
253 253
 	case multitenant.NetworkPluginName():
254 254
 		ch := make(chan struct{})
255 255
 		config.KubeletConfig.StartUpdates = ch
256 256
 		plugin := multitenant.GetKubeNetworkPlugin()
257 257
 		config.KubeletConfig.NetworkPlugins = append(config.KubeletConfig.NetworkPlugins, plugin)
258
-		go multitenant.Node(oclient, config.Client, nodeConfig.NodeName, "", ch, plugin)
258
+		go multitenant.Node(oclient, config.Client, nodeConfig.NodeName, "", ch, plugin, nodeConfig.NetworkConfig.MTU)
259 259
 	}
260 260
 }
261 261
 
... ...
@@ -36,13 +36,13 @@ func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork s
36 36
 	}
37 37
 }
38 38
 
39
-func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}) {
39
+func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}, mtu uint) {
40 40
 	osdnInterface := osdn.NewOsdnRegistryInterface(osClient, kClient)
41 41
 	kc, err := ovssubnet.NewKubeController(&osdnInterface, hostname, publicIP, ready)
42 42
 	if err != nil {
43 43
 		glog.Fatalf("SDN initialization failed: %v", err)
44 44
 	}
45
-	err = kc.StartNode(false, false)
45
+	err = kc.StartNode(false, false, mtu)
46 46
 	if err != nil {
47 47
 		glog.Fatalf("SDN Node failed: %v", err)
48 48
 	}
... ...
@@ -37,7 +37,7 @@ func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork s
37 37
 	}
38 38
 }
39 39
 
40
-func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}, plugin knetwork.NetworkPlugin) {
40
+func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}, plugin knetwork.NetworkPlugin, mtu uint) {
41 41
 	mp, ok := plugin.(*MultitenantPlugin)
42 42
 	if !ok {
43 43
 		glog.Fatalf("Failed to type cast provided plugin to a multitenant type plugin")
... ...
@@ -48,7 +48,7 @@ func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, p
48 48
 		glog.Fatalf("SDN initialization failed: %v", err)
49 49
 	}
50 50
 	mp.OvsController = kc
51
-	err = kc.StartNode(false, false)
51
+	err = kc.StartNode(false, false, mtu)
52 52
 	if err != nil {
53 53
 		glog.Fatalf("SDN Node failed: %v", err)
54 54
 	}