From a47e99e37ac7d3cd2099d10df1ff250d1a110fd5 Mon Sep 17 00:00:00 2001 From: ksubrmnn Date: Fri, 11 Jan 2019 14:45:34 -0800 Subject: [PATCH] Add Windows flags for KubeProxyConfiguration --- cmd/kube-proxy/app/init_windows.go | 3 ++ cmd/kube-proxy/app/server_windows.go | 1 + pkg/proxy/apis/config/types.go | 16 ++++++++ .../v1alpha1/zz_generated.conversion.go | 40 +++++++++++++++++++ .../apis/config/zz_generated.deepcopy.go | 17 ++++++++ .../kube-proxy/config/v1alpha1/types.go | 16 ++++++++ .../config/v1alpha1/zz_generated.deepcopy.go | 17 ++++++++ 7 files changed, 110 insertions(+) diff --git a/cmd/kube-proxy/app/init_windows.go b/cmd/kube-proxy/app/init_windows.go index 85cafcda53..5db0b703f4 100644 --- a/cmd/kube-proxy/app/init_windows.go +++ b/cmd/kube-proxy/app/init_windows.go @@ -37,4 +37,7 @@ func initForOS(windowsService bool) error { func (o *Options) addOSFlags(fs *pflag.FlagSet) { fs.BoolVar(&o.WindowsService, "windows-service", o.WindowsService, "Enable Windows Service Control Manager API integration") + fs.StringVar(&o.config.Winkernel.SourceVip, "source-vip", o.config.Winkernel.SourceVip, "The IP address of the source VIP for non-DSR.") + fs.StringVar(&o.config.Winkernel.NetworkName, "network-name", o.config.Winkernel.NetworkName, "The name of the cluster network.") + fs.BoolVar(&o.config.Winkernel.EnableDSR, "enable-dsr", o.config.Winkernel.EnableDSR, "If true make kube-proxy apply DSR policies for service VIP") } diff --git a/cmd/kube-proxy/app/server_windows.go b/cmd/kube-proxy/app/server_windows.go index 5ef2ce1618..5aba6cf665 100644 --- a/cmd/kube-proxy/app/server_windows.go +++ b/cmd/kube-proxy/app/server_windows.go @@ -110,6 +110,7 @@ func newProxyServer(config *proxyconfigapi.KubeProxyConfiguration, cleanupAndExi utilnode.GetNodeIP(client, hostname), recorder, healthzUpdater, + config.Winkernel, ) if err != nil { return nil, fmt.Errorf("unable to create proxier: %v", err) diff --git a/pkg/proxy/apis/config/types.go b/pkg/proxy/apis/config/types.go index 2c79debd69..a9d0b88493 100644 --- a/pkg/proxy/apis/config/types.go +++ b/pkg/proxy/apis/config/types.go @@ -78,6 +78,20 @@ type KubeProxyConntrackConfiguration struct { TCPCloseWaitTimeout *metav1.Duration } +// KubeProxyWinkernelConfiguration contains Windows/HNS settings for +// the Kubernetes proxy server. +type KubeProxyWinkernelConfiguration struct { + // networkName is the name of the network kube-proxy will use + // to create endpoints and policies + NetworkName string + // sourceVip is the IP address of the source VIP endoint used for + // NAT when loadbalancing + SourceVip string + // enableDSR tells kube-proxy whether HNS policies should be created + // with DSR + EnableDSR bool +} + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // KubeProxyConfiguration contains everything necessary to configure the @@ -140,6 +154,8 @@ type KubeProxyConfiguration struct { // If set it to a non-zero IP block, kube-proxy will filter that down to just the IPs that applied to the node. // An empty string slice is meant to select all network interfaces. NodePortAddresses []string + // winkernel contains winkernel-related configuration options. + Winkernel KubeProxyWinkernelConfiguration } // Currently, three modes of proxy are available in Linux platform: 'userspace' (older, going to be EOL), 'iptables' diff --git a/pkg/proxy/apis/config/v1alpha1/zz_generated.conversion.go b/pkg/proxy/apis/config/v1alpha1/zz_generated.conversion.go index eedc7344fc..c360ab20af 100644 --- a/pkg/proxy/apis/config/v1alpha1/zz_generated.conversion.go +++ b/pkg/proxy/apis/config/v1alpha1/zz_generated.conversion.go @@ -78,6 +78,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*v1alpha1.KubeProxyWinkernelConfiguration)(nil), (*config.KubeProxyWinkernelConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_KubeProxyWinkernelConfiguration_To_config_KubeProxyWinkernelConfiguration(a.(*v1alpha1.KubeProxyWinkernelConfiguration), b.(*config.KubeProxyWinkernelConfiguration), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*config.KubeProxyWinkernelConfiguration)(nil), (*v1alpha1.KubeProxyWinkernelConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_config_KubeProxyWinkernelConfiguration_To_v1alpha1_KubeProxyWinkernelConfiguration(a.(*config.KubeProxyWinkernelConfiguration), b.(*v1alpha1.KubeProxyWinkernelConfiguration), scope) + }); err != nil { + return err + } return nil } @@ -108,6 +118,9 @@ func autoConvert_v1alpha1_KubeProxyConfiguration_To_config_KubeProxyConfiguratio } out.ConfigSyncPeriod = in.ConfigSyncPeriod out.NodePortAddresses = *(*[]string)(unsafe.Pointer(&in.NodePortAddresses)) + if err := Convert_v1alpha1_KubeProxyWinkernelConfiguration_To_config_KubeProxyWinkernelConfiguration(&in.Winkernel, &out.Winkernel, s); err != nil { + return err + } return nil } @@ -143,6 +156,9 @@ func autoConvert_config_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguratio } out.ConfigSyncPeriod = in.ConfigSyncPeriod out.NodePortAddresses = *(*[]string)(unsafe.Pointer(&in.NodePortAddresses)) + if err := Convert_config_KubeProxyWinkernelConfiguration_To_v1alpha1_KubeProxyWinkernelConfiguration(&in.Winkernel, &out.Winkernel, s); err != nil { + return err + } return nil } @@ -230,3 +246,27 @@ func autoConvert_config_KubeProxyIPVSConfiguration_To_v1alpha1_KubeProxyIPVSConf func Convert_config_KubeProxyIPVSConfiguration_To_v1alpha1_KubeProxyIPVSConfiguration(in *config.KubeProxyIPVSConfiguration, out *v1alpha1.KubeProxyIPVSConfiguration, s conversion.Scope) error { return autoConvert_config_KubeProxyIPVSConfiguration_To_v1alpha1_KubeProxyIPVSConfiguration(in, out, s) } + +func autoConvert_v1alpha1_KubeProxyWinkernelConfiguration_To_config_KubeProxyWinkernelConfiguration(in *v1alpha1.KubeProxyWinkernelConfiguration, out *config.KubeProxyWinkernelConfiguration, s conversion.Scope) error { + out.NetworkName = in.NetworkName + out.SourceVip = in.SourceVip + out.EnableDSR = in.EnableDSR + return nil +} + +// Convert_v1alpha1_KubeProxyWinkernelConfiguration_To_config_KubeProxyWinkernelConfiguration is an autogenerated conversion function. +func Convert_v1alpha1_KubeProxyWinkernelConfiguration_To_config_KubeProxyWinkernelConfiguration(in *v1alpha1.KubeProxyWinkernelConfiguration, out *config.KubeProxyWinkernelConfiguration, s conversion.Scope) error { + return autoConvert_v1alpha1_KubeProxyWinkernelConfiguration_To_config_KubeProxyWinkernelConfiguration(in, out, s) +} + +func autoConvert_config_KubeProxyWinkernelConfiguration_To_v1alpha1_KubeProxyWinkernelConfiguration(in *config.KubeProxyWinkernelConfiguration, out *v1alpha1.KubeProxyWinkernelConfiguration, s conversion.Scope) error { + out.NetworkName = in.NetworkName + out.SourceVip = in.SourceVip + out.EnableDSR = in.EnableDSR + return nil +} + +// Convert_config_KubeProxyWinkernelConfiguration_To_v1alpha1_KubeProxyWinkernelConfiguration is an autogenerated conversion function. +func Convert_config_KubeProxyWinkernelConfiguration_To_v1alpha1_KubeProxyWinkernelConfiguration(in *config.KubeProxyWinkernelConfiguration, out *v1alpha1.KubeProxyWinkernelConfiguration, s conversion.Scope) error { + return autoConvert_config_KubeProxyWinkernelConfiguration_To_v1alpha1_KubeProxyWinkernelConfiguration(in, out, s) +} diff --git a/pkg/proxy/apis/config/zz_generated.deepcopy.go b/pkg/proxy/apis/config/zz_generated.deepcopy.go index 983b5113b7..04a5dbfe7a 100644 --- a/pkg/proxy/apis/config/zz_generated.deepcopy.go +++ b/pkg/proxy/apis/config/zz_generated.deepcopy.go @@ -74,6 +74,7 @@ func (in *KubeProxyConfiguration) DeepCopyInto(out *KubeProxyConfiguration) { *out = make([]string, len(*in)) copy(*out, *in) } + out.Winkernel = in.Winkernel return } @@ -181,3 +182,19 @@ func (in *KubeProxyIPVSConfiguration) DeepCopy() *KubeProxyIPVSConfiguration { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeProxyWinkernelConfiguration) DeepCopyInto(out *KubeProxyWinkernelConfiguration) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeProxyWinkernelConfiguration. +func (in *KubeProxyWinkernelConfiguration) DeepCopy() *KubeProxyWinkernelConfiguration { + if in == nil { + return nil + } + out := new(KubeProxyWinkernelConfiguration) + in.DeepCopyInto(out) + return out +} diff --git a/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go b/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go index ecf95d68d2..b266a5c3d7 100644 --- a/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go +++ b/staging/src/k8s.io/kube-proxy/config/v1alpha1/types.go @@ -74,6 +74,20 @@ type KubeProxyConntrackConfiguration struct { TCPCloseWaitTimeout *metav1.Duration `json:"tcpCloseWaitTimeout"` } +// KubeProxyWinkernelConfiguration contains Windows/HNS settings for +// the Kubernetes proxy server. +type KubeProxyWinkernelConfiguration struct { + // networkName is the name of the network kube-proxy will use + // to create endpoints and policies + NetworkName string `json:"networkName"` + // sourceVip is the IP address of the source VIP endoint used for + // NAT when loadbalancing + SourceVip string `json:"sourceVip"` + // enableDSR tells kube-proxy whether HNS policies should be created + // with DSR + EnableDSR bool `json:"enableDSR"` +} + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // KubeProxyConfiguration contains everything necessary to configure the @@ -136,6 +150,8 @@ type KubeProxyConfiguration struct { // If set it to a non-zero IP block, kube-proxy will filter that down to just the IPs that applied to the node. // An empty string slice is meant to select all network interfaces. NodePortAddresses []string `json:"nodePortAddresses"` + // winkernel contains winkernel-related configuration options. + Winkernel KubeProxyWinkernelConfiguration `json:"winkernel"` } // Currently, three modes of proxy are available in Linux platform: 'userspace' (older, going to be EOL), 'iptables' diff --git a/staging/src/k8s.io/kube-proxy/config/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/kube-proxy/config/v1alpha1/zz_generated.deepcopy.go index ca70abbdc9..ff0252d416 100644 --- a/staging/src/k8s.io/kube-proxy/config/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/kube-proxy/config/v1alpha1/zz_generated.deepcopy.go @@ -52,6 +52,7 @@ func (in *KubeProxyConfiguration) DeepCopyInto(out *KubeProxyConfiguration) { *out = make([]string, len(*in)) copy(*out, *in) } + out.Winkernel = in.Winkernel return } @@ -159,3 +160,19 @@ func (in *KubeProxyIPVSConfiguration) DeepCopy() *KubeProxyIPVSConfiguration { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubeProxyWinkernelConfiguration) DeepCopyInto(out *KubeProxyWinkernelConfiguration) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeProxyWinkernelConfiguration. +func (in *KubeProxyWinkernelConfiguration) DeepCopy() *KubeProxyWinkernelConfiguration { + if in == nil { + return nil + } + out := new(KubeProxyWinkernelConfiguration) + in.DeepCopyInto(out) + return out +}