Skip to content

Commit 4663c08

Browse files
author
Ravi Sankar Penta
committed
Make openshift SDN MTU configurable
1 parent cac6c64 commit 4663c08

File tree

12 files changed

+75
-22
lines changed

12 files changed

+75
-22
lines changed

pkg/cmd/server/admin/create_nodeconfig.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ func (o CreateNodeConfigOptions) MakeNodeConfig(serverCertFile, serverKeyFile, n
376376

377377
MasterKubeConfig: kubeConfigFile,
378378

379-
NetworkPluginName: o.NetworkPluginName,
379+
NetworkConfig: configapi.NodeNetworkConfig{
380+
NetworkPluginName: o.NetworkPluginName,
381+
},
380382
}
381383

382384
if o.UseTLS() {

pkg/cmd/server/api/types.go

+13-5
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type NodeConfig struct {
4646
// DNSIP holds the IP
4747
DNSIP string
4848

49-
// NetworkPluginName is a string specifying the networking plugin
50-
NetworkPluginName string
49+
// NetworkConfig provides network options for the node
50+
NetworkConfig NodeNetworkConfig
5151

5252
// VolumeDir is the directory that volumes will be stored under
5353
VolumeDirectory string
@@ -71,6 +71,14 @@ type NodeConfig struct {
7171
KubeletArguments ExtendedArguments
7272
}
7373

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+
7482
// DockerConfig holds Docker related configuration options.
7583
type DockerConfig struct {
7684
// ExecHandlerName is the name of the handler to use for executing
@@ -169,7 +177,7 @@ type MasterConfig struct {
169177
RoutingConfig RoutingConfig
170178

171179
// NetworkConfig to be passed to the compiled in network plugin
172-
NetworkConfig NetworkConfig
180+
NetworkConfig MasterNetworkConfig
173181
}
174182

175183
type ProjectConfig struct {
@@ -226,8 +234,8 @@ type PolicyConfig struct {
226234
OpenShiftInfrastructureNamespace string
227235
}
228236

229-
// NetworkConfig to be passed to the compiled in network plugin
230-
type NetworkConfig struct {
237+
// MasterNetworkConfig to be passed to the compiled in network plugin
238+
type MasterNetworkConfig struct {
231239
NetworkPluginName string
232240
ClusterNetworkCIDR string
233241
HostSubnetLength uint

pkg/cmd/server/api/v1/conversions.go

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ func init() {
4343
obj.PodEvictionTimeout = "5m"
4444
}
4545
},
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+
},
4655
func(obj *EtcdStorageConfig) {
4756
if len(obj.KubernetesStorageVersion) == 0 {
4857
obj.KubernetesStorageVersion = "v1"
@@ -89,6 +98,12 @@ func init() {
8998
panic(err)
9099
}
91100
err = newer.Scheme.AddConversionFuncs(
101+
func(in *NodeConfig, out *newer.NodeConfig, s conversion.Scope) error {
102+
return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
103+
},
104+
func(in *newer.NodeConfig, out *NodeConfig, s conversion.Scope) error {
105+
return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
106+
},
92107
func(in *ServingInfo, out *newer.ServingInfo, s conversion.Scope) error {
93108
out.BindAddress = in.BindAddress
94109
out.BindNetwork = in.BindNetwork

pkg/cmd/server/api/v1/types.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ type NodeConfig struct {
2727
// DNSIP holds the IP
2828
DNSIP string `json:"dnsIP"`
2929

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"`
3235

3336
// VolumeDirectory is the directory that volumes will be stored under
3437
VolumeDirectory string `json:"volumeDirectory"`
@@ -52,6 +55,14 @@ type NodeConfig struct {
5255
KubeletArguments ExtendedArguments `json:"kubeletArguments,omitempty"`
5356
}
5457

58+
// NodeNetworkConfig provides network options for the node
59+
type NodeNetworkConfig struct {
60+
// NetworkPluginName is a string specifying the networking plugin
61+
NetworkPluginName string `json:"networkPluginName"`
62+
// Maximum transmission unit for the network packets
63+
MTU uint `json:"mtu"`
64+
}
65+
5566
// DockerConfig holds Docker related configuration options.
5667
type DockerConfig struct {
5768
// ExecHandlerName is the name of the handler to use for executing
@@ -150,7 +161,7 @@ type MasterConfig struct {
150161
RoutingConfig RoutingConfig `json:"routingConfig"`
151162

152163
// NetworkConfig to be passed to the compiled in network plugin
153-
NetworkConfig NetworkConfig `json:"networkConfig"`
164+
NetworkConfig MasterNetworkConfig `json:"networkConfig"`
154165
}
155166

156167
type ProjectConfig struct {
@@ -207,8 +218,8 @@ type RoutingConfig struct {
207218
Subdomain string `json:"subdomain"`
208219
}
209220

210-
// NetworkConfig to be passed to the compiled in network plugin
211-
type NetworkConfig struct {
221+
// MasterNetworkConfig to be passed to the compiled in network plugin
222+
type MasterNetworkConfig struct {
212223
NetworkPluginName string `json:"networkPluginName"`
213224
ClusterNetworkCIDR string `json:"clusterNetworkCIDR"`
214225
HostSubnetLength uint `json:"hostSubnetLength"`

pkg/cmd/server/api/v1/types_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ imageConfig:
2626
latest: false
2727
kind: NodeConfig
2828
masterKubeConfig: ""
29-
networkPluginName: ""
29+
networkConfig:
30+
mtu: 0
31+
networkPluginName: ""
3032
nodeName: ""
3133
podManifestConfig:
3234
fileCheckIntervalSeconds: 0

pkg/cmd/server/api/validation/node.go

+13
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,26 @@ func ValidateNodeConfig(config *api.NodeConfig) fielderrors.ValidationErrorList
3333
allErrs = append(allErrs, ValidatePodManifestConfig(config.PodManifestConfig).Prefix("podManifestConfig")...)
3434
}
3535

36+
allErrs = append(allErrs, ValidateNetworkConfig(config.NetworkConfig).Prefix("networkConfig")...)
37+
3638
allErrs = append(allErrs, ValidateDockerConfig(config.DockerConfig).Prefix("dockerConfig")...)
3739

3840
allErrs = append(allErrs, ValidateKubeletExtendedArguments(config.KubeletArguments).Prefix("kubeletArguments")...)
3941

4042
return allErrs
4143
}
4244

45+
func ValidateNetworkConfig(config api.NodeNetworkConfig) fielderrors.ValidationErrorList {
46+
allErrs := fielderrors.ValidationErrorList{}
47+
48+
if len(config.NetworkPluginName) > 0 {
49+
if config.MTU == 0 {
50+
allErrs = append(allErrs, fielderrors.NewFieldInvalid("mtu", config.MTU, fmt.Sprintf("must be greater than zero")))
51+
}
52+
}
53+
return allErrs
54+
}
55+
4356
func ValidateDockerConfig(config api.DockerConfig) fielderrors.ValidationErrorList {
4457
allErrs := fielderrors.ValidationErrorList{}
4558

pkg/cmd/server/kubernetes/node_config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig) (*NodeConfig, error
112112
server.HealthzPort = 0 // no unsecured healthz access
113113
server.ClusterDNS = dnsIP
114114
server.ClusterDomain = options.DNSDomain
115-
server.NetworkPluginName = options.NetworkPluginName
115+
server.NetworkPluginName = options.NetworkConfig.NetworkPluginName
116116
server.HostNetworkSources = strings.Join([]string{kubelet.ApiserverSource, kubelet.FileSource}, ",")
117117
server.HTTPCheckFrequency = 0 // no remote HTTP pod creation access
118118
server.FileCheckFrequency = time.Duration(fileCheckInterval) * time.Second

pkg/cmd/server/start/master_args.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (args MasterArgs) BuildSerializeableMasterConfig() (*configapi.MasterConfig
240240
SecurityAllocator: &configapi.SecurityAllocator{},
241241
},
242242

243-
NetworkConfig: configapi.NetworkConfig{
243+
NetworkConfig: configapi.MasterNetworkConfig{
244244
NetworkPluginName: args.NetworkArgs.NetworkPluginName,
245245
ClusterNetworkCIDR: args.NetworkArgs.ClusterNetworkCIDR,
246246
HostSubnetLength: args.NetworkArgs.HostSubnetLength,

pkg/cmd/server/start/node_args.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ func (args NodeArgs) BuildSerializeableNodeConfig() (*configapi.NodeConfig, erro
120120
Latest: args.ImageFormatArgs.ImageTemplate.Latest,
121121
},
122122

123-
NetworkPluginName: args.NetworkPluginName,
123+
NetworkConfig: configapi.NodeNetworkConfig{
124+
NetworkPluginName: args.NetworkPluginName,
125+
},
124126

125127
VolumeDirectory: args.VolumeDir,
126128
AllowDisabledDocker: args.AllowDisabledDocker,

pkg/cmd/server/start/start_node.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,17 @@ func RunSDNController(config *kubernetes.NodeConfig, nodeConfig configapi.NodeCo
245245
glog.Fatal("Failed to get kube client for SDN")
246246
}
247247

248-
switch nodeConfig.NetworkPluginName {
248+
switch nodeConfig.NetworkConfig.NetworkPluginName {
249249
case flatsdn.NetworkPluginName():
250250
ch := make(chan struct{})
251251
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)
253253
case multitenant.NetworkPluginName():
254254
ch := make(chan struct{})
255255
config.KubeletConfig.StartUpdates = ch
256256
plugin := multitenant.GetKubeNetworkPlugin()
257257
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)
259259
}
260260
}
261261

plugins/osdn/flatsdn/flatsdn.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork s
3636
}
3737
}
3838

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) {
4040
osdnInterface := osdn.NewOsdnRegistryInterface(osClient, kClient)
4141
kc, err := ovssubnet.NewKubeController(&osdnInterface, hostname, publicIP, ready)
4242
if err != nil {
4343
glog.Fatalf("SDN initialization failed: %v", err)
4444
}
45-
err = kc.StartNode(false, false)
45+
err = kc.StartNode(false, false, mtu)
4646
if err != nil {
4747
glog.Fatalf("SDN Node failed: %v", err)
4848
}

plugins/osdn/multitenant/multitenant.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork s
3737
}
3838
}
3939

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) {
4141
mp, ok := plugin.(*MultitenantPlugin)
4242
if !ok {
4343
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
4848
glog.Fatalf("SDN initialization failed: %v", err)
4949
}
5050
mp.OvsController = kc
51-
err = kc.StartNode(false, false)
51+
err = kc.StartNode(false, false, mtu)
5252
if err != nil {
5353
glog.Fatalf("SDN Node failed: %v", err)
5454
}

0 commit comments

Comments
 (0)