Skip to content

Commit

Permalink
Make openshift SDN MTU configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravi Sankar Penta committed Aug 31, 2015
1 parent cac6c64 commit 4663c08
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 22 deletions.
4 changes: 3 additions & 1 deletion pkg/cmd/server/admin/create_nodeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ func (o CreateNodeConfigOptions) MakeNodeConfig(serverCertFile, serverKeyFile, n

MasterKubeConfig: kubeConfigFile,

NetworkPluginName: o.NetworkPluginName,
NetworkConfig: configapi.NodeNetworkConfig{
NetworkPluginName: o.NetworkPluginName,
},
}

if o.UseTLS() {
Expand Down
18 changes: 13 additions & 5 deletions pkg/cmd/server/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type NodeConfig struct {
// DNSIP holds the IP
DNSIP string

// NetworkPluginName is a string specifying the networking plugin
NetworkPluginName string
// NetworkConfig provides network options for the node
NetworkConfig NodeNetworkConfig

// VolumeDir is the directory that volumes will be stored under
VolumeDirectory string
Expand All @@ -71,6 +71,14 @@ type NodeConfig struct {
KubeletArguments ExtendedArguments
}

// NodeNetworkConfig provides network options for the node
type NodeNetworkConfig struct {
// NetworkPluginName is a string specifying the networking plugin
NetworkPluginName string
// Maximum transmission unit for the network packets
MTU uint
}

// DockerConfig holds Docker related configuration options.
type DockerConfig struct {
// ExecHandlerName is the name of the handler to use for executing
Expand Down Expand Up @@ -169,7 +177,7 @@ type MasterConfig struct {
RoutingConfig RoutingConfig

// NetworkConfig to be passed to the compiled in network plugin
NetworkConfig NetworkConfig
NetworkConfig MasterNetworkConfig
}

type ProjectConfig struct {
Expand Down Expand Up @@ -226,8 +234,8 @@ type PolicyConfig struct {
OpenShiftInfrastructureNamespace string
}

// NetworkConfig to be passed to the compiled in network plugin
type NetworkConfig struct {
// MasterNetworkConfig to be passed to the compiled in network plugin
type MasterNetworkConfig struct {
NetworkPluginName string
ClusterNetworkCIDR string
HostSubnetLength uint
Expand Down
15 changes: 15 additions & 0 deletions pkg/cmd/server/api/v1/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ func init() {
obj.PodEvictionTimeout = "5m"
}
},
func(obj *NodeConfig) {
// Defaults/migrations for NetworkConfig
if len(obj.NetworkConfig.NetworkPluginName) == 0 {
obj.NetworkConfig.NetworkPluginName = obj.DeprecatedNetworkPluginName
}
if obj.NetworkConfig.MTU == 0 {
obj.NetworkConfig.MTU = 1450
}
},
func(obj *EtcdStorageConfig) {
if len(obj.KubernetesStorageVersion) == 0 {
obj.KubernetesStorageVersion = "v1"
Expand Down Expand Up @@ -89,6 +98,12 @@ func init() {
panic(err)
}
err = newer.Scheme.AddConversionFuncs(
func(in *NodeConfig, out *newer.NodeConfig, s conversion.Scope) error {
return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
},
func(in *newer.NodeConfig, out *NodeConfig, s conversion.Scope) error {
return s.DefaultConvert(in, out, conversion.IgnoreMissingFields)
},
func(in *ServingInfo, out *newer.ServingInfo, s conversion.Scope) error {
out.BindAddress = in.BindAddress
out.BindNetwork = in.BindNetwork
Expand Down
21 changes: 16 additions & 5 deletions pkg/cmd/server/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ type NodeConfig struct {
// DNSIP holds the IP
DNSIP string `json:"dnsIP"`

// NetworkPluginName is a string specifying the networking plugin
NetworkPluginName string `json:"networkPluginName"`
// Deprecated and maintained for backward compatibility, use NetworkConfig.NetworkPluginName instead
DeprecatedNetworkPluginName string `json:"networkPluginName,omitempty"`

// NetworkConfig provides network options for the node
NetworkConfig NodeNetworkConfig `json:"networkConfig"`

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

// NodeNetworkConfig provides network options for the node
type NodeNetworkConfig struct {
// NetworkPluginName is a string specifying the networking plugin
NetworkPluginName string `json:"networkPluginName"`
// Maximum transmission unit for the network packets
MTU uint `json:"mtu"`
}

// DockerConfig holds Docker related configuration options.
type DockerConfig struct {
// ExecHandlerName is the name of the handler to use for executing
Expand Down Expand Up @@ -150,7 +161,7 @@ type MasterConfig struct {
RoutingConfig RoutingConfig `json:"routingConfig"`

// NetworkConfig to be passed to the compiled in network plugin
NetworkConfig NetworkConfig `json:"networkConfig"`
NetworkConfig MasterNetworkConfig `json:"networkConfig"`
}

type ProjectConfig struct {
Expand Down Expand Up @@ -207,8 +218,8 @@ type RoutingConfig struct {
Subdomain string `json:"subdomain"`
}

// NetworkConfig to be passed to the compiled in network plugin
type NetworkConfig struct {
// MasterNetworkConfig to be passed to the compiled in network plugin
type MasterNetworkConfig struct {
NetworkPluginName string `json:"networkPluginName"`
ClusterNetworkCIDR string `json:"clusterNetworkCIDR"`
HostSubnetLength uint `json:"hostSubnetLength"`
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/server/api/v1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ imageConfig:
latest: false
kind: NodeConfig
masterKubeConfig: ""
networkPluginName: ""
networkConfig:
mtu: 0
networkPluginName: ""
nodeName: ""
podManifestConfig:
fileCheckIntervalSeconds: 0
Expand Down
13 changes: 13 additions & 0 deletions pkg/cmd/server/api/validation/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,26 @@ func ValidateNodeConfig(config *api.NodeConfig) fielderrors.ValidationErrorList
allErrs = append(allErrs, ValidatePodManifestConfig(config.PodManifestConfig).Prefix("podManifestConfig")...)
}

allErrs = append(allErrs, ValidateNetworkConfig(config.NetworkConfig).Prefix("networkConfig")...)

allErrs = append(allErrs, ValidateDockerConfig(config.DockerConfig).Prefix("dockerConfig")...)

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

return allErrs
}

func ValidateNetworkConfig(config api.NodeNetworkConfig) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}

if len(config.NetworkPluginName) > 0 {
if config.MTU == 0 {
allErrs = append(allErrs, fielderrors.NewFieldInvalid("mtu", config.MTU, fmt.Sprintf("must be greater than zero")))
}
}
return allErrs
}

func ValidateDockerConfig(config api.DockerConfig) fielderrors.ValidationErrorList {
allErrs := fielderrors.ValidationErrorList{}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/kubernetes/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func BuildKubernetesNodeConfig(options configapi.NodeConfig) (*NodeConfig, error
server.HealthzPort = 0 // no unsecured healthz access
server.ClusterDNS = dnsIP
server.ClusterDomain = options.DNSDomain
server.NetworkPluginName = options.NetworkPluginName
server.NetworkPluginName = options.NetworkConfig.NetworkPluginName
server.HostNetworkSources = strings.Join([]string{kubelet.ApiserverSource, kubelet.FileSource}, ",")
server.HTTPCheckFrequency = 0 // no remote HTTP pod creation access
server.FileCheckFrequency = time.Duration(fileCheckInterval) * time.Second
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/start/master_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (args MasterArgs) BuildSerializeableMasterConfig() (*configapi.MasterConfig
SecurityAllocator: &configapi.SecurityAllocator{},
},

NetworkConfig: configapi.NetworkConfig{
NetworkConfig: configapi.MasterNetworkConfig{
NetworkPluginName: args.NetworkArgs.NetworkPluginName,
ClusterNetworkCIDR: args.NetworkArgs.ClusterNetworkCIDR,
HostSubnetLength: args.NetworkArgs.HostSubnetLength,
Expand Down
4 changes: 3 additions & 1 deletion pkg/cmd/server/start/node_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ func (args NodeArgs) BuildSerializeableNodeConfig() (*configapi.NodeConfig, erro
Latest: args.ImageFormatArgs.ImageTemplate.Latest,
},

NetworkPluginName: args.NetworkPluginName,
NetworkConfig: configapi.NodeNetworkConfig{
NetworkPluginName: args.NetworkPluginName,
},

VolumeDirectory: args.VolumeDir,
AllowDisabledDocker: args.AllowDisabledDocker,
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/server/start/start_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,17 @@ func RunSDNController(config *kubernetes.NodeConfig, nodeConfig configapi.NodeCo
glog.Fatal("Failed to get kube client for SDN")
}

switch nodeConfig.NetworkPluginName {
switch nodeConfig.NetworkConfig.NetworkPluginName {
case flatsdn.NetworkPluginName():
ch := make(chan struct{})
config.KubeletConfig.StartUpdates = ch
go flatsdn.Node(oclient, config.Client, nodeConfig.NodeName, "", ch)
go flatsdn.Node(oclient, config.Client, nodeConfig.NodeName, "", ch, nodeConfig.NetworkConfig.MTU)
case multitenant.NetworkPluginName():
ch := make(chan struct{})
config.KubeletConfig.StartUpdates = ch
plugin := multitenant.GetKubeNetworkPlugin()
config.KubeletConfig.NetworkPlugins = append(config.KubeletConfig.NetworkPlugins, plugin)
go multitenant.Node(oclient, config.Client, nodeConfig.NodeName, "", ch, plugin)
go multitenant.Node(oclient, config.Client, nodeConfig.NodeName, "", ch, plugin, nodeConfig.NetworkConfig.MTU)
}
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/osdn/flatsdn/flatsdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork s
}
}

func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}) {
func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}, mtu uint) {
osdnInterface := osdn.NewOsdnRegistryInterface(osClient, kClient)
kc, err := ovssubnet.NewKubeController(&osdnInterface, hostname, publicIP, ready)
if err != nil {
glog.Fatalf("SDN initialization failed: %v", err)
}
err = kc.StartNode(false, false)
err = kc.StartNode(false, false, mtu)
if err != nil {
glog.Fatalf("SDN Node failed: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/osdn/multitenant/multitenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Master(osClient *osclient.Client, kClient *kclient.Client, clusterNetwork s
}
}

func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}, plugin knetwork.NetworkPlugin) {
func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, publicIP string, ready chan struct{}, plugin knetwork.NetworkPlugin, mtu uint) {
mp, ok := plugin.(*MultitenantPlugin)
if !ok {
glog.Fatalf("Failed to type cast provided plugin to a multitenant type plugin")
Expand All @@ -48,7 +48,7 @@ func Node(osClient *osclient.Client, kClient *kclient.Client, hostname string, p
glog.Fatalf("SDN initialization failed: %v", err)
}
mp.OvsController = kc
err = kc.StartNode(false, false)
err = kc.StartNode(false, false, mtu)
if err != nil {
glog.Fatalf("SDN Node failed: %v", err)
}
Expand Down

0 comments on commit 4663c08

Please sign in to comment.