Skip to content

Commit b2b2546

Browse files
authored
Merge pull request kubernetes#70755 from ereslibre/remove-feature-gates-from-join-configuration
kubeadm: Remove feature gates from JoinConfiguration
2 parents 62d9999 + fb88c19 commit b2b2546

File tree

12 files changed

+79
-50
lines changed

12 files changed

+79
-50
lines changed

cmd/kubeadm/app/apis/kubeadm/types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,6 @@ type JoinConfiguration struct {
295295

296296
// APIEndpoint represents the endpoint of the instance of the API server eventually to be deployed on this node.
297297
APIEndpoint APIEndpoint
298-
299-
// FeatureGates enabled by the user.
300-
FeatureGates map[string]bool
301298
}
302299

303300
// Discovery specifies the options for the kubelet to use during the TLS Bootstrap process

cmd/kubeadm/app/apis/kubeadm/v1alpha3/BUILD

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ filegroup(
4747

4848
go_test(
4949
name = "go_default_test",
50-
srcs = ["bootstraptokenstring_test.go"],
50+
srcs = [
51+
"bootstraptokenstring_test.go",
52+
"conversion_test.go",
53+
],
5154
embed = [":go_default_library"],
52-
deps = ["//vendor/github.com/pkg/errors:go_default_library"],
55+
deps = [
56+
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
57+
"//cmd/kubeadm/app/apis/kubeadm/scheme:go_default_library",
58+
"//cmd/kubeadm/test:go_default_library",
59+
"//vendor/github.com/pkg/errors:go_default_library",
60+
],
5361
)

cmd/kubeadm/app/apis/kubeadm/v1alpha3/conversion.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha3
1818

1919
import (
20+
"github.com/pkg/errors"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
"k8s.io/apimachinery/pkg/conversion"
2223
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
@@ -28,6 +29,10 @@ func Convert_v1alpha3_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinCon
2829
return err
2930
}
3031

32+
if len(in.FeatureGates) != 0 {
33+
return errors.New("featureGates has been removed from JoinConfiguration and featureGates from ClusterConfiguration will be used instead. Please cleanup JoinConfiguration.FeatureGates fields")
34+
}
35+
3136
out.Discovery.Timeout = in.DiscoveryTimeout
3237

3338
if len(in.TLSBootstrapToken) != 0 {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright 2018 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1alpha3_test
18+
19+
import (
20+
"testing"
21+
22+
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
23+
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
24+
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha3"
25+
testutil "k8s.io/kubernetes/cmd/kubeadm/test"
26+
)
27+
28+
func TestJoinConfigurationConversion(t *testing.T) {
29+
testcases := map[string]struct {
30+
old *v1alpha3.JoinConfiguration
31+
expectedErr string
32+
}{
33+
"conversion succeeds": {
34+
old: &v1alpha3.JoinConfiguration{},
35+
expectedErr: "",
36+
},
37+
"feature gates fails to be converted": {
38+
old: &v1alpha3.JoinConfiguration{
39+
FeatureGates: map[string]bool{
40+
"someGate": true,
41+
},
42+
},
43+
expectedErr: "featureGates has been removed from JoinConfiguration and featureGates from ClusterConfiguration will be used instead. Please cleanup JoinConfiguration.FeatureGates fields",
44+
},
45+
}
46+
for _, tc := range testcases {
47+
internal := &kubeadm.JoinConfiguration{}
48+
err := scheme.Scheme.Convert(tc.old, internal, nil)
49+
if len(tc.expectedErr) != 0 {
50+
testutil.AssertError(t, err, tc.expectedErr)
51+
} else if err != nil {
52+
t.Errorf("no error was expected but '%s' was found", err)
53+
}
54+
}
55+
}

cmd/kubeadm/app/apis/kubeadm/v1alpha3/zz_generated.conversion.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kubeadm/app/apis/kubeadm/v1beta1/types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,6 @@ type JoinConfiguration struct {
274274

275275
// APIEndpoint represents the endpoint of the instance of the API server eventually to be deployed on this node.
276276
APIEndpoint APIEndpoint `json:"apiEndpoint,omitempty"`
277-
278-
// FeatureGates enabled by the user.
279-
FeatureGates map[string]bool `json:"featureGates,omitempty"`
280277
}
281278

282279
// Discovery specifies the options for the kubelet to use during the TLS Bootstrap process

cmd/kubeadm/app/apis/kubeadm/v1beta1/zz_generated.conversion.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kubeadm/app/apis/kubeadm/v1beta1/zz_generated.deepcopy.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kubeadm/app/apis/kubeadm/zz_generated.deepcopy.go

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/kubeadm/app/cmd/join.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"io"
2323
"os"
2424
"path/filepath"
25-
"strings"
2625
"text/template"
2726

2827
"github.com/golang/glog"
@@ -164,7 +163,6 @@ func NewCmdJoin(out io.Writer) *cobra.Command {
164163

165164
var token string
166165
var cfgPath string
167-
var featureGatesString string
168166
var ignorePreflightErrors []string
169167

170168
cmd := &cobra.Command{
@@ -192,13 +190,13 @@ func NewCmdJoin(out io.Writer) *cobra.Command {
192190
cfg.Discovery.TLSBootstrapToken = token
193191
}
194192

195-
j, err := NewValidJoin(cmd.PersistentFlags(), cfg, cfgPath, featureGatesString, ignorePreflightErrors)
193+
j, err := NewValidJoin(cmd.PersistentFlags(), cfg, cfgPath, ignorePreflightErrors)
196194
kubeadmutil.CheckErr(err)
197195
kubeadmutil.CheckErr(j.Run(out))
198196
},
199197
}
200198

201-
AddJoinConfigFlags(cmd.PersistentFlags(), cfg, &featureGatesString, &token)
199+
AddJoinConfigFlags(cmd.PersistentFlags(), cfg, &token)
202200
AddJoinBootstrapTokenDiscoveryFlags(cmd.PersistentFlags(), btd)
203201
AddJoinFileDiscoveryFlags(cmd.PersistentFlags(), fd)
204202
AddJoinOtherFlags(cmd.PersistentFlags(), &cfgPath, &ignorePreflightErrors)
@@ -207,13 +205,10 @@ func NewCmdJoin(out io.Writer) *cobra.Command {
207205
}
208206

209207
// NewValidJoin validates the command line that are passed to the cobra command
210-
func NewValidJoin(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.JoinConfiguration, cfgPath, featureGatesString string, ignorePreflightErrors []string) (*Join, error) {
208+
func NewValidJoin(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.JoinConfiguration, cfgPath string, ignorePreflightErrors []string) (*Join, error) {
211209
var err error
212-
if cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, featureGatesString); err != nil {
213-
return nil, err
214-
}
215210

216-
if err := validation.ValidateMixedArguments(flagSet); err != nil {
211+
if err = validation.ValidateMixedArguments(flagSet); err != nil {
217212
return nil, err
218213
}
219214

@@ -226,17 +221,13 @@ func NewValidJoin(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.JoinConfiguratio
226221
}
227222

228223
// AddJoinConfigFlags adds join flags bound to the config to the specified flagset
229-
func AddJoinConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.JoinConfiguration, featureGatesString *string, token *string) {
224+
func AddJoinConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta1.JoinConfiguration, token *string) {
230225
flagSet.StringVar(
231226
&cfg.NodeRegistration.Name, "node-name", cfg.NodeRegistration.Name,
232227
"Specify the node name.")
233228
flagSet.StringVar(
234229
token, "token", "",
235230
"Use this token for both discovery-token and tls-bootstrap-token when those values are not provided.")
236-
flagSet.StringVar(
237-
featureGatesString, "feature-gates", *featureGatesString,
238-
"A set of key=value pairs that describe feature gates for various features. "+
239-
"Options are:\n"+strings.Join(features.KnownFeatures(&features.InitFeatureGates), "\n"))
240231
flagSet.StringVar(
241232
&cfg.NodeRegistration.CRISocket, "cri-socket", cfg.NodeRegistration.CRISocket,
242233
`Specify the CRI socket to connect to.`,
@@ -503,7 +494,7 @@ func (j *Join) BootstrapKubelet(tlsBootstrapCfg *clientcmdapi.Config) error {
503494
// register the joining node with the specified taints if the node
504495
// is not a master. The markmaster phase will register the taints otherwise.
505496
registerTaintsUsingFlags := !j.cfg.ControlPlane
506-
if err := kubeletphase.WriteKubeletDynamicEnvFile(&j.cfg.NodeRegistration, j.cfg.FeatureGates, registerTaintsUsingFlags, kubeadmconstants.KubeletRunDirectory); err != nil {
497+
if err := kubeletphase.WriteKubeletDynamicEnvFile(&j.cfg.NodeRegistration, j.initCfg.FeatureGates, registerTaintsUsingFlags, kubeadmconstants.KubeletRunDirectory); err != nil {
507498
return err
508499
}
509500

@@ -532,7 +523,7 @@ func (j *Join) BootstrapKubelet(tlsBootstrapCfg *clientcmdapi.Config) error {
532523
}
533524

534525
// This feature is disabled by default in kubeadm
535-
if features.Enabled(j.cfg.FeatureGates, features.DynamicKubeletConfig) {
526+
if features.Enabled(j.initCfg.FeatureGates, features.DynamicKubeletConfig) {
536527
if err := kubeletphase.EnableDynamicConfigForNode(client, j.cfg.NodeRegistration.Name, kubeletVersion); err != nil {
537528
return errors.Wrap(err, "error consuming base kubelet configuration")
538529
}

0 commit comments

Comments
 (0)