Skip to content

Commit

Permalink
Migrate FeatureGates type of kube-proxy from string to map[string]bool
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangpengzhao committed Feb 11, 2018
1 parent 317853c commit 57071d8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/kube-proxy/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (o *Options) Complete() error {
} else {
o.config = c
// Make sure we apply the feature gate settings in the config file.
utilfeature.DefaultFeatureGate.Set(o.config.FeatureGates)
utilfeature.DefaultFeatureGate.SetFromMap(o.config.FeatureGates)
}
}

Expand Down
6 changes: 4 additions & 2 deletions cmd/kube-proxy/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/util/diff"
utilfeature "k8s.io/apiserver/pkg/util/feature"
api "k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
"k8s.io/kubernetes/pkg/proxy/ipvs"
"k8s.io/kubernetes/pkg/util/configz"
Expand Down Expand Up @@ -413,7 +414,8 @@ conntrack:
min: 1
tcpCloseWaitTimeout: 10s
tcpEstablishedTimeout: 20s
featureGates: "all"
featureGates:
SupportIPVSProxyMode: true
healthzBindAddress: "%s"
hostnameOverride: "foo"
iptables:
Expand Down Expand Up @@ -524,7 +526,7 @@ udpIdleTimeout: 123ms
TCPCloseWaitTimeout: &metav1.Duration{Duration: 10 * time.Second},
TCPEstablishedTimeout: &metav1.Duration{Duration: 20 * time.Second},
},
FeatureGates: "all",
FeatureGates: map[string]bool{string(features.SupportIPVSProxyMode): true},
HealthzBindAddress: tc.healthzBindAddress,
HostnameOverride: "foo",
IPTables: kubeproxyconfig.KubeProxyIPTablesConfiguration{
Expand Down
10 changes: 2 additions & 8 deletions pkg/proxy/apis/kubeproxyconfig/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,8 @@ type KubeProxyConntrackConfiguration struct {
type KubeProxyConfiguration struct {
metav1.TypeMeta

// TODO FeatureGates really should be a map but that requires refactoring all
// components to use config files because local-up-cluster.sh only supports
// the --feature-gates flag right now, which is comma-separated key=value
// pairs.
//
// featureGates is a comma-separated list of key=value pairs that control
// which alpha/beta features are enabled.
FeatureGates string
// featureGates is a map of feature names to bools that enable or disable alpha/experimental features.
FeatureGates map[string]bool

// bindAddress is the IP address for the proxy server to serve on (set to 0.0.0.0
// for all interfaces)
Expand Down
3 changes: 3 additions & 0 deletions pkg/proxy/apis/kubeproxyconfig/v1alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,7 @@ func SetDefaults_KubeProxyConfiguration(obj *KubeProxyConfiguration) {
if obj.ClientConnection.Burst == 0 {
obj.ClientConnection.Burst = 10
}
if obj.FeatureGates == nil {
obj.FeatureGates = make(map[string]bool)
}
}
10 changes: 2 additions & 8 deletions pkg/proxy/apis/kubeproxyconfig/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,8 @@ type KubeProxyConntrackConfiguration struct {
type KubeProxyConfiguration struct {
metav1.TypeMeta `json:",inline"`

// TODO FeatureGates really should be a map but that requires refactoring all
// components to use config files because local-up-cluster.sh only supports
// the --feature-gates flag right now, which is comma-separated key=value
// pairs.
//
// featureGates is a comma-separated list of key=value pairs that control
// which alpha/beta features are enabled.
FeatureGates string `json:"featureGates"`
// featureGates is a map of feature names to bools that enable or disable alpha/experimental features.
FeatureGates map[string]bool `json:"featureGates,omitempty"`

// bindAddress is the IP address for the proxy server to serve on (set to 0.0.0.0
// for all interfaces)
Expand Down

0 comments on commit 57071d8

Please sign in to comment.