From bb8eec49345acc6084eab40b874e6263c4cd74c1 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Wed, 26 Sep 2018 17:39:18 +0200 Subject: [PATCH 1/2] removal of v1alpha2 --- cmd/kubeadm/app/apis/kubeadm/scheme/scheme.go | 2 - .../kubeadm/v1alpha2/bootstraptokenstring.go | 90 ---- .../v1alpha2/bootstraptokenstring_test.go | 236 --------- .../app/apis/kubeadm/v1alpha2/conversion.go | 191 ------- .../app/apis/kubeadm/v1alpha2/defaults.go | 275 ---------- .../apis/kubeadm/v1alpha2/defaults_unix.go | 26 - .../apis/kubeadm/v1alpha2/defaults_windows.go | 26 - cmd/kubeadm/app/apis/kubeadm/v1alpha2/doc.go | 23 - .../app/apis/kubeadm/v1alpha2/register.go | 64 --- .../app/apis/kubeadm/v1alpha2/types.go | 331 ------------ .../v1alpha2/zz_generated.conversion.go | 479 ------------------ .../kubeadm/v1alpha2/zz_generated.deepcopy.go | 441 ---------------- .../kubeadm/v1alpha2/zz_generated.defaults.go | 56 -- cmd/kubeadm/app/cmd/config.go | 13 +- cmd/kubeadm/app/cmd/config_test.go | 47 +- .../upgrade/testdata/diff_master_config.yaml | 6 +- cmd/kubeadm/app/constants/constants.go | 12 - cmd/kubeadm/app/util/config/cluster.go | 40 +- cmd/kubeadm/app/util/config/cluster_test.go | 24 +- cmd/kubeadm/app/util/config/common.go | 8 +- cmd/kubeadm/app/util/config/common_test.go | 38 +- .../app/util/config/masterconfig_test.go | 35 +- .../app/util/config/nodeconfig_test.go | 35 +- .../testdata/conversion/master/v1alpha2.yaml | 150 ------ .../testdata/conversion/node/v1alpha2.yaml | 16 - .../defaulting/master/incomplete.yaml | 18 - .../testdata/defaulting/node/incomplete.yaml | 9 - .../validation/invalid_mastercfg.yaml | 21 +- .../testdata/validation/invalid_nodecfg.yaml | 15 +- cmd/kubeadm/app/util/marshal.go | 4 +- cmd/kubeadm/test/cmd/init_test.go | 5 +- hack/.golint_failures | 1 - 32 files changed, 85 insertions(+), 2652 deletions(-) delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring_test.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/conversion.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_unix.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_windows.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/doc.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/register.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/types.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.conversion.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.deepcopy.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.defaults.go delete mode 100644 cmd/kubeadm/app/util/config/testdata/conversion/master/v1alpha2.yaml delete mode 100644 cmd/kubeadm/app/util/config/testdata/conversion/node/v1alpha2.yaml delete mode 100644 cmd/kubeadm/app/util/config/testdata/defaulting/master/incomplete.yaml delete mode 100644 cmd/kubeadm/app/util/config/testdata/defaulting/node/incomplete.yaml diff --git a/cmd/kubeadm/app/apis/kubeadm/scheme/scheme.go b/cmd/kubeadm/app/apis/kubeadm/scheme/scheme.go index eddb1eeacf2..5bc5519379a 100644 --- a/cmd/kubeadm/app/apis/kubeadm/scheme/scheme.go +++ b/cmd/kubeadm/app/apis/kubeadm/scheme/scheme.go @@ -23,7 +23,6 @@ import ( "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" - "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha2" "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha3" ) @@ -41,7 +40,6 @@ func init() { // AddToScheme builds the kubeadm scheme using all known versions of the kubeadm api. func AddToScheme(scheme *runtime.Scheme) { utilruntime.Must(kubeadm.AddToScheme(scheme)) - utilruntime.Must(v1alpha2.AddToScheme(scheme)) utilruntime.Must(v1alpha3.AddToScheme(scheme)) utilruntime.Must(scheme.SetVersionPriority(v1alpha3.SchemeGroupVersion)) } diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring.go deleted file mode 100644 index d62d5a7438c..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package v1alpha2 holds the external kubeadm API types of version v1alpha2 -// Note: This file should be kept in sync with the similar one for the internal API -// TODO: The BootstrapTokenString object should move out to either k8s.io/client-go or k8s.io/api in the future -// (probably as part of Bootstrap Tokens going GA). It should not be staged under the kubeadm API as it is now. -package v1alpha2 - -import ( - "fmt" - "strings" - - bootstrapapi "k8s.io/client-go/tools/bootstrap/token/api" - bootstraputil "k8s.io/client-go/tools/bootstrap/token/util" -) - -// BootstrapTokenString is a token of the format abcdef.abcdef0123456789 that is used -// for both validation of the practically of the API server from a joining node's point -// of view and as an authentication method for the node in the bootstrap phase of -// "kubeadm join". This token is and should be short-lived -type BootstrapTokenString struct { - ID string - Secret string -} - -// MarshalJSON implements the json.Marshaler interface. -func (bts BootstrapTokenString) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf(`"%s"`, bts.String())), nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface. -func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error { - // If the token is represented as "", just return quickly without an error - if len(b) == 0 { - return nil - } - - // Remove unnecessary " characters coming from the JSON parser - token := strings.Replace(string(b), `"`, ``, -1) - // Convert the string Token to a BootstrapTokenString object - newbts, err := NewBootstrapTokenString(token) - if err != nil { - return err - } - bts.ID = newbts.ID - bts.Secret = newbts.Secret - return nil -} - -// String returns the string representation of the BootstrapTokenString -func (bts BootstrapTokenString) String() string { - if len(bts.ID) > 0 && len(bts.Secret) > 0 { - return bootstraputil.TokenFromIDAndSecret(bts.ID, bts.Secret) - } - return "" -} - -// NewBootstrapTokenString converts the given Bootstrap Token as a string -// to the BootstrapTokenString object used for serialization/deserialization -// and internal usage. It also automatically validates that the given token -// is of the right format -func NewBootstrapTokenString(token string) (*BootstrapTokenString, error) { - substrs := bootstraputil.BootstrapTokenRegexp.FindStringSubmatch(token) - // TODO: Add a constant for the 3 value here, and explain better why it's needed (other than because how the regexp parsin works) - if len(substrs) != 3 { - return nil, fmt.Errorf("the bootstrap token %q was not of the form %q", token, bootstrapapi.BootstrapTokenPattern) - } - - return &BootstrapTokenString{ID: substrs[1], Secret: substrs[2]}, nil -} - -// NewBootstrapTokenStringFromIDAndSecret is a wrapper around NewBootstrapTokenString -// that allows the caller to specify the ID and Secret separately -func NewBootstrapTokenStringFromIDAndSecret(id, secret string) (*BootstrapTokenString, error) { - return NewBootstrapTokenString(bootstraputil.TokenFromIDAndSecret(id, secret)) -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring_test.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring_test.go deleted file mode 100644 index 0d06bd153e3..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/bootstraptokenstring_test.go +++ /dev/null @@ -1,236 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - "encoding/json" - "fmt" - "reflect" - "testing" -) - -func TestMarshalJSON(t *testing.T) { - var tests = []struct { - bts BootstrapTokenString - expected string - }{ - {BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"}, `"abcdef.abcdef0123456789"`}, - {BootstrapTokenString{ID: "foo", Secret: "bar"}, `"foo.bar"`}, - {BootstrapTokenString{ID: "h", Secret: "b"}, `"h.b"`}, - } - for _, rt := range tests { - b, err := json.Marshal(rt.bts) - if err != nil { - t.Fatalf("json.Marshal returned an unexpected error: %v", err) - } - if string(b) != rt.expected { - t.Errorf( - "failed BootstrapTokenString.MarshalJSON:\n\texpected: %s\n\t actual: %s", - rt.expected, - string(b), - ) - } - } -} - -func TestUnmarshalJSON(t *testing.T) { - var tests = []struct { - input string - bts *BootstrapTokenString - expectedError bool - }{ - {`"f.s"`, &BootstrapTokenString{}, true}, - {`"abcdef."`, &BootstrapTokenString{}, true}, - {`"abcdef:abcdef0123456789"`, &BootstrapTokenString{}, true}, - {`abcdef.abcdef0123456789`, &BootstrapTokenString{}, true}, - {`"abcdef.abcdef0123456789`, &BootstrapTokenString{}, true}, - {`"abcdef.ABCDEF0123456789"`, &BootstrapTokenString{}, true}, - {`"abcdef.abcdef0123456789"`, &BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"}, false}, - {`"123456.aabbccddeeffgghh"`, &BootstrapTokenString{ID: "123456", Secret: "aabbccddeeffgghh"}, false}, - } - for _, rt := range tests { - newbts := &BootstrapTokenString{} - err := json.Unmarshal([]byte(rt.input), newbts) - if (err != nil) != rt.expectedError { - t.Errorf("failed BootstrapTokenString.UnmarshalJSON:\n\texpected error: %t\n\t actual error: %v", rt.expectedError, err) - } else if !reflect.DeepEqual(rt.bts, newbts) { - t.Errorf( - "failed BootstrapTokenString.UnmarshalJSON:\n\texpected: %v\n\t actual: %v", - rt.bts, - newbts, - ) - } - } -} - -func TestJSONRoundtrip(t *testing.T) { - var tests = []struct { - input string - bts *BootstrapTokenString - }{ - {`"abcdef.abcdef0123456789"`, nil}, - {"", &BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"}}, - } - for _, rt := range tests { - if err := roundtrip(rt.input, rt.bts); err != nil { - t.Errorf("failed BootstrapTokenString JSON roundtrip with error: %v", err) - } - } -} - -func roundtrip(input string, bts *BootstrapTokenString) error { - var b []byte - var err error - newbts := &BootstrapTokenString{} - // If string input was specified, roundtrip like this: string -> (unmarshal) -> object -> (marshal) -> string - if len(input) > 0 { - if err := json.Unmarshal([]byte(input), newbts); err != nil { - return fmt.Errorf("expected no unmarshal error, got error: %v", err) - } - if b, err = json.Marshal(newbts); err != nil { - return fmt.Errorf("expected no marshal error, got error: %v", err) - } - if input != string(b) { - return fmt.Errorf( - "expected token: %s\n\t actual: %s", - input, - string(b), - ) - } - } else { // Otherwise, roundtrip like this: object -> (marshal) -> string -> (unmarshal) -> object - if b, err = json.Marshal(bts); err != nil { - return fmt.Errorf("expected no marshal error, got error: %v", err) - } - if err := json.Unmarshal(b, newbts); err != nil { - return fmt.Errorf("expected no unmarshal error, got error: %v", err) - } - if !reflect.DeepEqual(bts, newbts) { - return fmt.Errorf( - "expected object: %v\n\t actual: %v", - bts, - newbts, - ) - } - } - return nil -} - -func TestTokenFromIDAndSecret(t *testing.T) { - var tests = []struct { - bts BootstrapTokenString - expected string - }{ - {BootstrapTokenString{ID: "foo", Secret: "bar"}, "foo.bar"}, - {BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"}, "abcdef.abcdef0123456789"}, - {BootstrapTokenString{ID: "h", Secret: "b"}, "h.b"}, - } - for _, rt := range tests { - actual := rt.bts.String() - if actual != rt.expected { - t.Errorf( - "failed BootstrapTokenString.String():\n\texpected: %s\n\t actual: %s", - rt.expected, - actual, - ) - } - } -} - -func TestNewBootstrapTokenString(t *testing.T) { - var tests = []struct { - token string - expectedError bool - bts *BootstrapTokenString - }{ - {token: "", expectedError: true, bts: nil}, - {token: ".", expectedError: true, bts: nil}, - {token: "1234567890123456789012", expectedError: true, bts: nil}, // invalid parcel size - {token: "12345.1234567890123456", expectedError: true, bts: nil}, // invalid parcel size - {token: ".1234567890123456", expectedError: true, bts: nil}, // invalid parcel size - {token: "123456.", expectedError: true, bts: nil}, // invalid parcel size - {token: "123456:1234567890.123456", expectedError: true, bts: nil}, // invalid separation - {token: "abcdef:1234567890123456", expectedError: true, bts: nil}, // invalid separation - {token: "Abcdef.1234567890123456", expectedError: true, bts: nil}, // invalid token id - {token: "123456.AABBCCDDEEFFGGHH", expectedError: true, bts: nil}, // invalid token secret - {token: "123456.AABBCCD-EEFFGGHH", expectedError: true, bts: nil}, // invalid character - {token: "abc*ef.1234567890123456", expectedError: true, bts: nil}, // invalid character - {token: "abcdef.1234567890123456", expectedError: false, bts: &BootstrapTokenString{ID: "abcdef", Secret: "1234567890123456"}}, - {token: "123456.aabbccddeeffgghh", expectedError: false, bts: &BootstrapTokenString{ID: "123456", Secret: "aabbccddeeffgghh"}}, - {token: "abcdef.abcdef0123456789", expectedError: false, bts: &BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"}}, - {token: "123456.1234560123456789", expectedError: false, bts: &BootstrapTokenString{ID: "123456", Secret: "1234560123456789"}}, - } - for _, rt := range tests { - actual, err := NewBootstrapTokenString(rt.token) - if (err != nil) != rt.expectedError { - t.Errorf( - "failed NewBootstrapTokenString for the token %q\n\texpected error: %t\n\t actual error: %v", - rt.token, - rt.expectedError, - err, - ) - } else if !reflect.DeepEqual(actual, rt.bts) { - t.Errorf( - "failed NewBootstrapTokenString for the token %q\n\texpected: %v\n\t actual: %v", - rt.token, - rt.bts, - actual, - ) - } - } -} - -func TestNewBootstrapTokenStringFromIDAndSecret(t *testing.T) { - var tests = []struct { - id, secret string - expectedError bool - bts *BootstrapTokenString - }{ - {id: "", secret: "", expectedError: true, bts: nil}, - {id: "1234567890123456789012", secret: "", expectedError: true, bts: nil}, // invalid parcel size - {id: "12345", secret: "1234567890123456", expectedError: true, bts: nil}, // invalid parcel size - {id: "", secret: "1234567890123456", expectedError: true, bts: nil}, // invalid parcel size - {id: "123456", secret: "", expectedError: true, bts: nil}, // invalid parcel size - {id: "Abcdef", secret: "1234567890123456", expectedError: true, bts: nil}, // invalid token id - {id: "123456", secret: "AABBCCDDEEFFGGHH", expectedError: true, bts: nil}, // invalid token secret - {id: "123456", secret: "AABBCCD-EEFFGGHH", expectedError: true, bts: nil}, // invalid character - {id: "abc*ef", secret: "1234567890123456", expectedError: true, bts: nil}, // invalid character - {id: "abcdef", secret: "1234567890123456", expectedError: false, bts: &BootstrapTokenString{ID: "abcdef", Secret: "1234567890123456"}}, - {id: "123456", secret: "aabbccddeeffgghh", expectedError: false, bts: &BootstrapTokenString{ID: "123456", Secret: "aabbccddeeffgghh"}}, - {id: "abcdef", secret: "abcdef0123456789", expectedError: false, bts: &BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"}}, - {id: "123456", secret: "1234560123456789", expectedError: false, bts: &BootstrapTokenString{ID: "123456", Secret: "1234560123456789"}}, - } - for _, rt := range tests { - actual, err := NewBootstrapTokenStringFromIDAndSecret(rt.id, rt.secret) - if (err != nil) != rt.expectedError { - t.Errorf( - "failed NewBootstrapTokenStringFromIDAndSecret for the token with id %q and secret %q\n\texpected error: %t\n\t actual error: %v", - rt.id, - rt.secret, - rt.expectedError, - err, - ) - } else if !reflect.DeepEqual(actual, rt.bts) { - t.Errorf( - "failed NewBootstrapTokenStringFromIDAndSecret for the token with id %q and secret %q\n\texpected: %v\n\t actual: %v", - rt.id, - rt.secret, - rt.bts, - actual, - ) - } - } -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/conversion.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/conversion.go deleted file mode 100644 index a5de5c45631..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/conversion.go +++ /dev/null @@ -1,191 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - "unsafe" - - "k8s.io/apimachinery/pkg/conversion" - kubeproxyconfigv1alpha1 "k8s.io/kube-proxy/config/v1alpha1" - kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1" - "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" - "k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs" - kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" - kubeproxyconfig "k8s.io/kubernetes/pkg/proxy/apis/config" -) - -func Convert_v1alpha2_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConfiguration, out *kubeadm.InitConfiguration, s conversion.Scope) error { - if err := autoConvert_v1alpha2_InitConfiguration_To_kubeadm_InitConfiguration(in, out, s); err != nil { - return err - } - if err := split_v1alpha2_InitConfiguration_into_kubeadm_ClusterConfiguration(in, &out.ClusterConfiguration, s); err != nil { - return err - } - if err := split_v1alpha2_InitConfiguration_into_kubeadm_APIEndpoint(in, &out.APIEndpoint, s); err != nil { - return err - } - return nil -} - -func split_v1alpha2_InitConfiguration_into_kubeadm_APIEndpoint(in *InitConfiguration, out *kubeadm.APIEndpoint, s conversion.Scope) error { - out.AdvertiseAddress = in.API.AdvertiseAddress - out.BindPort = in.API.BindPort - // in.API.ControlPlaneEndpoint will be splitted into ClusterConfiguration - return nil -} - -func split_v1alpha2_InitConfiguration_into_kubeadm_ClusterConfiguration(in *InitConfiguration, out *kubeadm.ClusterConfiguration, s conversion.Scope) error { - if err := split_v1alpha2_InitConfiguration_into_kubeadm_ComponentConfigs(in, &out.ComponentConfigs, s); err != nil { - return err - } - if err := Convert_v1alpha2_Networking_To_kubeadm_Networking(&in.Networking, &out.Networking, s); err != nil { - return err - } - if err := Convert_v1alpha2_Etcd_To_kubeadm_Etcd(&in.Etcd, &out.Etcd, s); err != nil { - return err - } - if err := Convert_v1alpha2_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(&in.AuditPolicyConfiguration, &out.AuditPolicyConfiguration, s); err != nil { - return err - } - out.KubernetesVersion = in.KubernetesVersion - out.ControlPlaneEndpoint = in.API.ControlPlaneEndpoint - out.APIServerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.APIServerExtraArgs)) - out.ControllerManagerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ControllerManagerExtraArgs)) - out.SchedulerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.SchedulerExtraArgs)) - out.APIServerExtraVolumes = *(*[]kubeadm.HostPathMount)(unsafe.Pointer(&in.APIServerExtraVolumes)) - out.ControllerManagerExtraVolumes = *(*[]kubeadm.HostPathMount)(unsafe.Pointer(&in.ControllerManagerExtraVolumes)) - out.SchedulerExtraVolumes = *(*[]kubeadm.HostPathMount)(unsafe.Pointer(&in.SchedulerExtraVolumes)) - out.APIServerCertSANs = *(*[]string)(unsafe.Pointer(&in.APIServerCertSANs)) - out.CertificatesDir = in.CertificatesDir - out.ImageRepository = in.ImageRepository - out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage - out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - out.ClusterName = in.ClusterName - return nil -} - -func split_v1alpha2_InitConfiguration_into_kubeadm_ComponentConfigs(in *InitConfiguration, out *kubeadm.ComponentConfigs, s conversion.Scope) error { - if in.KubeProxy.Config != nil { - if out.KubeProxy == nil { - out.KubeProxy = &kubeproxyconfig.KubeProxyConfiguration{} - } - - if err := componentconfigs.Scheme.Convert(in.KubeProxy.Config, out.KubeProxy, nil); err != nil { - return err - } - } - if in.KubeletConfiguration.BaseConfig != nil { - if out.Kubelet == nil { - out.Kubelet = &kubeletconfig.KubeletConfiguration{} - } - - if err := componentconfigs.Scheme.Convert(in.KubeletConfiguration.BaseConfig, out.Kubelet, nil); err != nil { - return err - } - } - return nil -} - -func Convert_v1alpha2_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error { - if err := autoConvert_v1alpha2_JoinConfiguration_To_kubeadm_JoinConfiguration(in, out, s); err != nil { - return err - } - out.APIEndpoint.AdvertiseAddress = in.AdvertiseAddress - out.APIEndpoint.BindPort = in.BindPort - return nil -} - -func Convert_kubeadm_InitConfiguration_To_v1alpha2_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error { - if err := autoConvert_kubeadm_InitConfiguration_To_v1alpha2_InitConfiguration(in, out, s); err != nil { - return err - } - if err := join_kubeadm_ClusterConfiguration_into_v1alpha2_InitConfiguration(&in.ClusterConfiguration, out, s); err != nil { - return err - } - if err := join_kubeadm_APIEndpoint_into_v1alpha2_InitConfiguration(&in.APIEndpoint, out, s); err != nil { - return err - } - return nil -} - -func join_kubeadm_ClusterConfiguration_into_v1alpha2_InitConfiguration(in *kubeadm.ClusterConfiguration, out *InitConfiguration, s conversion.Scope) error { - if err := join_kubeadm_ComponentConfigs_into_v1alpha2_InitConfiguration(&in.ComponentConfigs, out, s); err != nil { - return err - } - if err := Convert_kubeadm_Etcd_To_v1alpha2_Etcd(&in.Etcd, &out.Etcd, s); err != nil { - return err - } - if err := Convert_kubeadm_Networking_To_v1alpha2_Networking(&in.Networking, &out.Networking, s); err != nil { - return err - } - if err := Convert_kubeadm_AuditPolicyConfiguration_To_v1alpha2_AuditPolicyConfiguration(&in.AuditPolicyConfiguration, &out.AuditPolicyConfiguration, s); err != nil { - return err - } - out.KubernetesVersion = in.KubernetesVersion - out.API.ControlPlaneEndpoint = in.ControlPlaneEndpoint - out.APIServerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.APIServerExtraArgs)) - out.ControllerManagerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ControllerManagerExtraArgs)) - out.SchedulerExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.SchedulerExtraArgs)) - out.APIServerExtraVolumes = *(*[]HostPathMount)(unsafe.Pointer(&in.APIServerExtraVolumes)) - out.ControllerManagerExtraVolumes = *(*[]HostPathMount)(unsafe.Pointer(&in.ControllerManagerExtraVolumes)) - out.SchedulerExtraVolumes = *(*[]HostPathMount)(unsafe.Pointer(&in.SchedulerExtraVolumes)) - out.APIServerCertSANs = *(*[]string)(unsafe.Pointer(&in.APIServerCertSANs)) - out.CertificatesDir = in.CertificatesDir - out.ImageRepository = in.ImageRepository - out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage - out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - out.ClusterName = in.ClusterName - return nil -} - -func join_kubeadm_APIEndpoint_into_v1alpha2_InitConfiguration(in *kubeadm.APIEndpoint, out *InitConfiguration, s conversion.Scope) error { - out.API.AdvertiseAddress = in.AdvertiseAddress - out.API.BindPort = in.BindPort - // out.API.ControlPlaneEndpoint will join from ClusterConfiguration - return nil -} - -func join_kubeadm_ComponentConfigs_into_v1alpha2_InitConfiguration(in *kubeadm.ComponentConfigs, out *InitConfiguration, s conversion.Scope) error { - if in.KubeProxy != nil { - if out.KubeProxy.Config == nil { - out.KubeProxy.Config = &kubeproxyconfigv1alpha1.KubeProxyConfiguration{} - } - - if err := componentconfigs.Scheme.Convert(in.KubeProxy, out.KubeProxy.Config, nil); err != nil { - return err - } - } - if in.Kubelet != nil { - if out.KubeletConfiguration.BaseConfig == nil { - out.KubeletConfiguration.BaseConfig = &kubeletconfigv1beta1.KubeletConfiguration{} - } - - if err := componentconfigs.Scheme.Convert(in.Kubelet, out.KubeletConfiguration.BaseConfig, nil); err != nil { - return err - } - } - return nil -} - -func Convert_kubeadm_JoinConfiguration_To_v1alpha2_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error { - if err := autoConvert_kubeadm_JoinConfiguration_To_v1alpha2_JoinConfiguration(in, out, s); err != nil { - return err - } - out.AdvertiseAddress = in.APIEndpoint.AdvertiseAddress - out.BindPort = in.APIEndpoint.BindPort - return nil -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults.go deleted file mode 100644 index 6672bf1e657..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults.go +++ /dev/null @@ -1,275 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - "net/url" - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - kubeproxyconfigv1alpha1 "k8s.io/kube-proxy/config/v1alpha1" - kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1" - "k8s.io/kubernetes/cmd/kubeadm/app/constants" - kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/config/scheme" - kubeproxyscheme "k8s.io/kubernetes/pkg/proxy/apis/config/scheme" - utilpointer "k8s.io/utils/pointer" -) - -const ( - // DefaultServiceDNSDomain defines default cluster-internal domain name for Services and Pods - DefaultServiceDNSDomain = "cluster.local" - // DefaultServicesSubnet defines default service subnet range - DefaultServicesSubnet = "10.96.0.0/12" - // DefaultClusterDNSIP defines default DNS IP - DefaultClusterDNSIP = "10.96.0.10" - // DefaultKubernetesVersion defines default kubernetes version - DefaultKubernetesVersion = "stable-1" - // DefaultAPIBindPort defines default API port - DefaultAPIBindPort = 6443 - // DefaultCertificatesDir defines default certificate directory - DefaultCertificatesDir = "/etc/kubernetes/pki" - // DefaultImageRepository defines default image registry - DefaultImageRepository = "k8s.gcr.io" - // DefaultManifestsDir defines default manifests directory - DefaultManifestsDir = "/etc/kubernetes/manifests" - // DefaultClusterName defines the default cluster name - DefaultClusterName = "kubernetes" - - // DefaultEtcdDataDir defines default location of etcd where static pods will save data to - DefaultEtcdDataDir = "/var/lib/etcd" - // DefaultProxyBindAddressv4 is the default bind address when the advertise address is v4 - DefaultProxyBindAddressv4 = "0.0.0.0" - // DefaultProxyBindAddressv6 is the default bind address when the advertise address is v6 - DefaultProxyBindAddressv6 = "::" - // KubeproxyKubeConfigFileName defines the file name for the kube-proxy's KubeConfig file - KubeproxyKubeConfigFileName = "/var/lib/kube-proxy/kubeconfig.conf" - - // DefaultDiscoveryTimeout specifies the default discovery timeout for kubeadm (used unless one is specified in the JoinConfiguration) - DefaultDiscoveryTimeout = 5 * time.Minute -) - -var ( - // DefaultAuditPolicyLogMaxAge is defined as a var so its address can be taken - // It is the number of days to store audit logs - DefaultAuditPolicyLogMaxAge = int32(2) -) - -func addDefaultingFuncs(scheme *runtime.Scheme) error { - return RegisterDefaults(scheme) -} - -// SetDefaults_InitConfiguration assigns default values to Master node -func SetDefaults_InitConfiguration(obj *InitConfiguration) { - if obj.KubernetesVersion == "" { - obj.KubernetesVersion = DefaultKubernetesVersion - } - - if obj.API.BindPort == 0 { - obj.API.BindPort = DefaultAPIBindPort - } - - if obj.Networking.ServiceSubnet == "" { - obj.Networking.ServiceSubnet = DefaultServicesSubnet - } - - if obj.Networking.DNSDomain == "" { - obj.Networking.DNSDomain = DefaultServiceDNSDomain - } - - if obj.CertificatesDir == "" { - obj.CertificatesDir = DefaultCertificatesDir - } - - if obj.ImageRepository == "" { - obj.ImageRepository = DefaultImageRepository - } - - if obj.ClusterName == "" { - obj.ClusterName = DefaultClusterName - } - - SetDefaults_NodeRegistrationOptions(&obj.NodeRegistration) - SetDefaults_BootstrapTokens(obj) - SetDefaults_KubeletConfiguration(obj) - SetDefaults_Etcd(obj) - SetDefaults_ProxyConfiguration(obj) - SetDefaults_AuditPolicyConfiguration(obj) -} - -// SetDefaults_Etcd assigns default values for the Proxy -func SetDefaults_Etcd(obj *InitConfiguration) { - if obj.Etcd.External == nil && obj.Etcd.Local == nil { - obj.Etcd.Local = &LocalEtcd{} - } - if obj.Etcd.Local != nil { - if obj.Etcd.Local.DataDir == "" { - obj.Etcd.Local.DataDir = DefaultEtcdDataDir - } - } -} - -// SetDefaults_ProxyConfiguration assigns default values for the Proxy -func SetDefaults_ProxyConfiguration(obj *InitConfiguration) { - // IMPORTANT NOTE: If you're changing this code you should mirror it to cmd/kubeadm/app/componentconfig/defaults.go - // and cmd/kubeadm/app/apis/kubeadm/v1alpha3/conversion.go. - if obj.KubeProxy.Config == nil { - obj.KubeProxy.Config = &kubeproxyconfigv1alpha1.KubeProxyConfiguration{} - } - if obj.KubeProxy.Config.ClusterCIDR == "" && obj.Networking.PodSubnet != "" { - obj.KubeProxy.Config.ClusterCIDR = obj.Networking.PodSubnet - } - - if obj.KubeProxy.Config.ClientConnection.Kubeconfig == "" { - obj.KubeProxy.Config.ClientConnection.Kubeconfig = KubeproxyKubeConfigFileName - } - - kubeproxyscheme.Scheme.Default(obj.KubeProxy.Config) -} - -// SetDefaults_JoinConfiguration assigns default values to a regular node -func SetDefaults_JoinConfiguration(obj *JoinConfiguration) { - if obj.CACertPath == "" { - obj.CACertPath = DefaultCACertPath - } - if len(obj.TLSBootstrapToken) == 0 { - obj.TLSBootstrapToken = obj.Token - } - if len(obj.DiscoveryToken) == 0 && len(obj.DiscoveryFile) == 0 { - obj.DiscoveryToken = obj.Token - } - // Make sure file URLs become paths - if len(obj.DiscoveryFile) != 0 { - u, err := url.Parse(obj.DiscoveryFile) - if err == nil && u.Scheme == "file" { - obj.DiscoveryFile = u.Path - } - } - if obj.DiscoveryTimeout == nil { - obj.DiscoveryTimeout = &metav1.Duration{ - Duration: DefaultDiscoveryTimeout, - } - } - if obj.ClusterName == "" { - obj.ClusterName = DefaultClusterName - } - - if obj.BindPort == 0 { - obj.BindPort = DefaultAPIBindPort - } - - SetDefaults_NodeRegistrationOptions(&obj.NodeRegistration) -} - -// SetDefaults_KubeletConfiguration assigns default values to kubelet -func SetDefaults_KubeletConfiguration(obj *InitConfiguration) { - // IMPORTANT NOTE: If you're changing this code you should mirror it to cmd/kubeadm/app/componentconfig/defaults.go - // and cmd/kubeadm/app/apis/kubeadm/v1alpha3/conversion.go. - if obj.KubeletConfiguration.BaseConfig == nil { - obj.KubeletConfiguration.BaseConfig = &kubeletconfigv1beta1.KubeletConfiguration{} - } - if obj.KubeletConfiguration.BaseConfig.StaticPodPath == "" { - obj.KubeletConfiguration.BaseConfig.StaticPodPath = DefaultManifestsDir - } - if obj.KubeletConfiguration.BaseConfig.ClusterDNS == nil { - dnsIP, err := constants.GetDNSIP(obj.Networking.ServiceSubnet) - if err != nil { - obj.KubeletConfiguration.BaseConfig.ClusterDNS = []string{DefaultClusterDNSIP} - } else { - obj.KubeletConfiguration.BaseConfig.ClusterDNS = []string{dnsIP.String()} - } - } - if obj.KubeletConfiguration.BaseConfig.ClusterDomain == "" { - obj.KubeletConfiguration.BaseConfig.ClusterDomain = obj.Networking.DNSDomain - } - - // Enforce security-related kubelet options - - // Require all clients to the kubelet API to have client certs signed by the cluster CA - obj.KubeletConfiguration.BaseConfig.Authentication.X509.ClientCAFile = DefaultCACertPath - obj.KubeletConfiguration.BaseConfig.Authentication.Anonymous.Enabled = utilpointer.BoolPtr(false) - - // On every client request to the kubelet API, execute a webhook (SubjectAccessReview request) to the API server - // and ask it whether the client is authorized to access the kubelet API - obj.KubeletConfiguration.BaseConfig.Authorization.Mode = kubeletconfigv1beta1.KubeletAuthorizationModeWebhook - - // Let clients using other authentication methods like ServiceAccount tokens also access the kubelet API - obj.KubeletConfiguration.BaseConfig.Authentication.Webhook.Enabled = utilpointer.BoolPtr(true) - - // Disable the readonly port of the kubelet, in order to not expose unnecessary information - obj.KubeletConfiguration.BaseConfig.ReadOnlyPort = 0 - - // Enables client certificate rotation for the kubelet - obj.KubeletConfiguration.BaseConfig.RotateCertificates = true - - // Serve a /healthz webserver on localhost:10248 that kubeadm can talk to - obj.KubeletConfiguration.BaseConfig.HealthzBindAddress = "127.0.0.1" - obj.KubeletConfiguration.BaseConfig.HealthzPort = utilpointer.Int32Ptr(constants.KubeletHealthzPort) - - scheme, _, _ := kubeletscheme.NewSchemeAndCodecs() - if scheme != nil { - scheme.Default(obj.KubeletConfiguration.BaseConfig) - } -} - -func SetDefaults_NodeRegistrationOptions(obj *NodeRegistrationOptions) { - if obj.CRISocket == "" { - obj.CRISocket = DefaultCRISocket - } -} - -// SetDefaults_AuditPolicyConfiguration sets default values for the AuditPolicyConfiguration -func SetDefaults_AuditPolicyConfiguration(obj *InitConfiguration) { - if obj.AuditPolicyConfiguration.LogDir == "" { - obj.AuditPolicyConfiguration.LogDir = constants.StaticPodAuditPolicyLogDir - } - if obj.AuditPolicyConfiguration.LogMaxAge == nil { - obj.AuditPolicyConfiguration.LogMaxAge = &DefaultAuditPolicyLogMaxAge - } -} - -// SetDefaults_BootstrapTokens sets the defaults for the .BootstrapTokens field -// If the slice is empty, it's defaulted with one token. Otherwise it just loops -// through the slice and sets the defaults for the omitempty fields that are TTL, -// Usages and Groups. Token is NOT defaulted with a random one in the API defaulting -// layer, but set to a random value later at runtime if not set before. -func SetDefaults_BootstrapTokens(obj *InitConfiguration) { - - if obj.BootstrapTokens == nil || len(obj.BootstrapTokens) == 0 { - obj.BootstrapTokens = []BootstrapToken{{}} - } - - for i := range obj.BootstrapTokens { - SetDefaults_BootstrapToken(&obj.BootstrapTokens[i]) - } -} - -// SetDefaults_BootstrapToken sets the defaults for an individual Bootstrap Token -func SetDefaults_BootstrapToken(bt *BootstrapToken) { - if bt.TTL == nil { - bt.TTL = &metav1.Duration{ - Duration: constants.DefaultTokenDuration, - } - } - if len(bt.Usages) == 0 { - bt.Usages = constants.DefaultTokenUsages - } - - if len(bt.Groups) == 0 { - bt.Groups = constants.DefaultTokenGroups - } -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_unix.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_unix.go deleted file mode 100644 index 0c5ee1035a7..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_unix.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build !windows - -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -const ( - // DefaultCACertPath defines default location of CA certificate on Linux - DefaultCACertPath = "/etc/kubernetes/pki/ca.crt" - // DefaultCRISocket defines the default cri socket - DefaultCRISocket = "/var/run/dockershim.sock" -) diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_windows.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_windows.go deleted file mode 100644 index 779dd5290c3..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/defaults_windows.go +++ /dev/null @@ -1,26 +0,0 @@ -// +build windows - -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -const ( - // DefaultCACertPath defines default location of CA certificate on Windows - DefaultCACertPath = "C:/etc/kubernetes/pki/ca.crt" - // DefaultCRISocket defines the default cri socket - DefaultCRISocket = "tcp://localhost:2375" -) diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/doc.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/doc.go deleted file mode 100644 index d833da6f3b6..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/doc.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +k8s:defaulter-gen=TypeMeta -// +groupName=kubeadm.k8s.io -// +k8s:deepcopy-gen=package -// +k8s:conversion-gen=k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm - -// Package v1alpha2 is the package that contains the libraries that drive the kubeadm binary. -package v1alpha2 // import "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha2" diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/register.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/register.go deleted file mode 100644 index d5cc0bc0d2b..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/register.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// GroupName is the group name use in this package -const GroupName = "kubeadm.k8s.io" - -// SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha2"} - -var ( - // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. - - // SchemeBuilder points to a list of functions added to Scheme. - SchemeBuilder runtime.SchemeBuilder - localSchemeBuilder = &SchemeBuilder - // AddToScheme applies all the stored functions to the scheme. - AddToScheme = localSchemeBuilder.AddToScheme -) - -func init() { - // We only register manually written functions here. The registration of the - // generated functions takes place in the generated files. The separation - // makes the code compile even when the generated files are missing. - localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs) -} - -// Kind takes an unqualified kind and returns a Group qualified GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("MasterConfiguration"), &InitConfiguration{}) - scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("NodeConfiguration"), &JoinConfiguration{}) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/types.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/types.go deleted file mode 100644 index 6bac7781cba..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/types.go +++ /dev/null @@ -1,331 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha2 - -import ( - "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - kubeproxyconfigv1alpha1 "k8s.io/kube-proxy/config/v1alpha1" - kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// InitConfiguration contains a list of elements which make up master's -// configuration object. -type InitConfiguration struct { - metav1.TypeMeta `json:",inline"` - - // `kubeadm init`-only information. These fields are solely used the first time `kubeadm init` runs. - // After that, the information in the fields ARE NOT uploaded to the `kubeadm-config` ConfigMap - // that is used by `kubeadm upgrade` for instance. These fields must be omitempty. - - // BootstrapTokens is respected at `kubeadm init` time and describes a set of Bootstrap Tokens to create. - // This information IS NOT uploaded to the kubeadm cluster configmap, partly because of its sensitive nature - BootstrapTokens []BootstrapToken `json:"bootstrapTokens,omitempty"` - - // NodeRegistration holds fields that relate to registering the new master node to the cluster - NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"` - - // Cluster-wide configuration - // TODO: Move these fields under some kind of ClusterConfiguration or similar struct that describes - // one cluster. Eventually we want this kind of spec to align well with the Cluster API spec. - - // API holds configuration for the k8s apiserver. - API API `json:"api"` - // KubeProxy holds configuration for the k8s service proxy. - KubeProxy KubeProxy `json:"kubeProxy"` - // Etcd holds configuration for etcd. - Etcd Etcd `json:"etcd"` - // KubeletConfiguration holds configuration for the kubelet. - KubeletConfiguration KubeletConfiguration `json:"kubeletConfiguration"` - // Networking holds configuration for the networking topology of the cluster. - Networking Networking `json:"networking"` - - // KubernetesVersion is the target version of the control plane. - KubernetesVersion string `json:"kubernetesVersion"` - - // APIServerExtraArgs is a set of extra flags to pass to the API Server or override - // default ones in form of =. - // TODO: This is temporary and ideally we would like to switch all components to - // use ComponentConfig + ConfigMaps. - APIServerExtraArgs map[string]string `json:"apiServerExtraArgs,omitempty"` - // ControllerManagerExtraArgs is a set of extra flags to pass to the Controller Manager - // or override default ones in form of = - // TODO: This is temporary and ideally we would like to switch all components to - // use ComponentConfig + ConfigMaps. - ControllerManagerExtraArgs map[string]string `json:"controllerManagerExtraArgs,omitempty"` - // SchedulerExtraArgs is a set of extra flags to pass to the Scheduler or override - // default ones in form of = - // TODO: This is temporary and ideally we would like to switch all components to - // use ComponentConfig + ConfigMaps. - SchedulerExtraArgs map[string]string `json:"schedulerExtraArgs,omitempty"` - - // APIServerExtraVolumes is an extra set of host volumes mounted to the API server. - APIServerExtraVolumes []HostPathMount `json:"apiServerExtraVolumes,omitempty"` - // ControllerManagerExtraVolumes is an extra set of host volumes mounted to the - // Controller Manager. - ControllerManagerExtraVolumes []HostPathMount `json:"controllerManagerExtraVolumes,omitempty"` - // SchedulerExtraVolumes is an extra set of host volumes mounted to the scheduler. - SchedulerExtraVolumes []HostPathMount `json:"schedulerExtraVolumes,omitempty"` - - // APIServerCertSANs sets extra Subject Alternative Names for the API Server signing cert. - APIServerCertSANs []string `json:"apiServerCertSANs,omitempty"` - // CertificatesDir specifies where to store or look for all required certificates. - CertificatesDir string `json:"certificatesDir"` - - // ImageRepository what container registry to pull control plane images from - ImageRepository string `json:"imageRepository"` - // UnifiedControlPlaneImage specifies if a specific container image should - // be used for all control plane components. - UnifiedControlPlaneImage string `json:"unifiedControlPlaneImage"` - - // AuditPolicyConfiguration defines the options for the api server audit system - AuditPolicyConfiguration AuditPolicyConfiguration `json:"auditPolicy"` - - // FeatureGates enabled by the user. - FeatureGates map[string]bool `json:"featureGates,omitempty"` - - // The cluster name - ClusterName string `json:"clusterName,omitempty"` -} - -// API struct contains elements of API server address. -type API struct { - // AdvertiseAddress sets the IP address for the API server to advertise. - AdvertiseAddress string `json:"advertiseAddress"` - // ControlPlaneEndpoint sets a stable IP address or DNS name for the control plane; it - // can be a valid IP address or a RFC-1123 DNS subdomain, both with optional TCP port. - // In case the ControlPlaneEndpoint is not specified, the AdvertiseAddress + BindPort - // are used; in case the ControlPlaneEndpoint is specified but without a TCP port, - // the BindPort is used. - // Possible usages are: - // e.g. In an cluster with more than one control plane instances, this field should be - // assigned the address of the external load balancer in front of the - // control plane instances. - // e.g. in environments with enforced node recycling, the ControlPlaneEndpoint - // could be used for assigning a stable DNS to the control plane. - ControlPlaneEndpoint string `json:"controlPlaneEndpoint"` - // BindPort sets the secure port for the API Server to bind to. - // Defaults to 6443. - BindPort int32 `json:"bindPort"` -} - -// NodeRegistrationOptions holds fields that relate to registering a new master or node to the cluster, either via "kubeadm init" or "kubeadm join" -type NodeRegistrationOptions struct { - - // Name is the `.Metadata.Name` field of the Node API object that will be created in this `kubeadm init` or `kubeadm joiƄ` operation. - // This field is also used in the CommonName field of the kubelet's client certificate to the API server. - // Defaults to the hostname of the node if not provided. - Name string `json:"name,omitempty"` - - // CRISocket is used to retrieve container runtime info. This information will be annotated to the Node API object, for later re-use - CRISocket string `json:"criSocket,omitempty"` - - // Taints specifies the taints the Node API object should be registered with. If this field is unset, i.e. nil, in the `kubeadm init` process - // it will be defaulted to []v1.Taint{'node-role.kubernetes.io/master=""'}. If you don't want to taint your master node, set this field to an - // empty slice, i.e. `taints: {}` in the YAML file. This field is solely used for Node registration. - Taints []v1.Taint `json:"taints,omitempty"` - - // KubeletExtraArgs passes through extra arguments to the kubelet. The arguments here are passed to the kubelet command line via the environment file - // kubeadm writes at runtime for the kubelet to source. This overrides the generic base-level configuration in the kubelet-config-1.X ConfigMap - // Flags have higher higher priority when parsing. These values are local and specific to the node kubeadm is executing on. - KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"` -} - -// Networking contains elements describing cluster's networking configuration -type Networking struct { - // ServiceSubnet is the subnet used by k8s services. Defaults to "10.96.0.0/12". - ServiceSubnet string `json:"serviceSubnet"` - // PodSubnet is the subnet used by pods. - PodSubnet string `json:"podSubnet"` - // DNSDomain is the dns domain used by k8s services. Defaults to "cluster.local". - DNSDomain string `json:"dnsDomain"` -} - -// BootstrapToken describes one bootstrap token, stored as a Secret in the cluster -type BootstrapToken struct { - // Token is used for establishing bidirectional trust between nodes and masters. - // Used for joining nodes in the cluster. - Token *BootstrapTokenString `json:"token"` - // Description sets a human-friendly message why this token exists and what it's used - // for, so other administrators can know its purpose. - Description string `json:"description,omitempty"` - // TTL defines the time to live for this token. Defaults to 24h. - // Expires and TTL are mutually exclusive. - TTL *metav1.Duration `json:"ttl,omitempty"` - // Expires specifies the timestamp when this token expires. Defaults to being set - // dynamically at runtime based on the TTL. Expires and TTL are mutually exclusive. - Expires *metav1.Time `json:"expires,omitempty"` - // Usages describes the ways in which this token can be used. Can by default be used - // for establishing bidirectional trust, but that can be changed here. - Usages []string `json:"usages,omitempty"` - // Groups specifies the extra groups that this token will authenticate as when/if - // used for authentication - Groups []string `json:"groups,omitempty"` -} - -// Etcd contains elements describing Etcd configuration. -type Etcd struct { - - // Local provides configuration knobs for configuring the local etcd instance - // Local and External are mutually exclusive - Local *LocalEtcd `json:"local,omitempty"` - - // External describes how to connect to an external etcd cluster - // Local and External are mutually exclusive - External *ExternalEtcd `json:"external,omitempty"` -} - -// LocalEtcd describes that kubeadm should run an etcd cluster locally -type LocalEtcd struct { - - // Image specifies which container image to use for running etcd. - // If empty, automatically populated by kubeadm using the image - // repository and default etcd version. - Image string `json:"image"` - - // DataDir is the directory etcd will place its data. - // Defaults to "/var/lib/etcd". - DataDir string `json:"dataDir"` - - // ExtraArgs are extra arguments provided to the etcd binary - // when run inside a static pod. - ExtraArgs map[string]string `json:"extraArgs,omitempty"` - - // ServerCertSANs sets extra Subject Alternative Names for the etcd server signing cert. - ServerCertSANs []string `json:"serverCertSANs,omitempty"` - // PeerCertSANs sets extra Subject Alternative Names for the etcd peer signing cert. - PeerCertSANs []string `json:"peerCertSANs,omitempty"` -} - -// ExternalEtcd describes an external etcd cluster -type ExternalEtcd struct { - - // Endpoints of etcd members. Useful for using external etcd. - // If not provided, kubeadm will run etcd in a static pod. - Endpoints []string `json:"endpoints"` - // CAFile is an SSL Certificate Authority file used to secure etcd communication. - CAFile string `json:"caFile"` - // CertFile is an SSL certification file used to secure etcd communication. - CertFile string `json:"certFile"` - // KeyFile is an SSL key file used to secure etcd communication. - KeyFile string `json:"keyFile"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// JoinConfiguration contains elements describing a particular node. -// TODO: This struct should be replaced by dynamic kubelet configuration. -type JoinConfiguration struct { - metav1.TypeMeta `json:",inline"` - - // NodeRegistration holds fields that relate to registering the new master node to the cluster - NodeRegistration NodeRegistrationOptions `json:"nodeRegistration"` - - // CACertPath is the path to the SSL certificate authority used to - // secure comunications between node and master. - // Defaults to "/etc/kubernetes/pki/ca.crt". - CACertPath string `json:"caCertPath"` - // DiscoveryFile is a file or url to a kubeconfig file from which to - // load cluster information. - DiscoveryFile string `json:"discoveryFile"` - // DiscoveryToken is a token used to validate cluster information - // fetched from the master. - DiscoveryToken string `json:"discoveryToken"` - // DiscoveryTokenAPIServers is a set of IPs to API servers from which info - // will be fetched. Currently we only pay attention to one API server but - // hope to support >1 in the future. - DiscoveryTokenAPIServers []string `json:"discoveryTokenAPIServers,omitempty"` - // DiscoveryTimeout modifies the discovery timeout - DiscoveryTimeout *metav1.Duration `json:"discoveryTimeout,omitempty"` - // TLSBootstrapToken is a token used for TLS bootstrapping. - // Defaults to Token. - TLSBootstrapToken string `json:"tlsBootstrapToken"` - // Token is used for both discovery and TLS bootstrapping. - Token string `json:"token"` - - // ClusterName is the name for the cluster in kubeconfig. - ClusterName string `json:"clusterName,omitempty"` - - // DiscoveryTokenCACertHashes specifies a set of public key pins to verify - // when token-based discovery is used. The root CA found during discovery - // must match one of these values. Specifying an empty set disables root CA - // pinning, which can be unsafe. Each hash is specified as ":", - // where the only currently supported type is "sha256". This is a hex-encoded - // SHA-256 hash of the Subject Public Key Info (SPKI) object in DER-encoded - // ASN.1. These hashes can be calculated using, for example, OpenSSL: - // openssl x509 -pubkey -in ca.crt openssl rsa -pubin -outform der 2>&/dev/null | openssl dgst -sha256 -hex - DiscoveryTokenCACertHashes []string `json:"discoveryTokenCACertHashes,omitempty"` - - // DiscoveryTokenUnsafeSkipCAVerification allows token-based discovery - // without CA verification via DiscoveryTokenCACertHashes. This can weaken - // the security of kubeadm since other nodes can impersonate the master. - DiscoveryTokenUnsafeSkipCAVerification bool `json:"discoveryTokenUnsafeSkipCAVerification"` - - // ControlPlane flag specifies that the joining node should host an additional - // control plane instance. - ControlPlane bool `json:"controlPlane,omitempty"` - - // AdvertiseAddress sets the IP address for the API server to advertise; the - // API server will be installed only on nodes hosting an additional control plane instance. - AdvertiseAddress string `json:"advertiseAddress,omitempty"` - - // BindPort sets the secure port for the API Server to bind to. - // Defaults to 6443. - BindPort int32 `json:"bindPort,omitempty"` - - // FeatureGates enabled by the user. - FeatureGates map[string]bool `json:"featureGates,omitempty"` -} - -// KubeletConfiguration contains elements describing initial remote configuration of kubelet. -type KubeletConfiguration struct { - BaseConfig *kubeletconfigv1beta1.KubeletConfiguration `json:"baseConfig,omitempty"` -} - -// HostPathMount contains elements describing volumes that are mounted from the -// host. -type HostPathMount struct { - // Name of the volume inside the pod template. - Name string `json:"name"` - // HostPath is the path in the host that will be mounted inside - // the pod. - HostPath string `json:"hostPath"` - // MountPath is the path inside the pod where hostPath will be mounted. - MountPath string `json:"mountPath"` - // Writable controls write access to the volume - Writable bool `json:"writable,omitempty"` - // PathType is the type of the HostPath. - PathType v1.HostPathType `json:"pathType,omitempty"` -} - -// KubeProxy contains elements describing the proxy configuration. -type KubeProxy struct { - Config *kubeproxyconfigv1alpha1.KubeProxyConfiguration `json:"config,omitempty"` -} - -// AuditPolicyConfiguration holds the options for configuring the api server audit policy. -type AuditPolicyConfiguration struct { - // Path is the local path to an audit policy. - Path string `json:"path"` - // LogDir is the local path to the directory where logs should be stored. - LogDir string `json:"logDir"` - // LogMaxAge is the number of days logs will be stored for. 0 indicates forever. - LogMaxAge *int32 `json:"logMaxAge,omitempty"` - //TODO(chuckha) add other options for audit policy. -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.conversion.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.conversion.go deleted file mode 100644 index 33f3a607e5a..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.conversion.go +++ /dev/null @@ -1,479 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by conversion-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - unsafe "unsafe" - - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - conversion "k8s.io/apimachinery/pkg/conversion" - runtime "k8s.io/apimachinery/pkg/runtime" - kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" -) - -func init() { - localSchemeBuilder.Register(RegisterConversions) -} - -// RegisterConversions adds conversion functions to the given scheme. -// Public to allow building arbitrary schemes. -func RegisterConversions(s *runtime.Scheme) error { - if err := s.AddGeneratedConversionFunc((*AuditPolicyConfiguration)(nil), (*kubeadm.AuditPolicyConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(a.(*AuditPolicyConfiguration), b.(*kubeadm.AuditPolicyConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.AuditPolicyConfiguration)(nil), (*AuditPolicyConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_AuditPolicyConfiguration_To_v1alpha2_AuditPolicyConfiguration(a.(*kubeadm.AuditPolicyConfiguration), b.(*AuditPolicyConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*BootstrapToken)(nil), (*kubeadm.BootstrapToken)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_BootstrapToken_To_kubeadm_BootstrapToken(a.(*BootstrapToken), b.(*kubeadm.BootstrapToken), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.BootstrapToken)(nil), (*BootstrapToken)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_BootstrapToken_To_v1alpha2_BootstrapToken(a.(*kubeadm.BootstrapToken), b.(*BootstrapToken), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*BootstrapTokenString)(nil), (*kubeadm.BootstrapTokenString)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_BootstrapTokenString_To_kubeadm_BootstrapTokenString(a.(*BootstrapTokenString), b.(*kubeadm.BootstrapTokenString), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.BootstrapTokenString)(nil), (*BootstrapTokenString)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_BootstrapTokenString_To_v1alpha2_BootstrapTokenString(a.(*kubeadm.BootstrapTokenString), b.(*BootstrapTokenString), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*Etcd)(nil), (*kubeadm.Etcd)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_Etcd_To_kubeadm_Etcd(a.(*Etcd), b.(*kubeadm.Etcd), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.Etcd)(nil), (*Etcd)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_Etcd_To_v1alpha2_Etcd(a.(*kubeadm.Etcd), b.(*Etcd), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*ExternalEtcd)(nil), (*kubeadm.ExternalEtcd)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_ExternalEtcd_To_kubeadm_ExternalEtcd(a.(*ExternalEtcd), b.(*kubeadm.ExternalEtcd), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.ExternalEtcd)(nil), (*ExternalEtcd)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_ExternalEtcd_To_v1alpha2_ExternalEtcd(a.(*kubeadm.ExternalEtcd), b.(*ExternalEtcd), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*HostPathMount)(nil), (*kubeadm.HostPathMount)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_HostPathMount_To_kubeadm_HostPathMount(a.(*HostPathMount), b.(*kubeadm.HostPathMount), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.HostPathMount)(nil), (*HostPathMount)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_HostPathMount_To_v1alpha2_HostPathMount(a.(*kubeadm.HostPathMount), b.(*HostPathMount), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*InitConfiguration)(nil), (*kubeadm.InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_InitConfiguration_To_kubeadm_InitConfiguration(a.(*InitConfiguration), b.(*kubeadm.InitConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_InitConfiguration_To_v1alpha2_InitConfiguration(a.(*kubeadm.InitConfiguration), b.(*InitConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*JoinConfiguration)(nil), (*kubeadm.JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_JoinConfiguration_To_kubeadm_JoinConfiguration(a.(*JoinConfiguration), b.(*kubeadm.JoinConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_JoinConfiguration_To_v1alpha2_JoinConfiguration(a.(*kubeadm.JoinConfiguration), b.(*JoinConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*LocalEtcd)(nil), (*kubeadm.LocalEtcd)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_LocalEtcd_To_kubeadm_LocalEtcd(a.(*LocalEtcd), b.(*kubeadm.LocalEtcd), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.LocalEtcd)(nil), (*LocalEtcd)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_LocalEtcd_To_v1alpha2_LocalEtcd(a.(*kubeadm.LocalEtcd), b.(*LocalEtcd), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*Networking)(nil), (*kubeadm.Networking)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_Networking_To_kubeadm_Networking(a.(*Networking), b.(*kubeadm.Networking), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.Networking)(nil), (*Networking)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_Networking_To_v1alpha2_Networking(a.(*kubeadm.Networking), b.(*Networking), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*NodeRegistrationOptions)(nil), (*kubeadm.NodeRegistrationOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(a.(*NodeRegistrationOptions), b.(*kubeadm.NodeRegistrationOptions), scope) - }); err != nil { - return err - } - if err := s.AddGeneratedConversionFunc((*kubeadm.NodeRegistrationOptions)(nil), (*NodeRegistrationOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_NodeRegistrationOptions_To_v1alpha2_NodeRegistrationOptions(a.(*kubeadm.NodeRegistrationOptions), b.(*NodeRegistrationOptions), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*kubeadm.InitConfiguration)(nil), (*InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_InitConfiguration_To_v1alpha2_InitConfiguration(a.(*kubeadm.InitConfiguration), b.(*InitConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*kubeadm.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_kubeadm_JoinConfiguration_To_v1alpha2_JoinConfiguration(a.(*kubeadm.JoinConfiguration), b.(*JoinConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*InitConfiguration)(nil), (*kubeadm.InitConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_InitConfiguration_To_kubeadm_InitConfiguration(a.(*InitConfiguration), b.(*kubeadm.InitConfiguration), scope) - }); err != nil { - return err - } - if err := s.AddConversionFunc((*JoinConfiguration)(nil), (*kubeadm.JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha2_JoinConfiguration_To_kubeadm_JoinConfiguration(a.(*JoinConfiguration), b.(*kubeadm.JoinConfiguration), scope) - }); err != nil { - return err - } - return nil -} - -func autoConvert_v1alpha2_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(in *AuditPolicyConfiguration, out *kubeadm.AuditPolicyConfiguration, s conversion.Scope) error { - out.Path = in.Path - out.LogDir = in.LogDir - out.LogMaxAge = (*int32)(unsafe.Pointer(in.LogMaxAge)) - return nil -} - -// Convert_v1alpha2_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration is an autogenerated conversion function. -func Convert_v1alpha2_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(in *AuditPolicyConfiguration, out *kubeadm.AuditPolicyConfiguration, s conversion.Scope) error { - return autoConvert_v1alpha2_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(in, out, s) -} - -func autoConvert_kubeadm_AuditPolicyConfiguration_To_v1alpha2_AuditPolicyConfiguration(in *kubeadm.AuditPolicyConfiguration, out *AuditPolicyConfiguration, s conversion.Scope) error { - out.Path = in.Path - out.LogDir = in.LogDir - out.LogMaxAge = (*int32)(unsafe.Pointer(in.LogMaxAge)) - return nil -} - -// Convert_kubeadm_AuditPolicyConfiguration_To_v1alpha2_AuditPolicyConfiguration is an autogenerated conversion function. -func Convert_kubeadm_AuditPolicyConfiguration_To_v1alpha2_AuditPolicyConfiguration(in *kubeadm.AuditPolicyConfiguration, out *AuditPolicyConfiguration, s conversion.Scope) error { - return autoConvert_kubeadm_AuditPolicyConfiguration_To_v1alpha2_AuditPolicyConfiguration(in, out, s) -} - -func autoConvert_v1alpha2_BootstrapToken_To_kubeadm_BootstrapToken(in *BootstrapToken, out *kubeadm.BootstrapToken, s conversion.Scope) error { - out.Token = (*kubeadm.BootstrapTokenString)(unsafe.Pointer(in.Token)) - out.Description = in.Description - out.TTL = (*v1.Duration)(unsafe.Pointer(in.TTL)) - out.Expires = (*v1.Time)(unsafe.Pointer(in.Expires)) - out.Usages = *(*[]string)(unsafe.Pointer(&in.Usages)) - out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups)) - return nil -} - -// Convert_v1alpha2_BootstrapToken_To_kubeadm_BootstrapToken is an autogenerated conversion function. -func Convert_v1alpha2_BootstrapToken_To_kubeadm_BootstrapToken(in *BootstrapToken, out *kubeadm.BootstrapToken, s conversion.Scope) error { - return autoConvert_v1alpha2_BootstrapToken_To_kubeadm_BootstrapToken(in, out, s) -} - -func autoConvert_kubeadm_BootstrapToken_To_v1alpha2_BootstrapToken(in *kubeadm.BootstrapToken, out *BootstrapToken, s conversion.Scope) error { - out.Token = (*BootstrapTokenString)(unsafe.Pointer(in.Token)) - out.Description = in.Description - out.TTL = (*v1.Duration)(unsafe.Pointer(in.TTL)) - out.Expires = (*v1.Time)(unsafe.Pointer(in.Expires)) - out.Usages = *(*[]string)(unsafe.Pointer(&in.Usages)) - out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups)) - return nil -} - -// Convert_kubeadm_BootstrapToken_To_v1alpha2_BootstrapToken is an autogenerated conversion function. -func Convert_kubeadm_BootstrapToken_To_v1alpha2_BootstrapToken(in *kubeadm.BootstrapToken, out *BootstrapToken, s conversion.Scope) error { - return autoConvert_kubeadm_BootstrapToken_To_v1alpha2_BootstrapToken(in, out, s) -} - -func autoConvert_v1alpha2_BootstrapTokenString_To_kubeadm_BootstrapTokenString(in *BootstrapTokenString, out *kubeadm.BootstrapTokenString, s conversion.Scope) error { - out.ID = in.ID - out.Secret = in.Secret - return nil -} - -// Convert_v1alpha2_BootstrapTokenString_To_kubeadm_BootstrapTokenString is an autogenerated conversion function. -func Convert_v1alpha2_BootstrapTokenString_To_kubeadm_BootstrapTokenString(in *BootstrapTokenString, out *kubeadm.BootstrapTokenString, s conversion.Scope) error { - return autoConvert_v1alpha2_BootstrapTokenString_To_kubeadm_BootstrapTokenString(in, out, s) -} - -func autoConvert_kubeadm_BootstrapTokenString_To_v1alpha2_BootstrapTokenString(in *kubeadm.BootstrapTokenString, out *BootstrapTokenString, s conversion.Scope) error { - out.ID = in.ID - out.Secret = in.Secret - return nil -} - -// Convert_kubeadm_BootstrapTokenString_To_v1alpha2_BootstrapTokenString is an autogenerated conversion function. -func Convert_kubeadm_BootstrapTokenString_To_v1alpha2_BootstrapTokenString(in *kubeadm.BootstrapTokenString, out *BootstrapTokenString, s conversion.Scope) error { - return autoConvert_kubeadm_BootstrapTokenString_To_v1alpha2_BootstrapTokenString(in, out, s) -} - -func autoConvert_v1alpha2_Etcd_To_kubeadm_Etcd(in *Etcd, out *kubeadm.Etcd, s conversion.Scope) error { - out.Local = (*kubeadm.LocalEtcd)(unsafe.Pointer(in.Local)) - out.External = (*kubeadm.ExternalEtcd)(unsafe.Pointer(in.External)) - return nil -} - -// Convert_v1alpha2_Etcd_To_kubeadm_Etcd is an autogenerated conversion function. -func Convert_v1alpha2_Etcd_To_kubeadm_Etcd(in *Etcd, out *kubeadm.Etcd, s conversion.Scope) error { - return autoConvert_v1alpha2_Etcd_To_kubeadm_Etcd(in, out, s) -} - -func autoConvert_kubeadm_Etcd_To_v1alpha2_Etcd(in *kubeadm.Etcd, out *Etcd, s conversion.Scope) error { - out.Local = (*LocalEtcd)(unsafe.Pointer(in.Local)) - out.External = (*ExternalEtcd)(unsafe.Pointer(in.External)) - return nil -} - -// Convert_kubeadm_Etcd_To_v1alpha2_Etcd is an autogenerated conversion function. -func Convert_kubeadm_Etcd_To_v1alpha2_Etcd(in *kubeadm.Etcd, out *Etcd, s conversion.Scope) error { - return autoConvert_kubeadm_Etcd_To_v1alpha2_Etcd(in, out, s) -} - -func autoConvert_v1alpha2_ExternalEtcd_To_kubeadm_ExternalEtcd(in *ExternalEtcd, out *kubeadm.ExternalEtcd, s conversion.Scope) error { - out.Endpoints = *(*[]string)(unsafe.Pointer(&in.Endpoints)) - out.CAFile = in.CAFile - out.CertFile = in.CertFile - out.KeyFile = in.KeyFile - return nil -} - -// Convert_v1alpha2_ExternalEtcd_To_kubeadm_ExternalEtcd is an autogenerated conversion function. -func Convert_v1alpha2_ExternalEtcd_To_kubeadm_ExternalEtcd(in *ExternalEtcd, out *kubeadm.ExternalEtcd, s conversion.Scope) error { - return autoConvert_v1alpha2_ExternalEtcd_To_kubeadm_ExternalEtcd(in, out, s) -} - -func autoConvert_kubeadm_ExternalEtcd_To_v1alpha2_ExternalEtcd(in *kubeadm.ExternalEtcd, out *ExternalEtcd, s conversion.Scope) error { - out.Endpoints = *(*[]string)(unsafe.Pointer(&in.Endpoints)) - out.CAFile = in.CAFile - out.CertFile = in.CertFile - out.KeyFile = in.KeyFile - return nil -} - -// Convert_kubeadm_ExternalEtcd_To_v1alpha2_ExternalEtcd is an autogenerated conversion function. -func Convert_kubeadm_ExternalEtcd_To_v1alpha2_ExternalEtcd(in *kubeadm.ExternalEtcd, out *ExternalEtcd, s conversion.Scope) error { - return autoConvert_kubeadm_ExternalEtcd_To_v1alpha2_ExternalEtcd(in, out, s) -} - -func autoConvert_v1alpha2_HostPathMount_To_kubeadm_HostPathMount(in *HostPathMount, out *kubeadm.HostPathMount, s conversion.Scope) error { - out.Name = in.Name - out.HostPath = in.HostPath - out.MountPath = in.MountPath - out.Writable = in.Writable - out.PathType = corev1.HostPathType(in.PathType) - return nil -} - -// Convert_v1alpha2_HostPathMount_To_kubeadm_HostPathMount is an autogenerated conversion function. -func Convert_v1alpha2_HostPathMount_To_kubeadm_HostPathMount(in *HostPathMount, out *kubeadm.HostPathMount, s conversion.Scope) error { - return autoConvert_v1alpha2_HostPathMount_To_kubeadm_HostPathMount(in, out, s) -} - -func autoConvert_kubeadm_HostPathMount_To_v1alpha2_HostPathMount(in *kubeadm.HostPathMount, out *HostPathMount, s conversion.Scope) error { - out.Name = in.Name - out.HostPath = in.HostPath - out.MountPath = in.MountPath - out.Writable = in.Writable - out.PathType = corev1.HostPathType(in.PathType) - return nil -} - -// Convert_kubeadm_HostPathMount_To_v1alpha2_HostPathMount is an autogenerated conversion function. -func Convert_kubeadm_HostPathMount_To_v1alpha2_HostPathMount(in *kubeadm.HostPathMount, out *HostPathMount, s conversion.Scope) error { - return autoConvert_kubeadm_HostPathMount_To_v1alpha2_HostPathMount(in, out, s) -} - -func autoConvert_v1alpha2_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConfiguration, out *kubeadm.InitConfiguration, s conversion.Scope) error { - out.BootstrapTokens = *(*[]kubeadm.BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens)) - if err := Convert_v1alpha2_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil { - return err - } - // WARNING: in.API requires manual conversion: does not exist in peer-type - // WARNING: in.KubeProxy requires manual conversion: does not exist in peer-type - // WARNING: in.Etcd requires manual conversion: does not exist in peer-type - // WARNING: in.KubeletConfiguration requires manual conversion: does not exist in peer-type - // WARNING: in.Networking requires manual conversion: does not exist in peer-type - // WARNING: in.KubernetesVersion requires manual conversion: does not exist in peer-type - // WARNING: in.APIServerExtraArgs requires manual conversion: does not exist in peer-type - // WARNING: in.ControllerManagerExtraArgs requires manual conversion: does not exist in peer-type - // WARNING: in.SchedulerExtraArgs requires manual conversion: does not exist in peer-type - // WARNING: in.APIServerExtraVolumes requires manual conversion: does not exist in peer-type - // WARNING: in.ControllerManagerExtraVolumes requires manual conversion: does not exist in peer-type - // WARNING: in.SchedulerExtraVolumes requires manual conversion: does not exist in peer-type - // WARNING: in.APIServerCertSANs requires manual conversion: does not exist in peer-type - // WARNING: in.CertificatesDir requires manual conversion: does not exist in peer-type - // WARNING: in.ImageRepository requires manual conversion: does not exist in peer-type - // WARNING: in.UnifiedControlPlaneImage requires manual conversion: does not exist in peer-type - // WARNING: in.AuditPolicyConfiguration requires manual conversion: does not exist in peer-type - // WARNING: in.FeatureGates requires manual conversion: does not exist in peer-type - // WARNING: in.ClusterName requires manual conversion: does not exist in peer-type - return nil -} - -func autoConvert_kubeadm_InitConfiguration_To_v1alpha2_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error { - // WARNING: in.ClusterConfiguration requires manual conversion: does not exist in peer-type - out.BootstrapTokens = *(*[]BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens)) - if err := Convert_kubeadm_NodeRegistrationOptions_To_v1alpha2_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil { - return err - } - // WARNING: in.APIEndpoint requires manual conversion: does not exist in peer-type - return nil -} - -func autoConvert_v1alpha2_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error { - if err := Convert_v1alpha2_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil { - return err - } - out.CACertPath = in.CACertPath - out.DiscoveryFile = in.DiscoveryFile - out.DiscoveryToken = in.DiscoveryToken - out.DiscoveryTokenAPIServers = *(*[]string)(unsafe.Pointer(&in.DiscoveryTokenAPIServers)) - out.DiscoveryTimeout = (*v1.Duration)(unsafe.Pointer(in.DiscoveryTimeout)) - out.TLSBootstrapToken = in.TLSBootstrapToken - out.Token = in.Token - out.ClusterName = in.ClusterName - out.DiscoveryTokenCACertHashes = *(*[]string)(unsafe.Pointer(&in.DiscoveryTokenCACertHashes)) - out.DiscoveryTokenUnsafeSkipCAVerification = in.DiscoveryTokenUnsafeSkipCAVerification - out.ControlPlane = in.ControlPlane - // WARNING: in.AdvertiseAddress requires manual conversion: does not exist in peer-type - // WARNING: in.BindPort requires manual conversion: does not exist in peer-type - out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - return nil -} - -func autoConvert_kubeadm_JoinConfiguration_To_v1alpha2_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error { - if err := Convert_kubeadm_NodeRegistrationOptions_To_v1alpha2_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil { - return err - } - out.CACertPath = in.CACertPath - out.DiscoveryFile = in.DiscoveryFile - out.DiscoveryToken = in.DiscoveryToken - out.DiscoveryTokenAPIServers = *(*[]string)(unsafe.Pointer(&in.DiscoveryTokenAPIServers)) - out.DiscoveryTimeout = (*v1.Duration)(unsafe.Pointer(in.DiscoveryTimeout)) - out.TLSBootstrapToken = in.TLSBootstrapToken - out.Token = in.Token - out.ClusterName = in.ClusterName - out.DiscoveryTokenCACertHashes = *(*[]string)(unsafe.Pointer(&in.DiscoveryTokenCACertHashes)) - out.DiscoveryTokenUnsafeSkipCAVerification = in.DiscoveryTokenUnsafeSkipCAVerification - out.ControlPlane = in.ControlPlane - // WARNING: in.APIEndpoint requires manual conversion: does not exist in peer-type - out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - return nil -} - -func autoConvert_v1alpha2_LocalEtcd_To_kubeadm_LocalEtcd(in *LocalEtcd, out *kubeadm.LocalEtcd, s conversion.Scope) error { - out.Image = in.Image - out.DataDir = in.DataDir - out.ExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ExtraArgs)) - out.ServerCertSANs = *(*[]string)(unsafe.Pointer(&in.ServerCertSANs)) - out.PeerCertSANs = *(*[]string)(unsafe.Pointer(&in.PeerCertSANs)) - return nil -} - -// Convert_v1alpha2_LocalEtcd_To_kubeadm_LocalEtcd is an autogenerated conversion function. -func Convert_v1alpha2_LocalEtcd_To_kubeadm_LocalEtcd(in *LocalEtcd, out *kubeadm.LocalEtcd, s conversion.Scope) error { - return autoConvert_v1alpha2_LocalEtcd_To_kubeadm_LocalEtcd(in, out, s) -} - -func autoConvert_kubeadm_LocalEtcd_To_v1alpha2_LocalEtcd(in *kubeadm.LocalEtcd, out *LocalEtcd, s conversion.Scope) error { - out.Image = in.Image - out.DataDir = in.DataDir - out.ExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.ExtraArgs)) - out.ServerCertSANs = *(*[]string)(unsafe.Pointer(&in.ServerCertSANs)) - out.PeerCertSANs = *(*[]string)(unsafe.Pointer(&in.PeerCertSANs)) - return nil -} - -// Convert_kubeadm_LocalEtcd_To_v1alpha2_LocalEtcd is an autogenerated conversion function. -func Convert_kubeadm_LocalEtcd_To_v1alpha2_LocalEtcd(in *kubeadm.LocalEtcd, out *LocalEtcd, s conversion.Scope) error { - return autoConvert_kubeadm_LocalEtcd_To_v1alpha2_LocalEtcd(in, out, s) -} - -func autoConvert_v1alpha2_Networking_To_kubeadm_Networking(in *Networking, out *kubeadm.Networking, s conversion.Scope) error { - out.ServiceSubnet = in.ServiceSubnet - out.PodSubnet = in.PodSubnet - out.DNSDomain = in.DNSDomain - return nil -} - -// Convert_v1alpha2_Networking_To_kubeadm_Networking is an autogenerated conversion function. -func Convert_v1alpha2_Networking_To_kubeadm_Networking(in *Networking, out *kubeadm.Networking, s conversion.Scope) error { - return autoConvert_v1alpha2_Networking_To_kubeadm_Networking(in, out, s) -} - -func autoConvert_kubeadm_Networking_To_v1alpha2_Networking(in *kubeadm.Networking, out *Networking, s conversion.Scope) error { - out.ServiceSubnet = in.ServiceSubnet - out.PodSubnet = in.PodSubnet - out.DNSDomain = in.DNSDomain - return nil -} - -// Convert_kubeadm_Networking_To_v1alpha2_Networking is an autogenerated conversion function. -func Convert_kubeadm_Networking_To_v1alpha2_Networking(in *kubeadm.Networking, out *Networking, s conversion.Scope) error { - return autoConvert_kubeadm_Networking_To_v1alpha2_Networking(in, out, s) -} - -func autoConvert_v1alpha2_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(in *NodeRegistrationOptions, out *kubeadm.NodeRegistrationOptions, s conversion.Scope) error { - out.Name = in.Name - out.CRISocket = in.CRISocket - out.Taints = *(*[]corev1.Taint)(unsafe.Pointer(&in.Taints)) - out.KubeletExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.KubeletExtraArgs)) - return nil -} - -// Convert_v1alpha2_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions is an autogenerated conversion function. -func Convert_v1alpha2_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(in *NodeRegistrationOptions, out *kubeadm.NodeRegistrationOptions, s conversion.Scope) error { - return autoConvert_v1alpha2_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(in, out, s) -} - -func autoConvert_kubeadm_NodeRegistrationOptions_To_v1alpha2_NodeRegistrationOptions(in *kubeadm.NodeRegistrationOptions, out *NodeRegistrationOptions, s conversion.Scope) error { - out.Name = in.Name - out.CRISocket = in.CRISocket - out.Taints = *(*[]corev1.Taint)(unsafe.Pointer(&in.Taints)) - out.KubeletExtraArgs = *(*map[string]string)(unsafe.Pointer(&in.KubeletExtraArgs)) - return nil -} - -// Convert_kubeadm_NodeRegistrationOptions_To_v1alpha2_NodeRegistrationOptions is an autogenerated conversion function. -func Convert_kubeadm_NodeRegistrationOptions_To_v1alpha2_NodeRegistrationOptions(in *kubeadm.NodeRegistrationOptions, out *NodeRegistrationOptions, s conversion.Scope) error { - return autoConvert_kubeadm_NodeRegistrationOptions_To_v1alpha2_NodeRegistrationOptions(in, out, s) -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.deepcopy.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.deepcopy.go deleted file mode 100644 index bcbdbcd190c..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.deepcopy.go +++ /dev/null @@ -1,441 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - v1alpha1 "k8s.io/kube-proxy/config/v1alpha1" - v1beta1 "k8s.io/kubelet/config/v1beta1" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *API) DeepCopyInto(out *API) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new API. -func (in *API) DeepCopy() *API { - if in == nil { - return nil - } - out := new(API) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AuditPolicyConfiguration) DeepCopyInto(out *AuditPolicyConfiguration) { - *out = *in - if in.LogMaxAge != nil { - in, out := &in.LogMaxAge, &out.LogMaxAge - *out = new(int32) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AuditPolicyConfiguration. -func (in *AuditPolicyConfiguration) DeepCopy() *AuditPolicyConfiguration { - if in == nil { - return nil - } - out := new(AuditPolicyConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BootstrapToken) DeepCopyInto(out *BootstrapToken) { - *out = *in - if in.Token != nil { - in, out := &in.Token, &out.Token - *out = new(BootstrapTokenString) - **out = **in - } - if in.TTL != nil { - in, out := &in.TTL, &out.TTL - *out = new(v1.Duration) - **out = **in - } - if in.Expires != nil { - in, out := &in.Expires, &out.Expires - *out = (*in).DeepCopy() - } - if in.Usages != nil { - in, out := &in.Usages, &out.Usages - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Groups != nil { - in, out := &in.Groups, &out.Groups - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootstrapToken. -func (in *BootstrapToken) DeepCopy() *BootstrapToken { - if in == nil { - return nil - } - out := new(BootstrapToken) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BootstrapTokenString) DeepCopyInto(out *BootstrapTokenString) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BootstrapTokenString. -func (in *BootstrapTokenString) DeepCopy() *BootstrapTokenString { - if in == nil { - return nil - } - out := new(BootstrapTokenString) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Etcd) DeepCopyInto(out *Etcd) { - *out = *in - if in.Local != nil { - in, out := &in.Local, &out.Local - *out = new(LocalEtcd) - (*in).DeepCopyInto(*out) - } - if in.External != nil { - in, out := &in.External, &out.External - *out = new(ExternalEtcd) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Etcd. -func (in *Etcd) DeepCopy() *Etcd { - if in == nil { - return nil - } - out := new(Etcd) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExternalEtcd) DeepCopyInto(out *ExternalEtcd) { - *out = *in - if in.Endpoints != nil { - in, out := &in.Endpoints, &out.Endpoints - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalEtcd. -func (in *ExternalEtcd) DeepCopy() *ExternalEtcd { - if in == nil { - return nil - } - out := new(ExternalEtcd) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *HostPathMount) DeepCopyInto(out *HostPathMount) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostPathMount. -func (in *HostPathMount) DeepCopy() *HostPathMount { - if in == nil { - return nil - } - out := new(HostPathMount) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InitConfiguration) DeepCopyInto(out *InitConfiguration) { - *out = *in - out.TypeMeta = in.TypeMeta - if in.BootstrapTokens != nil { - in, out := &in.BootstrapTokens, &out.BootstrapTokens - *out = make([]BootstrapToken, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - in.NodeRegistration.DeepCopyInto(&out.NodeRegistration) - out.API = in.API - in.KubeProxy.DeepCopyInto(&out.KubeProxy) - in.Etcd.DeepCopyInto(&out.Etcd) - in.KubeletConfiguration.DeepCopyInto(&out.KubeletConfiguration) - out.Networking = in.Networking - if in.APIServerExtraArgs != nil { - in, out := &in.APIServerExtraArgs, &out.APIServerExtraArgs - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ControllerManagerExtraArgs != nil { - in, out := &in.ControllerManagerExtraArgs, &out.ControllerManagerExtraArgs - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.SchedulerExtraArgs != nil { - in, out := &in.SchedulerExtraArgs, &out.SchedulerExtraArgs - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.APIServerExtraVolumes != nil { - in, out := &in.APIServerExtraVolumes, &out.APIServerExtraVolumes - *out = make([]HostPathMount, len(*in)) - copy(*out, *in) - } - if in.ControllerManagerExtraVolumes != nil { - in, out := &in.ControllerManagerExtraVolumes, &out.ControllerManagerExtraVolumes - *out = make([]HostPathMount, len(*in)) - copy(*out, *in) - } - if in.SchedulerExtraVolumes != nil { - in, out := &in.SchedulerExtraVolumes, &out.SchedulerExtraVolumes - *out = make([]HostPathMount, len(*in)) - copy(*out, *in) - } - if in.APIServerCertSANs != nil { - in, out := &in.APIServerCertSANs, &out.APIServerCertSANs - *out = make([]string, len(*in)) - copy(*out, *in) - } - in.AuditPolicyConfiguration.DeepCopyInto(&out.AuditPolicyConfiguration) - if in.FeatureGates != nil { - in, out := &in.FeatureGates, &out.FeatureGates - *out = make(map[string]bool, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InitConfiguration. -func (in *InitConfiguration) DeepCopy() *InitConfiguration { - if in == nil { - return nil - } - out := new(InitConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *InitConfiguration) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *JoinConfiguration) DeepCopyInto(out *JoinConfiguration) { - *out = *in - out.TypeMeta = in.TypeMeta - in.NodeRegistration.DeepCopyInto(&out.NodeRegistration) - if in.DiscoveryTokenAPIServers != nil { - in, out := &in.DiscoveryTokenAPIServers, &out.DiscoveryTokenAPIServers - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.DiscoveryTimeout != nil { - in, out := &in.DiscoveryTimeout, &out.DiscoveryTimeout - *out = new(v1.Duration) - **out = **in - } - if in.DiscoveryTokenCACertHashes != nil { - in, out := &in.DiscoveryTokenCACertHashes, &out.DiscoveryTokenCACertHashes - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.FeatureGates != nil { - in, out := &in.FeatureGates, &out.FeatureGates - *out = make(map[string]bool, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JoinConfiguration. -func (in *JoinConfiguration) DeepCopy() *JoinConfiguration { - if in == nil { - return nil - } - out := new(JoinConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *JoinConfiguration) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubeProxy) DeepCopyInto(out *KubeProxy) { - *out = *in - if in.Config != nil { - in, out := &in.Config, &out.Config - *out = new(v1alpha1.KubeProxyConfiguration) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeProxy. -func (in *KubeProxy) DeepCopy() *KubeProxy { - if in == nil { - return nil - } - out := new(KubeProxy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *KubeletConfiguration) DeepCopyInto(out *KubeletConfiguration) { - *out = *in - if in.BaseConfig != nil { - in, out := &in.BaseConfig, &out.BaseConfig - *out = new(v1beta1.KubeletConfiguration) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubeletConfiguration. -func (in *KubeletConfiguration) DeepCopy() *KubeletConfiguration { - if in == nil { - return nil - } - out := new(KubeletConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *LocalEtcd) DeepCopyInto(out *LocalEtcd) { - *out = *in - if in.ExtraArgs != nil { - in, out := &in.ExtraArgs, &out.ExtraArgs - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.ServerCertSANs != nil { - in, out := &in.ServerCertSANs, &out.ServerCertSANs - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.PeerCertSANs != nil { - in, out := &in.PeerCertSANs, &out.PeerCertSANs - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalEtcd. -func (in *LocalEtcd) DeepCopy() *LocalEtcd { - if in == nil { - return nil - } - out := new(LocalEtcd) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Networking) DeepCopyInto(out *Networking) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Networking. -func (in *Networking) DeepCopy() *Networking { - if in == nil { - return nil - } - out := new(Networking) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodeRegistrationOptions) DeepCopyInto(out *NodeRegistrationOptions) { - *out = *in - if in.Taints != nil { - in, out := &in.Taints, &out.Taints - *out = make([]corev1.Taint, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.KubeletExtraArgs != nil { - in, out := &in.KubeletExtraArgs, &out.KubeletExtraArgs - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeRegistrationOptions. -func (in *NodeRegistrationOptions) DeepCopy() *NodeRegistrationOptions { - if in == nil { - return nil - } - out := new(NodeRegistrationOptions) - in.DeepCopyInto(out) - return out -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.defaults.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.defaults.go deleted file mode 100644 index dd4522ee412..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/zz_generated.defaults.go +++ /dev/null @@ -1,56 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by defaulter-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" - v1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/config/v1beta1" - v1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/config/v1alpha1" -) - -// RegisterDefaults adds defaulters functions to the given scheme. -// Public to allow building arbitrary schemes. -// All generated defaulters are covering - they call all nested defaulters. -func RegisterDefaults(scheme *runtime.Scheme) error { - scheme.AddTypeDefaultingFunc(&InitConfiguration{}, func(obj interface{}) { SetObjectDefaults_InitConfiguration(obj.(*InitConfiguration)) }) - scheme.AddTypeDefaultingFunc(&JoinConfiguration{}, func(obj interface{}) { SetObjectDefaults_JoinConfiguration(obj.(*JoinConfiguration)) }) - return nil -} - -func SetObjectDefaults_InitConfiguration(in *InitConfiguration) { - SetDefaults_InitConfiguration(in) - for i := range in.BootstrapTokens { - a := &in.BootstrapTokens[i] - SetDefaults_BootstrapToken(a) - } - SetDefaults_NodeRegistrationOptions(&in.NodeRegistration) - if in.KubeProxy.Config != nil { - v1alpha1.SetDefaults_KubeProxyConfiguration(in.KubeProxy.Config) - } - if in.KubeletConfiguration.BaseConfig != nil { - v1beta1.SetDefaults_KubeletConfiguration(in.KubeletConfiguration.BaseConfig) - } -} - -func SetObjectDefaults_JoinConfiguration(in *JoinConfiguration) { - SetDefaults_JoinConfiguration(in) - SetDefaults_NodeRegistrationOptions(&in.NodeRegistration) -} diff --git a/cmd/kubeadm/app/cmd/config.go b/cmd/kubeadm/app/cmd/config.go index a73989305df..ade117e6404 100644 --- a/cmd/kubeadm/app/cmd/config.go +++ b/cmd/kubeadm/app/cmd/config.go @@ -32,7 +32,6 @@ import ( clientset "k8s.io/client-go/kubernetes" kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme" - kubeadmapiv1alpha2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha2" kubeadmapiv1alpha3 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha3" "k8s.io/kubernetes/cmd/kubeadm/app/cmd/options" phaseutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases" @@ -125,13 +124,13 @@ func NewCmdConfigPrintDefault(out io.Writer) *cobra.Command { func getDefaultAPIObjectBytes(apiObject string) ([]byte, error) { switch apiObject { - case constants.InitConfigurationKind, constants.MasterConfigurationKind: + case constants.InitConfigurationKind: return getDefaultInitConfigBytes(constants.InitConfigurationKind) case constants.ClusterConfigurationKind: return getDefaultInitConfigBytes(constants.ClusterConfigurationKind) - case constants.JoinConfigurationKind, constants.NodeConfigurationKind: + case constants.JoinConfigurationKind: return getDefaultNodeConfigBytes() default: @@ -154,8 +153,9 @@ func getSupportedAPIObjects() []string { } // getAllAPIObjectNames returns currently supported API object names and their historical aliases +// NB. currently there is no historical supported API objects, but we keep this function for future changes func getAllAPIObjectNames() []string { - historicAPIObjectAliases := []string{constants.MasterConfigurationKind} + historicAPIObjectAliases := []string{} objects := getSupportedAPIObjects() objects = append(objects, historicAPIObjectAliases...) return objects @@ -228,7 +228,6 @@ func NewCmdConfigMigrate(out io.Writer) *cobra.Command { locally in the CLI tool without ever touching anything in the cluster. In this version of kubeadm, the following API versions are supported: - %s - - %s Further, kubeadm can only write out config of version %q, but read both types. So regardless of what version you pass to the --old-config parameter here, the API object will be @@ -237,7 +236,7 @@ func NewCmdConfigMigrate(out io.Writer) *cobra.Command { In other words, the output of this command is what kubeadm actually would read internally if you submitted this file to "kubeadm init" - `), kubeadmapiv1alpha2.SchemeGroupVersion.String(), kubeadmapiv1alpha3.SchemeGroupVersion.String(), kubeadmapiv1alpha3.SchemeGroupVersion.String()), + `), kubeadmapiv1alpha3.SchemeGroupVersion.String(), kubeadmapiv1alpha3.SchemeGroupVersion.String()), Run: func(cmd *cobra.Command, args []string) { if len(oldCfgPath) == 0 { kubeadmutil.CheckErr(fmt.Errorf("The --old-config flag is mandatory")) @@ -380,7 +379,7 @@ func RunConfigView(out io.Writer, client clientset.Interface) error { return err } // No need to append \n as that already exists in the ConfigMap - fmt.Fprintf(out, "%s", cfgConfigMap.Data[constants.InitConfigurationConfigMapKey]) + fmt.Fprintf(out, "%s", cfgConfigMap.Data[constants.ClusterConfigurationConfigMapKey]) return nil } diff --git a/cmd/kubeadm/app/cmd/config_test.go b/cmd/kubeadm/app/cmd/config_test.go index defa2a9bc3c..5c9fb66859c 100644 --- a/cmd/kubeadm/app/cmd/config_test.go +++ b/cmd/kubeadm/app/cmd/config_test.go @@ -29,7 +29,6 @@ import ( kubeadmapiv1alpha3 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha3" "k8s.io/kubernetes/cmd/kubeadm/app/cmd" "k8s.io/kubernetes/cmd/kubeadm/app/features" - "k8s.io/kubernetes/cmd/kubeadm/app/util/config" utilruntime "k8s.io/kubernetes/cmd/kubeadm/app/util/runtime" "k8s.io/utils/exec" fakeexec "k8s.io/utils/exec/testing" @@ -232,28 +231,32 @@ func TestImagesPull(t *testing.T) { } func TestMigrate(t *testing.T) { - cfg := []byte(dedent.Dedent(` - # This is intentionally testing an old API version and the old kind naming and making sure the output is correct - apiVersion: kubeadm.k8s.io/v1alpha2 - kind: MasterConfiguration - kubernetesVersion: v1.11.0 - `)) - configFile, cleanup := tempConfig(t, cfg) - defer cleanup() + /* + TODO: refactor this to test v1alpha3 --> v1beta1 after introducing v1beta1 - var output bytes.Buffer - command := cmd.NewCmdConfigMigrate(&output) - if err := command.Flags().Set("old-config", configFile); err != nil { - t.Fatalf("failed to set old-config flag") - } - newConfigPath := filepath.Join(filepath.Dir(configFile), "new-migrated-config") - if err := command.Flags().Set("new-config", newConfigPath); err != nil { - t.Fatalf("failed to set new-config flag") - } - command.Run(nil, nil) - if _, err := config.ConfigFileAndDefaultsToInternalConfig(newConfigPath, &kubeadmapiv1alpha3.InitConfiguration{}); err != nil { - t.Fatalf("Could not read output back into internal type: %v", err) - } + cfg := []byte(dedent.Dedent(` + # This is intentionally testing an old API version and the old kind naming and making sure the output is correct + apiVersion: kubeadm.k8s.io/v1alpha2 + kind: MasterConfiguration + kubernetesVersion: v1.11.0 + `)) + configFile, cleanup := tempConfig(t, cfg) + defer cleanup() + + var output bytes.Buffer + command := cmd.NewCmdConfigMigrate(&output) + if err := command.Flags().Set("old-config", configFile); err != nil { + t.Fatalf("failed to set old-config flag") + } + newConfigPath := filepath.Join(filepath.Dir(configFile), "new-migrated-config") + if err := command.Flags().Set("new-config", newConfigPath); err != nil { + t.Fatalf("failed to set new-config flag") + } + command.Run(nil, nil) + if _, err := config.ConfigFileAndDefaultsToInternalConfig(newConfigPath, &kubeadmapiv1alpha3.InitConfiguration{}); err != nil { + t.Fatalf("Could not read output back into internal type: %v", err) + } + */ } // Returns the name of the file created and a cleanup callback diff --git a/cmd/kubeadm/app/cmd/upgrade/testdata/diff_master_config.yaml b/cmd/kubeadm/app/cmd/upgrade/testdata/diff_master_config.yaml index b5e5611c0fe..c9ae6e2bd36 100644 --- a/cmd/kubeadm/app/cmd/upgrade/testdata/diff_master_config.yaml +++ b/cmd/kubeadm/app/cmd/upgrade/testdata/diff_master_config.yaml @@ -1,3 +1,3 @@ -apiVersion: kubeadm.k8s.io/v1alpha2 -kind: MasterConfiguration -kubernetesVersion: 1.11.0 +apiVersion: kubeadm.k8s.io/v1alpha3 +kind: ClusterConfiguration +kubernetesVersion: 1.12.0 diff --git a/cmd/kubeadm/app/constants/constants.go b/cmd/kubeadm/app/constants/constants.go index 86ac6cdecfc..2de9cc4afd8 100644 --- a/cmd/kubeadm/app/constants/constants.go +++ b/cmd/kubeadm/app/constants/constants.go @@ -192,10 +192,6 @@ const ( // TODO: Rename this to KubeadmConfigConfigMap InitConfigurationConfigMap = "kubeadm-config" - // InitConfigurationConfigMapKey specifies in what ConfigMap key the master configuration should be stored - // TODO: This was used in v1.11 with vi1alpha2 config and older. Remove in v1.13 - InitConfigurationConfigMapKey = "MasterConfiguration" - // ClusterConfigurationConfigMapKey specifies in what ConfigMap key the cluster configuration should be stored ClusterConfigurationConfigMapKey = "ClusterConfiguration" @@ -310,17 +306,9 @@ const ( // InitConfigurationKind is the string kind value for the InitConfiguration struct InitConfigurationKind = "InitConfiguration" - // MasterConfigurationKind is the string kind value for the v1alpha2-named MasterConfiguration struct - // In v1alpha3 and higher, this struct is now named InitConfiguration - MasterConfigurationKind = "MasterConfiguration" - // JoinConfigurationKind is the string kind value for the JoinConfiguration struct JoinConfigurationKind = "JoinConfiguration" - // NodeConfigurationKind is the string kind value for the v1alpha2-named NodeConfiguration struct - // In v1alpha3 and higher, this struct is now named JoinConfiguration - NodeConfigurationKind = "NodeConfiguration" - // YAMLDocumentSeparator is the separator for YAML documents // TODO: Find a better place for this constant YAMLDocumentSeparator = "---\n" diff --git a/cmd/kubeadm/app/util/config/cluster.go b/cmd/kubeadm/app/util/config/cluster.go index 7917381e7c4..a3b6b909df7 100644 --- a/cmd/kubeadm/app/util/config/cluster.go +++ b/cmd/kubeadm/app/util/config/cluster.go @@ -73,12 +73,10 @@ func loadInitConfigurationFromFile(cfgPath string) (*kubeadmapi.InitConfiguratio // Unmarshal the versioned configuration populated from the file, // convert it to the internal API types, then default and validate - // NB the file can be one of - // - a single YAML, with a v1alpha2.MasterConfiguration object (with embedded component configs) - // - multiple YAML, with a combination of - // - a YAML with a v1alpha3.InitConfiguration object - // - a YAML with a v1alpha3.ClusterConfiguration object (without embedded component configs) - // - separated YAML for components configs + // NB the file contains multiple YAML, with a combination of + // - a YAML with a InitConfiguration object + // - a YAML with a ClusterConfiguration object (without embedded component configs) + // - separated YAML for components configs initcfg, err := BytesToInternalConfig(configBytes) if err != nil { return nil, err @@ -95,35 +93,11 @@ func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Inte return nil, err } - // TODO: remove in V1.13 - // If InitConfigurationConfigMapKey exist, the kubeadm-config was created with v1.11 - if _, ok := configMap.Data[constants.InitConfigurationConfigMapKey]; ok { - return getInitConfigurationFromConfigMapV11(configMap.Data) - } - - return getInitConfigurationFromConfigMaps(kubeconfigDir, client, configMap.Data, newControlPlane) -} - -func getInitConfigurationFromConfigMapV11(data map[string]string) (*kubeadmapi.InitConfiguration, error) { - configBytes := []byte(data[constants.InitConfigurationConfigMapKey]) - - // Unmarshal the versioned configuration populated from the file, - // convert it to the internal API types, then default and validate - // NB the config map created with v11 is a single YAML, with a v1alpha2.MasterConfiguration object (with embedded component configs) - initcfg, err := BytesToInternalConfig(configBytes) - if err != nil { - return nil, err - } - - return initcfg, nil -} - -func getInitConfigurationFromConfigMaps(kubeconfigDir string, client clientset.Interface, data map[string]string, newControlPlane bool) (*kubeadmapi.InitConfiguration, error) { - // In case of cluster crated with v1.12 InitConfiguration is composed with data from different places + // InitConfiguration is composed with data from different places initcfg := &kubeadmapi.InitConfiguration{} // gets ClusterConfiguration from kubeadm-config - clusterConfigurationData, ok := data[constants.ClusterConfigurationConfigMapKey] + clusterConfigurationData, ok := configMap.Data[constants.ClusterConfigurationConfigMapKey] if !ok { return nil, fmt.Errorf("unexpected error when reading kubeadm-config ConfigMap: %s key value pair missing", constants.ClusterConfigurationConfigMapKey) } @@ -144,7 +118,7 @@ func getInitConfigurationFromConfigMaps(kubeconfigDir string, client clientset.I return nil, err } // gets the APIEndpoint for the current node from then ClusterStatus in the kubeadm-config ConfigMap - if err := getAPIEndpoint(data, initcfg.NodeRegistration.Name, &initcfg.APIEndpoint); err != nil { + if err := getAPIEndpoint(configMap.Data, initcfg.NodeRegistration.Name, &initcfg.APIEndpoint); err != nil { return nil, err } } diff --git a/cmd/kubeadm/app/util/config/cluster_test.go b/cmd/kubeadm/app/util/config/cluster_test.go index 77ba145f917..373b1c03dfa 100644 --- a/cmd/kubeadm/app/util/config/cluster_test.go +++ b/cmd/kubeadm/app/util/config/cluster_test.go @@ -38,14 +38,6 @@ var k8sVersionString = "v1.12.0" var k8sVersion = version.MustParseGeneric(k8sVersionString) var nodeName = "mynode" var cfgFiles = map[string][]byte{ - "MasterConfiguration_v1alpha2": []byte(` -apiVersion: kubeadm.k8s.io/v1alpha2 -kind: MasterConfiguration -kubernetesVersion: ` + k8sVersionString + ` -api: - advertiseAddress: 1.2.3.4 - bindPort: 1234 -`), "InitConfiguration_v1alpha3": []byte(` apiVersion: kubeadm.k8s.io/v1alpha3 kind: InitConfiguration @@ -171,10 +163,7 @@ func TestLoadInitConfigurationFromFile(t *testing.T) { name string fileContents []byte }{ - { - name: "v1alpha2.MasterConfiguration", - fileContents: cfgFiles["MasterConfiguration_v1alpha2"], - }, + // TODO: implemen v1beta1 tests after introducing v1beta1 { name: "v1alpha3.partial1", fileContents: cfgFiles["InitConfiguration_v1alpha3"], @@ -523,17 +512,6 @@ func TestGetInitConfigurationFromCluster(t *testing.T) { newControlPlane bool expectedError bool }{ - { //TODO: remove in V1.13 - name: "before v1.11", // single YAML, with a v1alpha2.MasterConfiguration object (with embedded component configs) - configMaps: []fakeConfigMap{ - { - name: kubeadmconstants.InitConfigurationConfigMap, - data: map[string]string{ - kubeadmconstants.InitConfigurationConfigMapKey: string(cfgFiles["MasterConfiguration_v1alpha2"]), - }, - }, - }, - }, { name: "invalid - No kubeadm-config ConfigMap", expectedError: true, diff --git a/cmd/kubeadm/app/util/config/common.go b/cmd/kubeadm/app/util/config/common.go index 3573f2e9789..b63247b4105 100644 --- a/cmd/kubeadm/app/util/config/common.go +++ b/cmd/kubeadm/app/util/config/common.go @@ -79,11 +79,11 @@ func DetectUnsupportedVersion(b []byte) error { // tell them how to upgrade. The support matrix will look something like this now and in the future: // v1.10 and earlier: v1alpha1 // v1.11: v1alpha1 read-only, writes only v1alpha2 config - // v1.12: v1alpha2 read-only, writes only v1beta1 config. Warns if the user tries to use v1alpha1 - // v1.13 and v1.14: v1beta1 read-only, writes only v1 config. Warns if the user tries to use v1alpha1 or v1alpha2. - // v1.15: v1 is the only supported format. + // v1.12: v1alpha2 read-only, writes only v1alpha3 config. Warns if the user tries to use v1alpha1 + // v1.13: v1alpha3 read-only, writes only v1beta1 config. Warns if the user tries to use v1alpha1 or v1alpha2 oldKnownAPIVersions := map[string]string{ "kubeadm.k8s.io/v1alpha1": "v1.11", + "kubeadm.k8s.io/v1alpha2": "v1.12", } // If we find an old API version in this gvk list, error out and tell the user why this doesn't work knownKinds := map[string]bool{} @@ -94,7 +94,7 @@ func DetectUnsupportedVersion(b []byte) error { knownKinds[gvk.Kind] = true } // InitConfiguration, MasterConfiguration and NodeConfiguration are mutually exclusive, error if more than one are specified - mutuallyExclusive := []string{constants.InitConfigurationKind, constants.MasterConfigurationKind, constants.JoinConfigurationKind, constants.NodeConfigurationKind} + mutuallyExclusive := []string{constants.InitConfigurationKind, constants.JoinConfigurationKind} foundOne := false for _, kind := range mutuallyExclusive { if knownKinds[kind] { diff --git a/cmd/kubeadm/app/util/config/common_test.go b/cmd/kubeadm/app/util/config/common_test.go index c945a1a9dd6..ce671391a9d 100644 --- a/cmd/kubeadm/app/util/config/common_test.go +++ b/cmd/kubeadm/app/util/config/common_test.go @@ -84,10 +84,12 @@ func TestDetectUnsupportedVersion(t *testing.T) { { name: "Master_v1alpha2", fileContents: files["Master_v1alpha2"], + expectedErr: true, }, { name: "Node_v1alpha2", fileContents: files["Node_v1alpha2"], + expectedErr: true, }, { name: "Init_v1alpha3", @@ -97,16 +99,6 @@ func TestDetectUnsupportedVersion(t *testing.T) { name: "Join_v1alpha3", fileContents: files["Join_v1alpha3"], }, - { - name: "DuplicateMaster", - fileContents: bytes.Join([][]byte{files["Master_v1alpha2"], files["Master_v1alpha2"]}, []byte(constants.YAMLDocumentSeparator)), - expectedErr: true, - }, - { - name: "DuplicateNode", - fileContents: bytes.Join([][]byte{files["Node_v1alpha2"], files["Node_v1alpha2"]}, []byte(constants.YAMLDocumentSeparator)), - expectedErr: true, - }, { name: "DuplicateInit", fileContents: bytes.Join([][]byte{files["Init_v1alpha3"], files["Init_v1alpha3"]}, []byte(constants.YAMLDocumentSeparator)), @@ -132,31 +124,7 @@ func TestDetectUnsupportedVersion(t *testing.T) { fileContents: bytes.Join([][]byte{files["Foo"], files["Master_v1alpha1"]}, []byte(constants.YAMLDocumentSeparator)), expectedErr: true, }, - { - name: "MustNotMixMasterNode", - fileContents: bytes.Join([][]byte{files["Master_v1alpha2"], files["Node_v1alpha2"]}, []byte(constants.YAMLDocumentSeparator)), - expectedErr: true, - }, - { - name: "MustNotMixMasterJoin", - fileContents: bytes.Join([][]byte{files["Master_v1alpha2"], files["Join_v1alpha3"]}, []byte(constants.YAMLDocumentSeparator)), - expectedErr: true, - }, - { - name: "MustNotMixJoinNode", - fileContents: bytes.Join([][]byte{files["Join_v1alpha3"], files["Node_v1alpha2"]}, []byte(constants.YAMLDocumentSeparator)), - expectedErr: true, - }, - { - name: "MustNotMixInitMaster", - fileContents: bytes.Join([][]byte{files["Init_v1alpha3"], files["Master_v1alpha2"]}, []byte(constants.YAMLDocumentSeparator)), - expectedErr: true, - }, - { - name: "MustNotMixInitNode", - fileContents: bytes.Join([][]byte{files["Init_v1alpha3"], files["Node_v1alpha2"]}, []byte(constants.YAMLDocumentSeparator)), - expectedErr: true, - }, + // TODO: implement mustnotMix v1alpha3 v1beta1 after introducing v1beta1 { name: "MustNotMixInitJoin", fileContents: bytes.Join([][]byte{files["Init_v1alpha3"], files["Join_v1alpha3"]}, []byte(constants.YAMLDocumentSeparator)), diff --git a/cmd/kubeadm/app/util/config/masterconfig_test.go b/cmd/kubeadm/app/util/config/masterconfig_test.go index f35f9f158dd..de57d4b1e90 100644 --- a/cmd/kubeadm/app/util/config/masterconfig_test.go +++ b/cmd/kubeadm/app/util/config/masterconfig_test.go @@ -30,12 +30,12 @@ import ( ) const ( - master_v1alpha2YAML = "testdata/conversion/master/v1alpha2.yaml" - master_v1alpha3YAML = "testdata/conversion/master/v1alpha3.yaml" - master_internalYAML = "testdata/conversion/master/internal.yaml" - master_incompleteYAML = "testdata/defaulting/master/incomplete.yaml" - master_defaultedYAML = "testdata/defaulting/master/defaulted.yaml" - master_invalidYAML = "testdata/validation/invalid_mastercfg.yaml" + master_v1alpha3YAML = "testdata/conversion/master/v1alpha3.yaml" + //TODO master_v1beta1YAML = "testdata/conversion/master/v1beta1.yaml" after introducing v1beta1 + master_internalYAML = "testdata/conversion/master/internal.yaml" + //TODO master_incompleteYAML = "testdata/defaulting/master/incomplete.yaml" (using v1alpha3) after introducing v1beta1 + master_defaultedYAML = "testdata/defaulting/master/defaulted.yaml" + master_invalidYAML = "testdata/validation/invalid_mastercfg.yaml" ) func diff(expected, actual []byte) string { @@ -59,24 +59,14 @@ func TestConfigFileAndDefaultsToInternalConfig(t *testing.T) { }{ // These tests are reading one file, loading it using ConfigFileAndDefaultsToInternalConfig that all of kubeadm is using for unmarshal of our API types, // and then marshals the internal object to the expected groupVersion - { // v1alpha2 -> internal - name: "v1alpha2ToInternal", - in: master_v1alpha2YAML, - out: master_internalYAML, - groupVersion: kubeadm.SchemeGroupVersion, - }, { // v1alpha3 -> internal name: "v1alpha3ToInternal", in: master_v1alpha3YAML, out: master_internalYAML, groupVersion: kubeadm.SchemeGroupVersion, }, - { // v1alpha2 -> internal -> v1alpha3 - name: "v1alpha2Tov1alpha3", - in: master_v1alpha2YAML, - out: master_v1alpha3YAML, - groupVersion: kubeadmapiv1alpha3.SchemeGroupVersion, - }, + // TODO: implement v1beta1 <-> internal after introducing v1beta1 + // TODO: implement v1alpha3 -> internal -> v1beta1 after introducing v1beta1 { // v1alpha3 -> internal -> v1alpha3 name: "v1alpha3Tov1alpha3", in: master_v1alpha3YAML, @@ -85,13 +75,8 @@ func TestConfigFileAndDefaultsToInternalConfig(t *testing.T) { }, // These tests are reading one file that has only a subset of the fields populated, loading it using ConfigFileAndDefaultsToInternalConfig, // and then marshals the internal object to the expected groupVersion - { // v1alpha2 -> default -> validate -> internal -> v1alpha3 - name: "incompleteYAMLToDefaultedv1alpha3", - in: master_incompleteYAML, - out: master_defaultedYAML, - groupVersion: kubeadmapiv1alpha3.SchemeGroupVersion, - }, - { // v1alpha2 -> validation should fail + // TODO: implement v1alpha3 -> default -> validate -> v1beta1 -> v1alpha3 after introducing v1beta1 + { // v1alpha3 -> validation should fail name: "invalidYAMLShouldFail", in: master_invalidYAML, expectedErr: true, diff --git a/cmd/kubeadm/app/util/config/nodeconfig_test.go b/cmd/kubeadm/app/util/config/nodeconfig_test.go index cda3ac945da..c93882f148a 100644 --- a/cmd/kubeadm/app/util/config/nodeconfig_test.go +++ b/cmd/kubeadm/app/util/config/nodeconfig_test.go @@ -29,12 +29,12 @@ import ( ) const ( - node_v1alpha2YAML = "testdata/conversion/node/v1alpha2.yaml" - node_v1alpha3YAML = "testdata/conversion/node/v1alpha3.yaml" - node_internalYAML = "testdata/conversion/node/internal.yaml" - node_incompleteYAML = "testdata/defaulting/node/incomplete.yaml" - node_defaultedYAML = "testdata/defaulting/node/defaulted.yaml" - node_invalidYAML = "testdata/validation/invalid_nodecfg.yaml" + node_v1alpha3YAML = "testdata/conversion/node/v1alpha3.yaml" + //TODO node_v1beta1YAML = "testdata/conversion/node/v1beta1.yaml" after introducing v1beta1 + node_internalYAML = "testdata/conversion/node/internal.yaml" + //TODO node_incompleteYAML = "testdata/defaulting/node/incomplete.yaml" (using v1alpha3) after introducing v1beta1 + node_defaultedYAML = "testdata/defaulting/node/defaulted.yaml" + node_invalidYAML = "testdata/validation/invalid_nodecfg.yaml" ) func TestNodeConfigFileAndDefaultsToInternalConfig(t *testing.T) { @@ -45,24 +45,14 @@ func TestNodeConfigFileAndDefaultsToInternalConfig(t *testing.T) { }{ // These tests are reading one file, loading it using NodeConfigFileAndDefaultsToInternalConfig that all of kubeadm is using for unmarshal of our API types, // and then marshals the internal object to the expected groupVersion - { // v1alpha2 -> internal - name: "v1alpha2ToInternal", - in: node_v1alpha2YAML, - out: node_internalYAML, - groupVersion: kubeadm.SchemeGroupVersion, - }, { // v1alpha3 -> internal name: "v1alpha3ToInternal", in: node_v1alpha3YAML, out: node_internalYAML, groupVersion: kubeadm.SchemeGroupVersion, }, - { // v1alpha2 -> internal -> v1alpha3 - name: "v1alpha2Tov1alpha3", - in: node_v1alpha2YAML, - out: node_v1alpha3YAML, - groupVersion: kubeadmapiv1alpha3.SchemeGroupVersion, - }, + // TODO: implement v1beta1 <-> internal after introducing v1beta1 + // TODO: implement v1alpha3 -> internal -> v1beta1 after introducing v1beta1 { // v1alpha3 -> internal -> v1alpha3 name: "v1alpha3Tov1alpha3", in: node_v1alpha3YAML, @@ -71,13 +61,8 @@ func TestNodeConfigFileAndDefaultsToInternalConfig(t *testing.T) { }, // These tests are reading one file that has only a subset of the fields populated, loading it using NodeConfigFileAndDefaultsToInternalConfig, // and then marshals the internal object to the expected groupVersion - { // v1alpha2 -> default -> validate -> internal -> v1alpha3 - name: "incompleteYAMLToDefaulted", - in: node_incompleteYAML, - out: node_defaultedYAML, - groupVersion: kubeadmapiv1alpha3.SchemeGroupVersion, - }, - { // v1alpha2 -> validation should fail + // TODO: implement v1alpha3 -> default -> validate -> v1beta1 -> v1alpha3 after introducing v1beta1 + { // v1alpha3 -> validation should fail name: "invalidYAMLShouldFail", in: node_invalidYAML, expectedErr: true, diff --git a/cmd/kubeadm/app/util/config/testdata/conversion/master/v1alpha2.yaml b/cmd/kubeadm/app/util/config/testdata/conversion/master/v1alpha2.yaml deleted file mode 100644 index b5ffea7a2cd..00000000000 --- a/cmd/kubeadm/app/util/config/testdata/conversion/master/v1alpha2.yaml +++ /dev/null @@ -1,150 +0,0 @@ -api: - advertiseAddress: 192.168.2.2 - bindPort: 6443 - controlPlaneEndpoint: "" -apiServerExtraArgs: - authorization-mode: Node,RBAC,Webhook -apiVersion: kubeadm.k8s.io/v1alpha2 -auditPolicy: - logDir: /var/log/kubernetes/audit - logMaxAge: 2 - path: "" -bootstrapTokens: -- groups: - - system:bootstrappers:kubeadm:default-node-token - token: s73ybu.6tw6wnqgp5z0wb77 - ttl: 24h0m0s - usages: - - signing - - authentication -certificatesDir: /etc/kubernetes/pki -clusterName: kubernetes -etcd: - local: - dataDir: /var/lib/etcd - image: "" -imageRepository: k8s.gcr.io -kind: MasterConfiguration -kubeProxy: - config: - bindAddress: 0.0.0.0 - clientConnection: - acceptContentTypes: "" - burst: 10 - contentType: application/vnd.kubernetes.protobuf - kubeconfig: /var/lib/kube-proxy/kubeconfig.conf - qps: 5 - clusterCIDR: "" - configSyncPeriod: 15m0s - conntrack: - max: null - maxPerCore: 32768 - min: 131072 - tcpCloseWaitTimeout: 1h0m0s - tcpEstablishedTimeout: 24h0m0s - enableProfiling: false - featureGates: - ServiceNodeExclusion: true - SupportIPVSProxyMode: true - healthzBindAddress: 0.0.0.0:10256 - hostnameOverride: "" - iptables: - masqueradeAll: false - masqueradeBit: 14 - minSyncPeriod: 0s - syncPeriod: 30s - ipvs: - excludeCIDRs: null - minSyncPeriod: 0s - scheduler: "" - syncPeriod: 30s - metricsBindAddress: 127.0.0.1:10249 - mode: iptables - nodePortAddresses: null - oomScoreAdj: -999 - portRange: "" - resourceContainer: /kube-proxy - udpIdleTimeout: 250ms -kubeletConfiguration: - baseConfig: - address: 1.2.3.4 - authentication: - anonymous: - enabled: false - webhook: - cacheTTL: 2m0s - enabled: true - x509: - clientCAFile: /etc/kubernetes/pki/ca.crt - authorization: - mode: Webhook - webhook: - cacheAuthorizedTTL: 5m0s - cacheUnauthorizedTTL: 30s - cgroupDriver: cgroupfs - cgroupsPerQOS: true - clusterDNS: - - 10.96.0.10 - clusterDomain: cluster.local - configMapAndSecretChangeDetectionStrategy: Watch - containerLogMaxFiles: 5 - containerLogMaxSize: 10Mi - contentType: application/vnd.kubernetes.protobuf - cpuCFSQuota: true - cpuCFSQuotaPeriod: 0s - cpuManagerPolicy: none - cpuManagerReconcilePeriod: 10s - enableControllerAttachDetach: true - enableDebuggingHandlers: true - enforceNodeAllocatable: - - pods - eventBurst: 10 - eventRecordQPS: 5 - evictionHard: - imagefs.available: 15% - memory.available: 100Mi - nodefs.available: 10% - nodefs.inodesFree: 5% - evictionPressureTransitionPeriod: 5m0s - failSwapOn: true - fileCheckFrequency: 20s - hairpinMode: promiscuous-bridge - healthzBindAddress: 127.0.0.1 - healthzPort: 10248 - httpCheckFrequency: 20s - imageGCHighThresholdPercent: 85 - imageGCLowThresholdPercent: 80 - imageMinimumGCAge: 2m0s - iptablesDropBit: 15 - iptablesMasqueradeBit: 14 - kubeAPIBurst: 10 - kubeAPIQPS: 5 - makeIPTablesUtilChains: true - maxOpenFiles: 1000000 - maxPods: 110 - nodeStatusUpdateFrequency: 10s - oomScoreAdj: -999 - podPidsLimit: -1 - port: 10250 - registryBurst: 10 - registryPullQPS: 5 - resolvConf: /etc/resolv.conf - rotateCertificates: true - runtimeRequestTimeout: 2m0s - serializeImagePulls: true - staticPodPath: /etc/kubernetes/manifests - streamingConnectionIdleTimeout: 4h0m0s - syncFrequency: 1m0s - volumeStatsAggPeriod: 1m0s -kubernetesVersion: v1.11.2 -networking: - dnsDomain: cluster.local - podSubnet: "" - serviceSubnet: 10.96.0.0/12 -nodeRegistration: - criSocket: /var/run/dockershim.sock - name: master-1 - taints: - - effect: NoSchedule - key: node-role.kubernetes.io/master -unifiedControlPlaneImage: "" diff --git a/cmd/kubeadm/app/util/config/testdata/conversion/node/v1alpha2.yaml b/cmd/kubeadm/app/util/config/testdata/conversion/node/v1alpha2.yaml deleted file mode 100644 index 4b5e36e923f..00000000000 --- a/cmd/kubeadm/app/util/config/testdata/conversion/node/v1alpha2.yaml +++ /dev/null @@ -1,16 +0,0 @@ -advertiseAddress: 192.168.2.2 -apiVersion: kubeadm.k8s.io/v1alpha2 -caCertPath: /etc/kubernetes/pki/ca.crt -clusterName: kubernetes -discoveryFile: "" -discoveryTimeout: 5m0s -discoveryToken: abcdef.0123456789abcdef -discoveryTokenAPIServers: -- kube-apiserver:6443 -discoveryTokenUnsafeSkipCAVerification: true -kind: NodeConfiguration -nodeRegistration: - criSocket: /var/run/dockershim.sock - name: master-1 -tlsBootstrapToken: abcdef.0123456789abcdef -token: abcdef.0123456789abcdef diff --git a/cmd/kubeadm/app/util/config/testdata/defaulting/master/incomplete.yaml b/cmd/kubeadm/app/util/config/testdata/defaulting/master/incomplete.yaml deleted file mode 100644 index fd0fe30d712..00000000000 --- a/cmd/kubeadm/app/util/config/testdata/defaulting/master/incomplete.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kubeadm.k8s.io/v1alpha2 -kind: MasterConfiguration -api: - advertiseAddress: 192.168.2.2 - bindPort: 6443 -bootstrapTokens: -- token: s73ybu.6tw6wnqgp5z0wb77 -certificatesDir: /var/lib/kubernetes/pki -clusterName: kubernetes -imageRepository: my-company.com -kubernetesVersion: v1.11.2 -networking: - dnsDomain: cluster.global - serviceSubnet: 10.196.0.0/12 - podSubnet: 10.148.0.0/16 -nodeRegistration: - criSocket: /var/run/criruntime.sock - name: master-1 diff --git a/cmd/kubeadm/app/util/config/testdata/defaulting/node/incomplete.yaml b/cmd/kubeadm/app/util/config/testdata/defaulting/node/incomplete.yaml deleted file mode 100644 index 149f8f2770f..00000000000 --- a/cmd/kubeadm/app/util/config/testdata/defaulting/node/incomplete.yaml +++ /dev/null @@ -1,9 +0,0 @@ -advertiseAddress: 192.168.2.2 -apiVersion: kubeadm.k8s.io/v1alpha2 -kind: NodeConfiguration -discoveryTokenAPIServers: -- kube-apiserver:6443 -discoveryTokenUnsafeSkipCAVerification: true -nodeRegistration: - name: thegopher -token: abcdef.0123456789abcdef diff --git a/cmd/kubeadm/app/util/config/testdata/validation/invalid_mastercfg.yaml b/cmd/kubeadm/app/util/config/testdata/validation/invalid_mastercfg.yaml index b53e7106a48..5579fd38d8e 100644 --- a/cmd/kubeadm/app/util/config/testdata/validation/invalid_mastercfg.yaml +++ b/cmd/kubeadm/app/util/config/testdata/validation/invalid_mastercfg.yaml @@ -1,16 +1,7 @@ -apiVersion: kubeadm.k8s.io/v1alpha2 -kind: MasterConfiguration -api: - bindPort: 0 -bootstrapTokens: -- token: s7bu.6tw6wn -certificatesDir: relativepath -clusterName: kubernetes -imageRepository: my-company.com -kubernetesVersion: v1.11.2 +apiVersion: kubeadm.k8s.io/v1alpha3 +kind: ClusterConfiguration networking: - dnsDomain: cluster.GLOBAL - serviceSubnet: 10.196.1000.0/100 -nodeRegistration: - criSocket: relativepath - name: MASTER + dnsDomain: INVALID-DOMAIN-!!!! + podSubnet: "" + serviceSubnet: 10.96.0.0/12 +unifiedControlPlaneImage: "" \ No newline at end of file diff --git a/cmd/kubeadm/app/util/config/testdata/validation/invalid_nodecfg.yaml b/cmd/kubeadm/app/util/config/testdata/validation/invalid_nodecfg.yaml index 997c19ccbeb..34498e89527 100644 --- a/cmd/kubeadm/app/util/config/testdata/validation/invalid_nodecfg.yaml +++ b/cmd/kubeadm/app/util/config/testdata/validation/invalid_nodecfg.yaml @@ -1,12 +1,7 @@ apiVersion: kubeadm.k8s.io/v1alpha2 kind: NodeConfiguration -caCertPath: relativepath -discoveryFile: relativepath -discoveryTimeout: not-a-time -discoveryTokenAPIServers: -- INVALID_URL -discoveryTokenUnsafeSkipCAVerification: false -nodeRegistration: - criSocket: relativepath - name: NODE-1 -token: invalidtoken +apiEndpoint: + advertiseAddress: INVALID-ADDRESS-!!!! + bindPort: 6443 +apiVersion: kubeadm.k8s.io/v1alpha3 +kind: JoinConfiguration diff --git a/cmd/kubeadm/app/util/marshal.go b/cmd/kubeadm/app/util/marshal.go index a22f62ba62c..6e95dcc7151 100644 --- a/cmd/kubeadm/app/util/marshal.go +++ b/cmd/kubeadm/app/util/marshal.go @@ -156,10 +156,10 @@ func GroupVersionKindsHasClusterConfiguration(gvks ...schema.GroupVersionKind) b func GroupVersionKindsHasInitConfiguration(gvks ...schema.GroupVersionKind) bool { // Finding a MasterConfiguration kind is also okay, as it will decode and convert into an InitConfiguration struct eventually // TODO: When we remove support for the v1alpha2 API, remove support for MasterConfiguration - return GroupVersionKindsHasKind(gvks, constants.InitConfigurationKind) || GroupVersionKindsHasKind(gvks, constants.MasterConfigurationKind) + return GroupVersionKindsHasKind(gvks, constants.InitConfigurationKind) } // GroupVersionKindsHasJoinConfiguration returns whether the following gvk slice contains a JoinConfiguration object func GroupVersionKindsHasJoinConfiguration(gvks ...schema.GroupVersionKind) bool { - return GroupVersionKindsHasKind(gvks, constants.JoinConfigurationKind) || GroupVersionKindsHasKind(gvks, constants.NodeConfigurationKind) + return GroupVersionKindsHasKind(gvks, constants.JoinConfigurationKind) } diff --git a/cmd/kubeadm/test/cmd/init_test.go b/cmd/kubeadm/test/cmd/init_test.go index b150c54d8eb..f8dcf3c84ea 100644 --- a/cmd/kubeadm/test/cmd/init_test.go +++ b/cmd/kubeadm/test/cmd/init_test.go @@ -144,15 +144,16 @@ func TestCmdInitConfig(t *testing.T) { expected: false, }, { - name: "can load v1alpha2 config", + name: "can't load v1alpha2 config", args: "--config=testdata/init/v1alpha2.yaml", - expected: true, + expected: false, }, { name: "can load v1alpha3 config", args: "--config=testdata/init/v1alpha3.yaml", expected: true, }, + // TODO: implement v1beta1 tests after introducing v1beta1 { name: "don't allow mixed arguments", args: "--kubernetes-version=1.11.0 --config=testdata/init/v1alpha3.yaml", diff --git a/hack/.golint_failures b/hack/.golint_failures index e90363f49a6..a5fee3d2e9a 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -6,7 +6,6 @@ cmd/kube-apiserver/app cmd/kube-controller-manager/app cmd/kube-proxy/app cmd/kubeadm/app -cmd/kubeadm/app/apis/kubeadm/v1alpha2 cmd/kubeadm/app/apis/kubeadm/v1alpha3 cmd/kubeadm/app/util/config cmd/kubeadm/app/util/system From 4f5374e7cc228c057e8ff9717f0883f434af3439 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Wed, 26 Sep 2018 17:39:27 +0200 Subject: [PATCH 2/2] autogenerated --- cmd/kubeadm/app/apis/kubeadm/BUILD | 2 - cmd/kubeadm/app/apis/kubeadm/scheme/BUILD | 1 - cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD | 13 ----- cmd/kubeadm/app/apis/kubeadm/v1alpha2/BUILD | 61 --------------------- cmd/kubeadm/app/cmd/BUILD | 2 - 5 files changed, 79 deletions(-) delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha2/BUILD diff --git a/cmd/kubeadm/app/apis/kubeadm/BUILD b/cmd/kubeadm/app/apis/kubeadm/BUILD index 3036d93c72b..7869ddb8784 100644 --- a/cmd/kubeadm/app/apis/kubeadm/BUILD +++ b/cmd/kubeadm/app/apis/kubeadm/BUILD @@ -43,8 +43,6 @@ filegroup( ":package-srcs", "//cmd/kubeadm/app/apis/kubeadm/fuzzer:all-srcs", "//cmd/kubeadm/app/apis/kubeadm/scheme:all-srcs", - "//cmd/kubeadm/app/apis/kubeadm/v1alpha1:all-srcs", - "//cmd/kubeadm/app/apis/kubeadm/v1alpha2:all-srcs", "//cmd/kubeadm/app/apis/kubeadm/v1alpha3:all-srcs", "//cmd/kubeadm/app/apis/kubeadm/validation:all-srcs", ], diff --git a/cmd/kubeadm/app/apis/kubeadm/scheme/BUILD b/cmd/kubeadm/app/apis/kubeadm/scheme/BUILD index e374a07a343..4ccb7a02faa 100644 --- a/cmd/kubeadm/app/apis/kubeadm/scheme/BUILD +++ b/cmd/kubeadm/app/apis/kubeadm/scheme/BUILD @@ -7,7 +7,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//cmd/kubeadm/app/apis/kubeadm:go_default_library", - "//cmd/kubeadm/app/apis/kubeadm/v1alpha2:go_default_library", "//cmd/kubeadm/app/apis/kubeadm/v1alpha3:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD deleted file mode 100644 index 6df04e38cd7..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD +++ /dev/null @@ -1,13 +0,0 @@ -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/BUILD b/cmd/kubeadm/app/apis/kubeadm/v1alpha2/BUILD deleted file mode 100644 index 0458a2f0229..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha2/BUILD +++ /dev/null @@ -1,61 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "bootstraptokenstring.go", - "conversion.go", - "defaults.go", - "defaults_unix.go", - "defaults_windows.go", - "doc.go", - "register.go", - "types.go", - "zz_generated.conversion.go", - "zz_generated.deepcopy.go", - "zz_generated.defaults.go", - ], - importpath = "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha2", - visibility = ["//visibility:public"], - deps = [ - "//cmd/kubeadm/app/apis/kubeadm:go_default_library", - "//cmd/kubeadm/app/componentconfigs:go_default_library", - "//cmd/kubeadm/app/constants:go_default_library", - "//pkg/kubelet/apis/config:go_default_library", - "//pkg/kubelet/apis/config/scheme:go_default_library", - "//pkg/kubelet/apis/config/v1beta1:go_default_library", - "//pkg/proxy/apis/config:go_default_library", - "//pkg/proxy/apis/config/scheme:go_default_library", - "//pkg/proxy/apis/config/v1alpha1:go_default_library", - "//staging/src/k8s.io/api/core/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", - "//staging/src/k8s.io/client-go/tools/bootstrap/token/api:go_default_library", - "//staging/src/k8s.io/client-go/tools/bootstrap/token/util:go_default_library", - "//staging/src/k8s.io/kube-proxy/config/v1alpha1:go_default_library", - "//staging/src/k8s.io/kubelet/config/v1beta1:go_default_library", - "//vendor/k8s.io/utils/pointer:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) - -go_test( - name = "go_default_test", - srcs = ["bootstraptokenstring_test.go"], - embed = [":go_default_library"], -) diff --git a/cmd/kubeadm/app/cmd/BUILD b/cmd/kubeadm/app/cmd/BUILD index d0f731775b1..c28a079c36d 100644 --- a/cmd/kubeadm/app/cmd/BUILD +++ b/cmd/kubeadm/app/cmd/BUILD @@ -22,7 +22,6 @@ go_library( deps = [ "//cmd/kubeadm/app/apis/kubeadm:go_default_library", "//cmd/kubeadm/app/apis/kubeadm/scheme:go_default_library", - "//cmd/kubeadm/app/apis/kubeadm/v1alpha2:go_default_library", "//cmd/kubeadm/app/apis/kubeadm/v1alpha3:go_default_library", "//cmd/kubeadm/app/apis/kubeadm/validation:go_default_library", "//cmd/kubeadm/app/cmd/options:go_default_library", @@ -97,7 +96,6 @@ go_test( "//cmd/kubeadm/app/constants:go_default_library", "//cmd/kubeadm/app/features:go_default_library", "//cmd/kubeadm/app/preflight:go_default_library", - "//cmd/kubeadm/app/util/config:go_default_library", "//cmd/kubeadm/app/util/runtime:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",