From dea6f7e2a78defc516d9fd7f47133c2bd6845bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20K=C3=A4ldstr=C3=B6m?= Date: Wed, 4 Jul 2018 10:46:32 +0300 Subject: [PATCH] Remove the v1alpha1 API folder --- cmd/kubeadm/app/apis/kubeadm/BUILD | 1 - cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD | 66 ---- .../app/apis/kubeadm/v1alpha1/conversion.go | 226 ----------- .../apis/kubeadm/v1alpha1/conversion_test.go | 103 ----- .../app/apis/kubeadm/v1alpha1/defaults.go | 276 -------------- .../apis/kubeadm/v1alpha1/defaults_unix.go | 22 -- .../apis/kubeadm/v1alpha1/defaults_windows.go | 22 -- cmd/kubeadm/app/apis/kubeadm/v1alpha1/doc.go | 22 -- .../app/apis/kubeadm/v1alpha1/register.go | 66 ---- .../app/apis/kubeadm/v1alpha1/types.go | 299 --------------- .../app/apis/kubeadm/v1alpha1/upgrade.go | 98 ----- .../app/apis/kubeadm/v1alpha1/upgrade_test.go | 117 ------ .../v1alpha1/zz_generated.conversion.go | 339 ----------------- .../kubeadm/v1alpha1/zz_generated.deepcopy.go | 360 ------------------ .../kubeadm/v1alpha1/zz_generated.defaults.go | 50 --- 15 files changed, 2067 deletions(-) delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion_test.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_unix.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_windows.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/doc.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/register.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/upgrade.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/upgrade_test.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.conversion.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.deepcopy.go delete mode 100644 cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.defaults.go diff --git a/cmd/kubeadm/app/apis/kubeadm/BUILD b/cmd/kubeadm/app/apis/kubeadm/BUILD index 24806f29057..bb1716e4d74 100644 --- a/cmd/kubeadm/app/apis/kubeadm/BUILD +++ b/cmd/kubeadm/app/apis/kubeadm/BUILD @@ -42,7 +42,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/validation:all-srcs", ], diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD deleted file mode 100644 index 8a85a5a4313..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/BUILD +++ /dev/null @@ -1,66 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") - -go_library( - name = "go_default_library", - srcs = [ - "conversion.go", - "defaults.go", - "defaults_unix.go", - "defaults_windows.go", - "doc.go", - "register.go", - "types.go", - "upgrade.go", - "zz_generated.conversion.go", - "zz_generated.deepcopy.go", - "zz_generated.defaults.go", - ], - importpath = "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1", - visibility = ["//visibility:public"], - deps = [ - "//cmd/kubeadm/app/apis/kubeadm:go_default_library", - "//cmd/kubeadm/app/constants:go_default_library", - "//pkg/kubelet/apis/kubeletconfig/scheme:go_default_library", - "//pkg/kubelet/apis/kubeletconfig/v1beta1:go_default_library", - "//pkg/proxy/apis/kubeproxyconfig/scheme:go_default_library", - "//pkg/proxy/apis/kubeproxyconfig/v1alpha1:go_default_library", - "//pkg/util/pointer: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/apis/meta/v1/unstructured: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/apimachinery/pkg/runtime/serializer:go_default_library", - "//vendor/github.com/ugorji/go/codec: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 = [ - "conversion_test.go", - "upgrade_test.go", - ], - data = glob(["testdata/**"]), - embed = [":go_default_library"], - deps = [ - "//cmd/kubeadm/app/apis/kubeadm:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", - "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library", - ], -) diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion.go deleted file mode 100644 index 3bbad16e79d..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion.go +++ /dev/null @@ -1,226 +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 v1alpha1 - -import ( - "fmt" - "reflect" - "strings" - - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/conversion" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" - "k8s.io/kubernetes/cmd/kubeadm/app/constants" -) - -func addConversionFuncs(scheme *runtime.Scheme) error { - // Add non-generated conversion functions - err := scheme.AddConversionFuncs( - Convert_v1alpha1_MasterConfiguration_To_kubeadm_MasterConfiguration, - Convert_kubeadm_MasterConfiguration_To_v1alpha1_MasterConfiguration, - Convert_v1alpha1_NodeConfiguration_To_kubeadm_NodeConfiguration, - Convert_kubeadm_NodeConfiguration_To_v1alpha1_NodeConfiguration, - Convert_v1alpha1_Etcd_To_kubeadm_Etcd, - Convert_kubeadm_Etcd_To_v1alpha1_Etcd, - ) - if err != nil { - return err - } - - return nil -} - -// Upgrades below - -func Convert_v1alpha1_MasterConfiguration_To_kubeadm_MasterConfiguration(in *MasterConfiguration, out *kubeadm.MasterConfiguration, s conversion.Scope) error { - if err := autoConvert_v1alpha1_MasterConfiguration_To_kubeadm_MasterConfiguration(in, out, s); err != nil { - return err - } - - UpgradeCloudProvider(in, out) - UpgradeAuthorizationModes(in, out) - UpgradeNodeRegistrationOptionsForMaster(in, out) - if err := UpgradeBootstrapTokens(in, out); err != nil { - return err - } - // We don't support migrating information from the .PrivilegedPods field which was removed in v1alpha2 - // We don't support migrating information from the .ImagePullPolicy field which was removed in v1alpha2 - - return nil -} - -func Convert_v1alpha1_NodeConfiguration_To_kubeadm_NodeConfiguration(in *NodeConfiguration, out *kubeadm.NodeConfiguration, s conversion.Scope) error { - if err := autoConvert_v1alpha1_NodeConfiguration_To_kubeadm_NodeConfiguration(in, out, s); err != nil { - return err - } - - // .NodeName has moved to .NodeRegistration.Name - out.NodeRegistration.Name = in.NodeName - // .CRISocket has moved to .NodeRegistration.CRISocket - out.NodeRegistration.CRISocket = in.CRISocket - - return nil -} - -func Convert_v1alpha1_Etcd_To_kubeadm_Etcd(in *Etcd, out *kubeadm.Etcd, s conversion.Scope) error { - if err := autoConvert_v1alpha1_Etcd_To_kubeadm_Etcd(in, out, s); err != nil { - return err - } - - // The .Etcd schema changed between v1alpha1 and v1alpha2 API types. The change was to basically only split up the fields into two sub-structs, which can be seen here - if len(in.Endpoints) != 0 { - out.External = &kubeadm.ExternalEtcd{ - Endpoints: in.Endpoints, - CAFile: in.CAFile, - CertFile: in.CertFile, - KeyFile: in.KeyFile, - } - } else { - out.Local = &kubeadm.LocalEtcd{ - Image: in.Image, - DataDir: in.DataDir, - ExtraArgs: in.ExtraArgs, - ServerCertSANs: in.ServerCertSANs, - PeerCertSANs: in.PeerCertSANs, - } - } - - // No need to transfer information about .Etcd.Selfhosted to v1alpha2 - return nil -} - -// UpgradeCloudProvider handles the removal of .CloudProvider as smoothly as possible -func UpgradeCloudProvider(in *MasterConfiguration, out *kubeadm.MasterConfiguration) { - if len(in.CloudProvider) != 0 { - if out.APIServerExtraArgs == nil { - out.APIServerExtraArgs = map[string]string{} - } - if out.ControllerManagerExtraArgs == nil { - out.ControllerManagerExtraArgs = map[string]string{} - } - if out.NodeRegistration.KubeletExtraArgs == nil { - out.NodeRegistration.KubeletExtraArgs = map[string]string{} - } - - out.APIServerExtraArgs["cloud-provider"] = in.CloudProvider - out.ControllerManagerExtraArgs["cloud-provider"] = in.CloudProvider - out.NodeRegistration.KubeletExtraArgs["cloud-provider"] = in.CloudProvider - } -} - -func UpgradeAuthorizationModes(in *MasterConfiguration, out *kubeadm.MasterConfiguration) { - // If .AuthorizationModes was set to something else than the default, preserve the information via extraargs - if !reflect.DeepEqual(in.AuthorizationModes, strings.Split(DefaultAuthorizationModes, ",")) { - - if out.APIServerExtraArgs == nil { - out.APIServerExtraArgs = map[string]string{} - } - out.APIServerExtraArgs["authorization-mode"] = strings.Join(in.AuthorizationModes, ",") - } -} - -func UpgradeNodeRegistrationOptionsForMaster(in *MasterConfiguration, out *kubeadm.MasterConfiguration) { - // .NodeName has moved to .NodeRegistration.Name - out.NodeRegistration.Name = in.NodeName - - // .CRISocket has moved to .NodeRegistration.CRISocket - out.NodeRegistration.CRISocket = in.CRISocket - - // Transfer the information from .NoTaintMaster to the new layout - if in.NoTaintMaster { - out.NodeRegistration.Taints = []v1.Taint{} - } else { - out.NodeRegistration.Taints = []v1.Taint{constants.MasterTaint} - } -} - -// UpgradeBootstrapTokens should create at least one empty bootstrap token in the out config. -func UpgradeBootstrapTokens(in *MasterConfiguration, out *kubeadm.MasterConfiguration) error { - bts, err := kubeadm.NewBootstrapTokenString(in.Token) - // Ignore the error if the incoming token was empty. - if err != nil && in.Token != "" { - return fmt.Errorf("can't parse .Token, and hence can't convert v1alpha1 API to a newer version: %v", err) - } - - out.BootstrapTokens = []kubeadm.BootstrapToken{ - { - Token: bts, - TTL: in.TokenTTL, - Usages: in.TokenUsages, - Groups: in.TokenGroups, - }, - } - return nil -} - -// Downgrades below - -// This downgrade path IS NOT SUPPORTED. This is just here for roundtripping purposes at the moment. -func Convert_kubeadm_MasterConfiguration_To_v1alpha1_MasterConfiguration(in *kubeadm.MasterConfiguration, out *MasterConfiguration, s conversion.Scope) error { - if err := autoConvert_kubeadm_MasterConfiguration_To_v1alpha1_MasterConfiguration(in, out, s); err != nil { - return err - } - - // Converting from newer API version to an older API version isn't supported. This is here only for the roundtrip tests meanwhile. - out.NodeName = in.NodeRegistration.Name - out.CRISocket = in.NodeRegistration.CRISocket - out.NoTaintMaster = in.NodeRegistration.Taints != nil && len(in.NodeRegistration.Taints) == 0 - - if len(in.BootstrapTokens) > 0 { - out.Token = in.BootstrapTokens[0].Token.String() - out.TokenTTL = in.BootstrapTokens[0].TTL - out.TokenUsages = in.BootstrapTokens[0].Usages - out.TokenGroups = in.BootstrapTokens[0].Groups - } - - return nil -} - -// This downgrade path IS NOT SUPPORTED. This is just here for roundtripping purposes at the moment. -func Convert_kubeadm_NodeConfiguration_To_v1alpha1_NodeConfiguration(in *kubeadm.NodeConfiguration, out *NodeConfiguration, s conversion.Scope) error { - if err := autoConvert_kubeadm_NodeConfiguration_To_v1alpha1_NodeConfiguration(in, out, s); err != nil { - return err - } - - // Converting from newer API version to an older API version isn't supported. This is here only for the roundtrip tests meanwhile. - out.NodeName = in.NodeRegistration.Name - out.CRISocket = in.NodeRegistration.CRISocket - return nil -} - -// This downgrade path IS NOT SUPPORTED. This is just here for roundtripping purposes at the moment. -func Convert_kubeadm_Etcd_To_v1alpha1_Etcd(in *kubeadm.Etcd, out *Etcd, s conversion.Scope) error { - if err := autoConvert_kubeadm_Etcd_To_v1alpha1_Etcd(in, out, s); err != nil { - return err - } - - if in.External != nil { - out.Endpoints = in.External.Endpoints - out.CAFile = in.External.CAFile - out.CertFile = in.External.CertFile - out.KeyFile = in.External.KeyFile - } else { - out.Image = in.Local.Image - out.DataDir = in.Local.DataDir - out.ExtraArgs = in.Local.ExtraArgs - out.ServerCertSANs = in.Local.ServerCertSANs - out.PeerCertSANs = in.Local.PeerCertSANs - } - - return nil -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion_test.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion_test.go deleted file mode 100644 index 52fcc3db807..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/conversion_test.go +++ /dev/null @@ -1,103 +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 v1alpha1_test - -import ( - "reflect" - "testing" - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" - "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1" -) - -func TestUpgradeBootstrapTokens(t *testing.T) { - testcases := []struct { - name string - in *v1alpha1.MasterConfiguration - expectedOut *kubeadm.MasterConfiguration - expectError bool - }{ - { - name: "empty configs should create at least one token", - in: &v1alpha1.MasterConfiguration{}, - expectedOut: &kubeadm.MasterConfiguration{ - BootstrapTokens: []kubeadm.BootstrapToken{ - { - Token: nil, - }, - }, - }, - expectError: false, - }, - { - name: "fail at parsing incoming token", - in: &v1alpha1.MasterConfiguration{ - Token: "some fake token", - }, - expectError: true, - }, - { - name: "input has values", - in: &v1alpha1.MasterConfiguration{ - Token: "abcdef.abcdefghijklmnop", - TokenTTL: &metav1.Duration{ - Duration: time.Duration(10 * time.Hour), - }, - TokenUsages: []string{"action"}, - TokenGroups: []string{"group", "group2"}, - }, - expectedOut: &kubeadm.MasterConfiguration{ - BootstrapTokens: []kubeadm.BootstrapToken{ - { - Token: &kubeadm.BootstrapTokenString{ - ID: "abcdef", - Secret: "abcdefghijklmnop", - }, - TTL: &metav1.Duration{ - Duration: time.Duration(10 * time.Hour), - }, - Usages: []string{"action"}, - Groups: []string{"group", "group2"}, - }, - }, - }, - expectError: false, - }, - } - - for _, tc := range testcases { - t.Run(tc.name, func(t *testing.T) { - out := &kubeadm.MasterConfiguration{} - err := v1alpha1.UpgradeBootstrapTokens(tc.in, out) - - if tc.expectError { - if err == nil { - t.Fatal("expected an error but did not get one.") - } - // do not continue if we got an expected error - return - } - - if !reflect.DeepEqual(out.BootstrapTokens, tc.expectedOut.BootstrapTokens) { - t.Fatalf("\nexpected: %v\ngot: %v", tc.expectedOut.BootstrapTokens, out.BootstrapTokens) - } - }) - } - -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go deleted file mode 100644 index bb30de78c39..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults.go +++ /dev/null @@ -1,276 +0,0 @@ -/* -Copyright 2016 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 v1alpha1 - -import ( - "net/url" - "strings" - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/kubernetes/cmd/kubeadm/app/constants" - kubeletscheme "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/scheme" - kubeletconfigv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1" - kubeproxyscheme "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/scheme" - kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1" - utilpointer "k8s.io/kubernetes/pkg/util/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.11" - // DefaultAPIBindPort defines default API port - DefaultAPIBindPort = 6443 - // DefaultAuthorizationModes defines default authorization modes - DefaultAuthorizationModes = "Node,RBAC" - // 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" - // DefaultCRISocket defines the default cri socket - DefaultCRISocket = "/var/run/dockershim.sock" - // 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" - // DefaultEtcdClusterSize defines the default cluster size when using the etcd-operator - DefaultEtcdClusterSize = 3 - // DefaultEtcdOperatorVersion defines the default version of the etcd-operator to use - DefaultEtcdOperatorVersion = "v0.6.0" - // DefaultEtcdCertDir represents the directory where PKI assets are stored for self-hosted etcd - DefaultEtcdCertDir = "/etc/kubernetes/pki/etcd" - // DefaultEtcdClusterServiceName is the default name of the service backing the etcd cluster - DefaultEtcdClusterServiceName = "etcd-cluster" - // 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 NodeConfiguration) - 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_MasterConfiguration assigns default values to Master node -func SetDefaults_MasterConfiguration(obj *MasterConfiguration) { - 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 len(obj.AuthorizationModes) == 0 { - obj.AuthorizationModes = strings.Split(DefaultAuthorizationModes, ",") - } - - if obj.CertificatesDir == "" { - obj.CertificatesDir = DefaultCertificatesDir - } - - if obj.TokenTTL == nil { - obj.TokenTTL = &metav1.Duration{ - Duration: constants.DefaultTokenDuration, - } - } - - if obj.CRISocket == "" { - obj.CRISocket = DefaultCRISocket - } - - if len(obj.TokenUsages) == 0 { - obj.TokenUsages = constants.DefaultTokenUsages - } - - if len(obj.TokenGroups) == 0 { - obj.TokenGroups = constants.DefaultTokenGroups - } - - if obj.ImageRepository == "" { - obj.ImageRepository = DefaultImageRepository - } - - if obj.Etcd.DataDir == "" { - obj.Etcd.DataDir = DefaultEtcdDataDir - } - - if obj.ClusterName == "" { - obj.ClusterName = DefaultClusterName - } - - SetDefaultsEtcdSelfHosted(obj) - SetDefaults_KubeletConfiguration(obj) - SetDefaults_ProxyConfiguration(obj) - SetDefaults_AuditPolicyConfiguration(obj) -} - -// SetDefaults_ProxyConfiguration assigns default values for the Proxy -func SetDefaults_ProxyConfiguration(obj *MasterConfiguration) { - 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.KubeConfigFile == "" { - obj.KubeProxy.Config.ClientConnection.KubeConfigFile = KubeproxyKubeConfigFileName - } - - kubeproxyscheme.Scheme.Default(obj.KubeProxy.Config) -} - -// SetDefaults_NodeConfiguration assigns default values to a regular node -func SetDefaults_NodeConfiguration(obj *NodeConfiguration) { - 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 - } - if obj.CRISocket == "" { - obj.CRISocket = DefaultCRISocket - } - // 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 - } -} - -// SetDefaultsEtcdSelfHosted sets defaults for self-hosted etcd if used -func SetDefaultsEtcdSelfHosted(obj *MasterConfiguration) { - if obj.Etcd.SelfHosted != nil { - if obj.Etcd.SelfHosted.ClusterServiceName == "" { - obj.Etcd.SelfHosted.ClusterServiceName = DefaultEtcdClusterServiceName - } - - if obj.Etcd.SelfHosted.EtcdVersion == "" { - obj.Etcd.SelfHosted.EtcdVersion = constants.DefaultEtcdVersion - } - - if obj.Etcd.SelfHosted.OperatorVersion == "" { - obj.Etcd.SelfHosted.OperatorVersion = DefaultEtcdOperatorVersion - } - - if obj.Etcd.SelfHosted.CertificatesDir == "" { - obj.Etcd.SelfHosted.CertificatesDir = DefaultEtcdCertDir - } - } -} - -// SetDefaults_KubeletConfiguration assigns default values to kubelet -func SetDefaults_KubeletConfiguration(obj *MasterConfiguration) { - 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(10248) - - scheme, _, _ := kubeletscheme.NewSchemeAndCodecs() - if scheme != nil { - scheme.Default(obj.KubeletConfiguration.BaseConfig) - } -} - -// SetDefaults_AuditPolicyConfiguration sets default values for the AuditPolicyConfiguration -func SetDefaults_AuditPolicyConfiguration(obj *MasterConfiguration) { - if obj.AuditPolicyConfiguration.LogDir == "" { - obj.AuditPolicyConfiguration.LogDir = constants.StaticPodAuditPolicyLogDir - } - if obj.AuditPolicyConfiguration.LogMaxAge == nil { - obj.AuditPolicyConfiguration.LogMaxAge = &DefaultAuditPolicyLogMaxAge - } -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_unix.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_unix.go deleted file mode 100644 index 5de42850626..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_unix.go +++ /dev/null @@ -1,22 +0,0 @@ -// +build !windows - -/* -Copyright 2017 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 v1alpha1 - -// DefaultCACertPath defines default location of CA certificate on Linux -const DefaultCACertPath = "/etc/kubernetes/pki/ca.crt" diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_windows.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_windows.go deleted file mode 100644 index d073613930d..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/defaults_windows.go +++ /dev/null @@ -1,22 +0,0 @@ -// +build windows - -/* -Copyright 2017 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 v1alpha1 - -// DefaultCACertPath defines default location of CA certificate on Windows -const DefaultCACertPath = "C:/etc/kubernetes/pki/ca.crt" diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/doc.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/doc.go deleted file mode 100644 index 286e198797a..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/doc.go +++ /dev/null @@ -1,22 +0,0 @@ -/* -Copyright 2016 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 v1alpha1 is the package that contains the libraries that drive the kubeadm binary. -// +k8s:defaulter-gen=TypeMeta -// +groupName=kubeadm.k8s.io -// +k8s:deepcopy-gen=package -// +k8s:conversion-gen=k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm -package v1alpha1 // import "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha1" diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/register.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/register.go deleted file mode 100644 index abb323ac5ef..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/register.go +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright 2016 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 v1alpha1 - -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: "v1alpha1"} - -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, addConversionFuncs) -} - -// 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.AddKnownTypes(SchemeGroupVersion, - &MasterConfiguration{}, - &NodeConfiguration{}, - ) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go deleted file mode 100644 index c5f8ab9e21f..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/types.go +++ /dev/null @@ -1,299 +0,0 @@ -/* -Copyright 2016 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 v1alpha1 - -import ( - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - kubeletconfigv1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1" - kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// MasterConfiguration contains a list of elements which make up master's -// configuration object. -type MasterConfiguration struct { - metav1.TypeMeta `json:",inline"` - - // 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"` - // CloudProvider is the name of the cloud provider. - CloudProvider string `json:"cloudProvider"` - // NodeName is the name of the node that will host the k8s control plane. - // Defaults to the hostname if not provided. - NodeName string `json:"nodeName"` - // AuthorizationModes is a set of authorization modes used inside the cluster. - // If not specified, defaults to Node and RBAC, meaning both the node - // authorizer and RBAC are enabled. - AuthorizationModes []string `json:"authorizationModes,omitempty"` - // NoTaintMaster will, if set, suppress the tainting of the - // master node allowing workloads to be run on it (e.g. in - // single node configurations). - NoTaintMaster bool `json:"noTaintMaster,omitempty"` - - // Mark the controller and api server pods as privileged as some cloud - // controllers like openstack need escalated privileges under some conditions - // example - loading a config drive to fetch node information - PrivilegedPods bool `json:"privilegedPods"` - - // Token is used for establishing bidirectional trust between nodes and masters. - // Used for joining nodes in the cluster. - Token string `json:"token"` - // TokenTTL defines the ttl for Token. Defaults to 24h. - TokenTTL *metav1.Duration `json:"tokenTTL,omitempty"` - // TokenUsages describes the ways in which this token can be used. - TokenUsages []string `json:"tokenUsages,omitempty"` - // Extra groups that this token will authenticate as when used for authentication - TokenGroups []string `json:"tokenGroups,omitempty"` - - // CRISocket is used to retrieve container runtime info. - CRISocket string `json:"criSocket,omitempty"` - - // 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"` - // ImagePullPolicy that control plane images. Can be Always, IfNotPresent or Never. - ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"` - // 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"` -} - -// TokenDiscovery contains elements needed for token discovery. -type TokenDiscovery struct { - // ID is the first part of a bootstrap token. Considered public information. - // It is used when referring to a token without leaking the secret part. - ID string `json:"id"` - // Secret is the second part of a bootstrap token. Should only be shared - // with trusted parties. - Secret string `json:"secret"` - // TODO: Seems unused. Remove? - // Addresses []string `json:"addresses"` -} - -// 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"` -} - -// Etcd contains elements describing Etcd configuration. -type Etcd 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"` - // 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"` - // 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"` - // SelfHosted holds configuration for self-hosting etcd. - SelfHosted *SelfHostedEtcd `json:"selfHosted,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"` -} - -// SelfHostedEtcd describes options required to configure self-hosted etcd. -type SelfHostedEtcd struct { - // CertificatesDir represents the directory where all etcd TLS assets are stored. - // Defaults to "/etc/kubernetes/pki/etcd". - CertificatesDir string `json:"certificatesDir"` - // ClusterServiceName is the name of the service that load balances the etcd cluster. - ClusterServiceName string `json:"clusterServiceName"` - // EtcdVersion is the version of etcd running in the cluster. - EtcdVersion string `json:"etcdVersion"` - // OperatorVersion is the version of the etcd-operator to use. - OperatorVersion string `json:"operatorVersion"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// NodeConfiguration contains elements describing a particular node. -// TODO: This struct should be replaced by dynamic kubelet configuration. -type NodeConfiguration struct { - metav1.TypeMeta `json:",inline"` - - // 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"` - // NodeName is the name of the node to join the cluster. Defaults - // to the name of the host. - NodeName string `json:"nodeName"` - // 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"` - // CRISocket is used to retrieve container runtime info. - CRISocket string `json:"criSocket,omitempty"` - // 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"` - - // 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/v1alpha1/upgrade.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/upgrade.go deleted file mode 100644 index 7c3dd133feb..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/upgrade.go +++ /dev/null @@ -1,98 +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 v1alpha1 - -import ( - "bytes" - "fmt" - "reflect" - "strconv" - "strings" - - "github.com/ugorji/go/codec" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" -) - -type configMutationFunc func(map[string]interface{}) error - -// These migrations are a stop-gap until we get a properly-versioned configuration file for MasterConfiguration. -// https://github.com/kubernetes/kubeadm/issues/750 -var migrations = map[string][]configMutationFunc{ - "MasterConfiguration": { - proxyFeatureListToMap, - }, -} - -// Migrate takes a map representing a config file and an object to decode into. -// The map is transformed into a format suitable for encoding into the supplied object, then serialised and decoded. -func Migrate(in map[string]interface{}, obj runtime.Object, codecs serializer.CodecFactory) error { - kind := reflect.TypeOf(obj).Elem().Name() - migrationsForKind := migrations[kind] - - for _, m := range migrationsForKind { - err := m(in) - if err != nil { - return err - } - } - - // Use codec instead of encoding/json to handle map[interface{}]interface{} - handle := &codec.JsonHandle{} - buf := new(bytes.Buffer) - if err := codec.NewEncoder(buf, handle).Encode(in); err != nil { - return fmt.Errorf("couldn't json encode object: %v", err) - } - - return runtime.DecodeInto(codecs.UniversalDecoder(), buf.Bytes(), obj) -} - -func proxyFeatureListToMap(m map[string]interface{}) error { - featureGatePath := []string{"kubeProxy", "config", "featureGates"} - - // If featureGatePath is already a map, we don't need to do anything. - _, _, err := unstructured.NestedMap(m, featureGatePath...) - if err == nil { - return nil - } - - gates, _, err := unstructured.NestedString(m, featureGatePath...) - if err != nil { - return fmt.Errorf("couldn't get featureGates: %v", err) - } - - gateMap := make(map[string]interface{}) - for _, gate := range strings.Split(gates, ",") { - if gate == "" { - continue - } - parts := strings.SplitN(gate, "=", 2) - if len(parts) != 2 { - return fmt.Errorf("unparsable kubeproxy feature gate %q", gate) - } - val, err := strconv.ParseBool(parts[1]) - if err != nil { - return fmt.Errorf("unparsable kubeproxy feature gate %q: %v", gate, err) - } - gateMap[parts[0]] = val - } - - unstructured.SetNestedMap(m, gateMap, featureGatePath...) - return nil -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/upgrade_test.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/upgrade_test.go deleted file mode 100644 index edb451decf2..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/upgrade_test.go +++ /dev/null @@ -1,117 +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 v1alpha1 - -import ( - "testing" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" -) - -func TestProxyFeatureListToMap(t *testing.T) { - - cases := []struct { - name string - featureGates interface{} - expected map[string]interface{} - shouldError bool - }{ - { - name: "multiple features", - featureGates: "feature1=true,feature2=false", - expected: map[string]interface{}{ - "feature1": true, - "feature2": false, - }, - }, - { - name: "single feature", - featureGates: "feature1=true", - expected: map[string]interface{}{ - "feature1": true, - }, - }, - { - name: "already a map", - featureGates: map[string]interface{}{ - "feature1": true, - }, - expected: map[string]interface{}{ - "feature1": true, - }, - }, - { - name: "single feature", - featureGates: "", - expected: map[string]interface{}{}, - }, - { - name: "malformed string", - featureGates: "test,", - shouldError: true, - }, - } - - for _, testCase := range cases { - t.Run(testCase.name, func(t *testing.T) { - - cfg := map[string]interface{}{ - "kubeProxy": map[string]interface{}{ - "config": map[string]interface{}{ - "featureGates": testCase.featureGates, - }, - }, - } - - err := proxyFeatureListToMap(cfg) - if testCase.shouldError { - if err == nil { - t.Error("expected error, got nil") - } - return - } - - if err != nil { - t.Errorf("unexpected error: %v", err) - } - - gates, ok, err := unstructured.NestedMap(cfg, "kubeProxy", "config", "featureGates") - if !ok { - t.Errorf("missing map keys in nested map") - } - if err != nil { - t.Errorf("unexpected error in map: %v", err) - } - - if len(testCase.expected) != len(gates) { - t.Errorf("expected feature gate size %d, got %d", len(testCase.expected), len(gates)) - } - - for k, v := range testCase.expected { - gateVal, ok := gates[k] - if !ok { - t.Errorf("featureGates missing key %q", k) - continue - } - - if v != gateVal { - t.Errorf("expected value %v, got %v", v, gateVal) - } - } - }) - } -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.conversion.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.conversion.go deleted file mode 100644 index 47786ba8061..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.conversion.go +++ /dev/null @@ -1,339 +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 v1alpha1 - -import ( - unsafe "unsafe" - - v1 "k8s.io/api/core/v1" - metav1 "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" - v1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1" - kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1" -) - -func init() { - localSchemeBuilder.Register(RegisterConversions) -} - -// RegisterConversions adds conversion functions to the given scheme. -// Public to allow building arbitrary schemes. -func RegisterConversions(scheme *runtime.Scheme) error { - return scheme.AddGeneratedConversionFuncs( - Convert_v1alpha1_API_To_kubeadm_API, - Convert_kubeadm_API_To_v1alpha1_API, - Convert_v1alpha1_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration, - Convert_kubeadm_AuditPolicyConfiguration_To_v1alpha1_AuditPolicyConfiguration, - Convert_v1alpha1_Etcd_To_kubeadm_Etcd, - Convert_kubeadm_Etcd_To_v1alpha1_Etcd, - Convert_v1alpha1_HostPathMount_To_kubeadm_HostPathMount, - Convert_kubeadm_HostPathMount_To_v1alpha1_HostPathMount, - Convert_v1alpha1_KubeProxy_To_kubeadm_KubeProxy, - Convert_kubeadm_KubeProxy_To_v1alpha1_KubeProxy, - Convert_v1alpha1_KubeletConfiguration_To_kubeadm_KubeletConfiguration, - Convert_kubeadm_KubeletConfiguration_To_v1alpha1_KubeletConfiguration, - Convert_v1alpha1_MasterConfiguration_To_kubeadm_MasterConfiguration, - Convert_kubeadm_MasterConfiguration_To_v1alpha1_MasterConfiguration, - Convert_v1alpha1_Networking_To_kubeadm_Networking, - Convert_kubeadm_Networking_To_v1alpha1_Networking, - Convert_v1alpha1_NodeConfiguration_To_kubeadm_NodeConfiguration, - Convert_kubeadm_NodeConfiguration_To_v1alpha1_NodeConfiguration, - ) -} - -func autoConvert_v1alpha1_API_To_kubeadm_API(in *API, out *kubeadm.API, s conversion.Scope) error { - out.AdvertiseAddress = in.AdvertiseAddress - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - out.BindPort = in.BindPort - return nil -} - -// Convert_v1alpha1_API_To_kubeadm_API is an autogenerated conversion function. -func Convert_v1alpha1_API_To_kubeadm_API(in *API, out *kubeadm.API, s conversion.Scope) error { - return autoConvert_v1alpha1_API_To_kubeadm_API(in, out, s) -} - -func autoConvert_kubeadm_API_To_v1alpha1_API(in *kubeadm.API, out *API, s conversion.Scope) error { - out.AdvertiseAddress = in.AdvertiseAddress - out.ControlPlaneEndpoint = in.ControlPlaneEndpoint - out.BindPort = in.BindPort - return nil -} - -// Convert_kubeadm_API_To_v1alpha1_API is an autogenerated conversion function. -func Convert_kubeadm_API_To_v1alpha1_API(in *kubeadm.API, out *API, s conversion.Scope) error { - return autoConvert_kubeadm_API_To_v1alpha1_API(in, out, s) -} - -func autoConvert_v1alpha1_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_v1alpha1_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration is an autogenerated conversion function. -func Convert_v1alpha1_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(in *AuditPolicyConfiguration, out *kubeadm.AuditPolicyConfiguration, s conversion.Scope) error { - return autoConvert_v1alpha1_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(in, out, s) -} - -func autoConvert_kubeadm_AuditPolicyConfiguration_To_v1alpha1_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_v1alpha1_AuditPolicyConfiguration is an autogenerated conversion function. -func Convert_kubeadm_AuditPolicyConfiguration_To_v1alpha1_AuditPolicyConfiguration(in *kubeadm.AuditPolicyConfiguration, out *AuditPolicyConfiguration, s conversion.Scope) error { - return autoConvert_kubeadm_AuditPolicyConfiguration_To_v1alpha1_AuditPolicyConfiguration(in, out, s) -} - -func autoConvert_v1alpha1_Etcd_To_kubeadm_Etcd(in *Etcd, out *kubeadm.Etcd, s conversion.Scope) error { - // WARNING: in.Endpoints requires manual conversion: does not exist in peer-type - // WARNING: in.CAFile requires manual conversion: does not exist in peer-type - // WARNING: in.CertFile requires manual conversion: does not exist in peer-type - // WARNING: in.KeyFile requires manual conversion: does not exist in peer-type - // WARNING: in.DataDir requires manual conversion: does not exist in peer-type - // WARNING: in.ExtraArgs requires manual conversion: does not exist in peer-type - // WARNING: in.Image requires manual conversion: does not exist in peer-type - // WARNING: in.SelfHosted requires manual conversion: does not exist in peer-type - // WARNING: in.ServerCertSANs requires manual conversion: does not exist in peer-type - // WARNING: in.PeerCertSANs requires manual conversion: does not exist in peer-type - return nil -} - -func autoConvert_kubeadm_Etcd_To_v1alpha1_Etcd(in *kubeadm.Etcd, out *Etcd, s conversion.Scope) error { - // WARNING: in.Local requires manual conversion: does not exist in peer-type - // WARNING: in.External requires manual conversion: does not exist in peer-type - return nil -} - -func autoConvert_v1alpha1_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 = v1.HostPathType(in.PathType) - return nil -} - -// Convert_v1alpha1_HostPathMount_To_kubeadm_HostPathMount is an autogenerated conversion function. -func Convert_v1alpha1_HostPathMount_To_kubeadm_HostPathMount(in *HostPathMount, out *kubeadm.HostPathMount, s conversion.Scope) error { - return autoConvert_v1alpha1_HostPathMount_To_kubeadm_HostPathMount(in, out, s) -} - -func autoConvert_kubeadm_HostPathMount_To_v1alpha1_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 = v1.HostPathType(in.PathType) - return nil -} - -// Convert_kubeadm_HostPathMount_To_v1alpha1_HostPathMount is an autogenerated conversion function. -func Convert_kubeadm_HostPathMount_To_v1alpha1_HostPathMount(in *kubeadm.HostPathMount, out *HostPathMount, s conversion.Scope) error { - return autoConvert_kubeadm_HostPathMount_To_v1alpha1_HostPathMount(in, out, s) -} - -func autoConvert_v1alpha1_KubeProxy_To_kubeadm_KubeProxy(in *KubeProxy, out *kubeadm.KubeProxy, s conversion.Scope) error { - out.Config = (*kubeproxyconfigv1alpha1.KubeProxyConfiguration)(unsafe.Pointer(in.Config)) - return nil -} - -// Convert_v1alpha1_KubeProxy_To_kubeadm_KubeProxy is an autogenerated conversion function. -func Convert_v1alpha1_KubeProxy_To_kubeadm_KubeProxy(in *KubeProxy, out *kubeadm.KubeProxy, s conversion.Scope) error { - return autoConvert_v1alpha1_KubeProxy_To_kubeadm_KubeProxy(in, out, s) -} - -func autoConvert_kubeadm_KubeProxy_To_v1alpha1_KubeProxy(in *kubeadm.KubeProxy, out *KubeProxy, s conversion.Scope) error { - out.Config = (*kubeproxyconfigv1alpha1.KubeProxyConfiguration)(unsafe.Pointer(in.Config)) - return nil -} - -// Convert_kubeadm_KubeProxy_To_v1alpha1_KubeProxy is an autogenerated conversion function. -func Convert_kubeadm_KubeProxy_To_v1alpha1_KubeProxy(in *kubeadm.KubeProxy, out *KubeProxy, s conversion.Scope) error { - return autoConvert_kubeadm_KubeProxy_To_v1alpha1_KubeProxy(in, out, s) -} - -func autoConvert_v1alpha1_KubeletConfiguration_To_kubeadm_KubeletConfiguration(in *KubeletConfiguration, out *kubeadm.KubeletConfiguration, s conversion.Scope) error { - out.BaseConfig = (*v1beta1.KubeletConfiguration)(unsafe.Pointer(in.BaseConfig)) - return nil -} - -// Convert_v1alpha1_KubeletConfiguration_To_kubeadm_KubeletConfiguration is an autogenerated conversion function. -func Convert_v1alpha1_KubeletConfiguration_To_kubeadm_KubeletConfiguration(in *KubeletConfiguration, out *kubeadm.KubeletConfiguration, s conversion.Scope) error { - return autoConvert_v1alpha1_KubeletConfiguration_To_kubeadm_KubeletConfiguration(in, out, s) -} - -func autoConvert_kubeadm_KubeletConfiguration_To_v1alpha1_KubeletConfiguration(in *kubeadm.KubeletConfiguration, out *KubeletConfiguration, s conversion.Scope) error { - out.BaseConfig = (*v1beta1.KubeletConfiguration)(unsafe.Pointer(in.BaseConfig)) - return nil -} - -// Convert_kubeadm_KubeletConfiguration_To_v1alpha1_KubeletConfiguration is an autogenerated conversion function. -func Convert_kubeadm_KubeletConfiguration_To_v1alpha1_KubeletConfiguration(in *kubeadm.KubeletConfiguration, out *KubeletConfiguration, s conversion.Scope) error { - return autoConvert_kubeadm_KubeletConfiguration_To_v1alpha1_KubeletConfiguration(in, out, s) -} - -func autoConvert_v1alpha1_MasterConfiguration_To_kubeadm_MasterConfiguration(in *MasterConfiguration, out *kubeadm.MasterConfiguration, s conversion.Scope) error { - if err := Convert_v1alpha1_API_To_kubeadm_API(&in.API, &out.API, s); err != nil { - return err - } - if err := Convert_v1alpha1_KubeProxy_To_kubeadm_KubeProxy(&in.KubeProxy, &out.KubeProxy, s); err != nil { - return err - } - if err := Convert_v1alpha1_Etcd_To_kubeadm_Etcd(&in.Etcd, &out.Etcd, s); err != nil { - return err - } - if err := Convert_v1alpha1_KubeletConfiguration_To_kubeadm_KubeletConfiguration(&in.KubeletConfiguration, &out.KubeletConfiguration, s); err != nil { - return err - } - if err := Convert_v1alpha1_Networking_To_kubeadm_Networking(&in.Networking, &out.Networking, s); err != nil { - return err - } - out.KubernetesVersion = in.KubernetesVersion - // WARNING: in.CloudProvider requires manual conversion: does not exist in peer-type - // WARNING: in.NodeName requires manual conversion: does not exist in peer-type - // WARNING: in.AuthorizationModes requires manual conversion: does not exist in peer-type - // WARNING: in.NoTaintMaster requires manual conversion: does not exist in peer-type - // WARNING: in.PrivilegedPods requires manual conversion: does not exist in peer-type - // WARNING: in.Token requires manual conversion: does not exist in peer-type - // WARNING: in.TokenTTL requires manual conversion: does not exist in peer-type - // WARNING: in.TokenUsages requires manual conversion: does not exist in peer-type - // WARNING: in.TokenGroups requires manual conversion: does not exist in peer-type - // WARNING: in.CRISocket requires manual conversion: does not exist in peer-type - 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 - // WARNING: in.ImagePullPolicy requires manual conversion: does not exist in peer-type - out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage - if err := Convert_v1alpha1_AuditPolicyConfiguration_To_kubeadm_AuditPolicyConfiguration(&in.AuditPolicyConfiguration, &out.AuditPolicyConfiguration, s); err != nil { - return err - } - out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - out.ClusterName = in.ClusterName - return nil -} - -func autoConvert_kubeadm_MasterConfiguration_To_v1alpha1_MasterConfiguration(in *kubeadm.MasterConfiguration, out *MasterConfiguration, s conversion.Scope) error { - // WARNING: in.BootstrapTokens requires manual conversion: does not exist in peer-type - // WARNING: in.NodeRegistration requires manual conversion: does not exist in peer-type - if err := Convert_kubeadm_API_To_v1alpha1_API(&in.API, &out.API, s); err != nil { - return err - } - if err := Convert_kubeadm_KubeProxy_To_v1alpha1_KubeProxy(&in.KubeProxy, &out.KubeProxy, s); err != nil { - return err - } - if err := Convert_kubeadm_Etcd_To_v1alpha1_Etcd(&in.Etcd, &out.Etcd, s); err != nil { - return err - } - if err := Convert_kubeadm_KubeletConfiguration_To_v1alpha1_KubeletConfiguration(&in.KubeletConfiguration, &out.KubeletConfiguration, s); err != nil { - return err - } - if err := Convert_kubeadm_Networking_To_v1alpha1_Networking(&in.Networking, &out.Networking, s); err != nil { - return err - } - out.KubernetesVersion = in.KubernetesVersion - 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 - // INFO: in.CIImageRepository opted out of conversion generation - out.UnifiedControlPlaneImage = in.UnifiedControlPlaneImage - if err := Convert_kubeadm_AuditPolicyConfiguration_To_v1alpha1_AuditPolicyConfiguration(&in.AuditPolicyConfiguration, &out.AuditPolicyConfiguration, s); err != nil { - return err - } - out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - out.ClusterName = in.ClusterName - return nil -} - -func autoConvert_v1alpha1_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_v1alpha1_Networking_To_kubeadm_Networking is an autogenerated conversion function. -func Convert_v1alpha1_Networking_To_kubeadm_Networking(in *Networking, out *kubeadm.Networking, s conversion.Scope) error { - return autoConvert_v1alpha1_Networking_To_kubeadm_Networking(in, out, s) -} - -func autoConvert_kubeadm_Networking_To_v1alpha1_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_v1alpha1_Networking is an autogenerated conversion function. -func Convert_kubeadm_Networking_To_v1alpha1_Networking(in *kubeadm.Networking, out *Networking, s conversion.Scope) error { - return autoConvert_kubeadm_Networking_To_v1alpha1_Networking(in, out, s) -} - -func autoConvert_v1alpha1_NodeConfiguration_To_kubeadm_NodeConfiguration(in *NodeConfiguration, out *kubeadm.NodeConfiguration, s conversion.Scope) error { - out.CACertPath = in.CACertPath - out.DiscoveryFile = in.DiscoveryFile - out.DiscoveryToken = in.DiscoveryToken - out.DiscoveryTokenAPIServers = *(*[]string)(unsafe.Pointer(&in.DiscoveryTokenAPIServers)) - out.DiscoveryTimeout = (*metav1.Duration)(unsafe.Pointer(in.DiscoveryTimeout)) - // WARNING: in.NodeName requires manual conversion: does not exist in peer-type - out.TLSBootstrapToken = in.TLSBootstrapToken - out.Token = in.Token - // WARNING: in.CRISocket requires manual conversion: does not exist in peer-type - out.ClusterName = in.ClusterName - out.DiscoveryTokenCACertHashes = *(*[]string)(unsafe.Pointer(&in.DiscoveryTokenCACertHashes)) - out.DiscoveryTokenUnsafeSkipCAVerification = in.DiscoveryTokenUnsafeSkipCAVerification - out.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - return nil -} - -func autoConvert_kubeadm_NodeConfiguration_To_v1alpha1_NodeConfiguration(in *kubeadm.NodeConfiguration, out *NodeConfiguration, s conversion.Scope) error { - // WARNING: in.NodeRegistration requires manual conversion: does not exist in peer-type - out.CACertPath = in.CACertPath - out.DiscoveryFile = in.DiscoveryFile - out.DiscoveryToken = in.DiscoveryToken - out.DiscoveryTokenAPIServers = *(*[]string)(unsafe.Pointer(&in.DiscoveryTokenAPIServers)) - out.DiscoveryTimeout = (*metav1.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.FeatureGates = *(*map[string]bool)(unsafe.Pointer(&in.FeatureGates)) - return nil -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.deepcopy.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 5268c479f09..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,360 +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 v1alpha1 - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - v1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1" - kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/v1alpha1" -) - -// 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 *Etcd) DeepCopyInto(out *Etcd) { - *out = *in - if in.Endpoints != nil { - in, out := &in.Endpoints, &out.Endpoints - *out = make([]string, len(*in)) - copy(*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.SelfHosted != nil { - in, out := &in.SelfHosted, &out.SelfHosted - *out = new(SelfHostedEtcd) - **out = **in - } - 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 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 *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 *KubeProxy) DeepCopyInto(out *KubeProxy) { - *out = *in - if in.Config != nil { - in, out := &in.Config, &out.Config - *out = new(kubeproxyconfigv1alpha1.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 *MasterConfiguration) DeepCopyInto(out *MasterConfiguration) { - *out = *in - out.TypeMeta = in.TypeMeta - 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.AuthorizationModes != nil { - in, out := &in.AuthorizationModes, &out.AuthorizationModes - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.TokenTTL != nil { - in, out := &in.TokenTTL, &out.TokenTTL - *out = new(v1.Duration) - **out = **in - } - if in.TokenUsages != nil { - in, out := &in.TokenUsages, &out.TokenUsages - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.TokenGroups != nil { - in, out := &in.TokenGroups, &out.TokenGroups - *out = make([]string, len(*in)) - copy(*out, *in) - } - 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 MasterConfiguration. -func (in *MasterConfiguration) DeepCopy() *MasterConfiguration { - if in == nil { - return nil - } - out := new(MasterConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MasterConfiguration) 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 *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 *NodeConfiguration) DeepCopyInto(out *NodeConfiguration) { - *out = *in - out.TypeMeta = in.TypeMeta - 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 NodeConfiguration. -func (in *NodeConfiguration) DeepCopy() *NodeConfiguration { - if in == nil { - return nil - } - out := new(NodeConfiguration) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *NodeConfiguration) 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 *SelfHostedEtcd) DeepCopyInto(out *SelfHostedEtcd) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelfHostedEtcd. -func (in *SelfHostedEtcd) DeepCopy() *SelfHostedEtcd { - if in == nil { - return nil - } - out := new(SelfHostedEtcd) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TokenDiscovery) DeepCopyInto(out *TokenDiscovery) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TokenDiscovery. -func (in *TokenDiscovery) DeepCopy() *TokenDiscovery { - if in == nil { - return nil - } - out := new(TokenDiscovery) - in.DeepCopyInto(out) - return out -} diff --git a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.defaults.go b/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.defaults.go deleted file mode 100644 index ccb898b1cfb..00000000000 --- a/cmd/kubeadm/app/apis/kubeadm/v1alpha1/zz_generated.defaults.go +++ /dev/null @@ -1,50 +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 v1alpha1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" - v1beta1 "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig/v1beta1" - kubeproxyconfigv1alpha1 "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig/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(&MasterConfiguration{}, func(obj interface{}) { SetObjectDefaults_MasterConfiguration(obj.(*MasterConfiguration)) }) - scheme.AddTypeDefaultingFunc(&NodeConfiguration{}, func(obj interface{}) { SetObjectDefaults_NodeConfiguration(obj.(*NodeConfiguration)) }) - return nil -} - -func SetObjectDefaults_MasterConfiguration(in *MasterConfiguration) { - SetDefaults_MasterConfiguration(in) - if in.KubeProxy.Config != nil { - kubeproxyconfigv1alpha1.SetDefaults_KubeProxyConfiguration(in.KubeProxy.Config) - } - if in.KubeletConfiguration.BaseConfig != nil { - v1beta1.SetDefaults_KubeletConfiguration(in.KubeletConfiguration.BaseConfig) - } -} - -func SetObjectDefaults_NodeConfiguration(in *NodeConfiguration) { - SetDefaults_NodeConfiguration(in) -}