mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #101129 from neolit123/1.22-kubeadm-v1beta3
kubeadm: add placeholder v1beta3; remove the deprecated v1beta1
This commit is contained in:
commit
89db31aade
@ -21,7 +21,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
|
||||
@ -58,18 +58,18 @@ func fuzzInitConfiguration(obj *kubeadm.InitConfiguration, c fuzz.Continue) {
|
||||
DNS: kubeadm.DNS{
|
||||
Type: kubeadm.CoreDNS,
|
||||
},
|
||||
CertificatesDir: v1beta2.DefaultCertificatesDir,
|
||||
ClusterName: v1beta2.DefaultClusterName,
|
||||
CertificatesDir: kubeadmapiv1.DefaultCertificatesDir,
|
||||
ClusterName: kubeadmapiv1.DefaultClusterName,
|
||||
Etcd: kubeadm.Etcd{
|
||||
Local: &kubeadm.LocalEtcd{
|
||||
DataDir: v1beta2.DefaultEtcdDataDir,
|
||||
DataDir: kubeadmapiv1.DefaultEtcdDataDir,
|
||||
},
|
||||
},
|
||||
ImageRepository: v1beta2.DefaultImageRepository,
|
||||
KubernetesVersion: v1beta2.DefaultKubernetesVersion,
|
||||
ImageRepository: kubeadmapiv1.DefaultImageRepository,
|
||||
KubernetesVersion: kubeadmapiv1.DefaultKubernetesVersion,
|
||||
Networking: kubeadm.Networking{
|
||||
ServiceSubnet: v1beta2.DefaultServicesSubnet,
|
||||
DNSDomain: v1beta2.DefaultServiceDNSDomain,
|
||||
ServiceSubnet: kubeadmapiv1.DefaultServicesSubnet,
|
||||
DNSDomain: kubeadmapiv1.DefaultServiceDNSDomain,
|
||||
},
|
||||
}
|
||||
// Adds the default bootstrap token to get the round working
|
||||
@ -83,9 +83,6 @@ func fuzzInitConfiguration(obj *kubeadm.InitConfiguration, c fuzz.Continue) {
|
||||
Usages: []string{"foo"},
|
||||
},
|
||||
}
|
||||
|
||||
// Pin values for fields that are not present in v1beta1
|
||||
obj.CertificateKey = ""
|
||||
}
|
||||
|
||||
func fuzzNodeRegistration(obj *kubeadm.NodeRegistrationOptions, c fuzz.Continue) {
|
||||
@ -150,7 +147,4 @@ func fuzzJoinConfiguration(obj *kubeadm.JoinConfiguration, c fuzz.Continue) {
|
||||
|
||||
func fuzzJoinControlPlane(obj *kubeadm.JoinControlPlane, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(obj)
|
||||
|
||||
// Pin values for fields that are not present in v1beta1
|
||||
obj.CertificateKey = ""
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ 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/v1beta1"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
)
|
||||
|
||||
// Scheme is the runtime.Scheme to which all kubeadm api types are registered.
|
||||
@ -41,7 +41,7 @@ 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(v1beta1.AddToScheme(scheme))
|
||||
utilruntime.Must(v1beta2.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1beta2.SchemeGroupVersion))
|
||||
utilruntime.Must(v1beta3.AddToScheme(scheme))
|
||||
utilruntime.Must(scheme.SetVersionPriority(v1beta3.SchemeGroupVersion))
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 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 v1beta1
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
)
|
||||
|
||||
func Convert_kubeadm_InitConfiguration_To_v1beta1_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error {
|
||||
if err := autoConvert_kubeadm_InitConfiguration_To_v1beta1_InitConfiguration(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if in.CertificateKey != "" {
|
||||
return errors.New("certificateKey field is not supported by v1beta1 config format")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_kubeadm_JoinControlPlane_To_v1beta1_JoinControlPlane(in *kubeadm.JoinControlPlane, out *JoinControlPlane, s conversion.Scope) error {
|
||||
if err := autoConvert_kubeadm_JoinControlPlane_To_v1beta1_JoinControlPlane(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if in.CertificateKey != "" {
|
||||
return errors.New("certificateKey field is not supported by v1beta1 config format")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_kubeadm_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(in *kubeadm.NodeRegistrationOptions, out *NodeRegistrationOptions, s conversion.Scope) error {
|
||||
if err := autoConvert_kubeadm_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(in.IgnorePreflightErrors) > 0 {
|
||||
return errors.New("ignorePreflightErrors field is not supported by v1beta1 config format")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -1,149 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 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 v1beta1
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
)
|
||||
|
||||
func TestInternalToVersionedInitConfigurationConversion(t *testing.T) {
|
||||
testcases := map[string]struct {
|
||||
in kubeadm.InitConfiguration
|
||||
expectedError bool
|
||||
}{
|
||||
"conversion succeeds": {
|
||||
in: kubeadm.InitConfiguration{},
|
||||
expectedError: false,
|
||||
},
|
||||
"certificateKey set causes an error": {
|
||||
in: kubeadm.InitConfiguration{
|
||||
CertificateKey: "secret",
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
"ignorePreflightErrors set causes an error": {
|
||||
in: kubeadm.InitConfiguration{
|
||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
||||
IgnorePreflightErrors: []string{"SomeUndesirableError"},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
}
|
||||
for name, tc := range testcases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
versioned := &InitConfiguration{}
|
||||
err := Convert_kubeadm_InitConfiguration_To_v1beta1_InitConfiguration(&tc.in, versioned, nil)
|
||||
if err == nil && tc.expectedError {
|
||||
t.Error("unexpected success")
|
||||
} else if err != nil && !tc.expectedError {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInternalToVersionedJoinConfigurationConversion(t *testing.T) {
|
||||
testcases := map[string]struct {
|
||||
in kubeadm.JoinConfiguration
|
||||
expectedError bool
|
||||
}{
|
||||
"conversion succeeds": {
|
||||
in: kubeadm.JoinConfiguration{},
|
||||
expectedError: false,
|
||||
},
|
||||
"ignorePreflightErrors set causes an error": {
|
||||
in: kubeadm.JoinConfiguration{
|
||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
||||
IgnorePreflightErrors: []string{"SomeUndesirableError"},
|
||||
},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
}
|
||||
for name, tc := range testcases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
versioned := &JoinConfiguration{}
|
||||
err := Convert_kubeadm_JoinConfiguration_To_v1beta1_JoinConfiguration(&tc.in, versioned, nil)
|
||||
if err == nil && tc.expectedError {
|
||||
t.Error("unexpected success")
|
||||
} else if err != nil && !tc.expectedError {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInternalToVersionedNodeRegistrationOptionsConversion(t *testing.T) {
|
||||
testcases := map[string]struct {
|
||||
in kubeadm.NodeRegistrationOptions
|
||||
expectedError bool
|
||||
}{
|
||||
"conversion succeeds": {
|
||||
in: kubeadm.NodeRegistrationOptions{},
|
||||
expectedError: false,
|
||||
},
|
||||
"ignorePreflightErrors set causes an error": {
|
||||
in: kubeadm.NodeRegistrationOptions{
|
||||
IgnorePreflightErrors: []string{"SomeUndesirableError"},
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
}
|
||||
for name, tc := range testcases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
versioned := &NodeRegistrationOptions{}
|
||||
err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta1_NodeRegistrationOptions(&tc.in, versioned, nil)
|
||||
if err == nil && tc.expectedError {
|
||||
t.Error("unexpected success")
|
||||
} else if err != nil && !tc.expectedError {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInternalToVersionedJoinControlPlaneConversion(t *testing.T) {
|
||||
testcases := map[string]struct {
|
||||
in kubeadm.JoinControlPlane
|
||||
expectedError bool
|
||||
}{
|
||||
"conversion succeeds": {
|
||||
in: kubeadm.JoinControlPlane{},
|
||||
expectedError: false,
|
||||
},
|
||||
"certificateKey set causes an error": {
|
||||
in: kubeadm.JoinControlPlane{
|
||||
CertificateKey: "secret",
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
}
|
||||
for name, tc := range testcases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
versioned := &JoinControlPlane{}
|
||||
err := Convert_kubeadm_JoinControlPlane_To_v1beta1_JoinControlPlane(&tc.in, versioned, nil)
|
||||
if err == nil && tc.expectedError {
|
||||
t.Error("unexpected success")
|
||||
} else if err != nil && !tc.expectedError {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -26,7 +26,6 @@ import (
|
||||
bootstraputil "k8s.io/cluster-bootstrap/token/util"
|
||||
)
|
||||
|
||||
// DEPRECATED - This group version of BootstrapTokenString is deprecated by apis/kubeadm/v1beta2/BootstrapTokenString.
|
||||
// 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
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
import (
|
||||
"encoding/json"
|
38
cmd/kubeadm/app/apis/kubeadm/v1beta3/conversion.go
Normal file
38
cmd/kubeadm/app/apis/kubeadm/v1beta3/conversion.go
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2021 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 v1beta3
|
||||
|
||||
import (
|
||||
conversion "k8s.io/apimachinery/pkg/conversion"
|
||||
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
)
|
||||
|
||||
func Convert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func Convert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConfiguration, out *kubeadm.InitConfiguration, s conversion.Scope) error {
|
||||
err := autoConvert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in, out, s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Keep the fuzzer test happy by setting out.ClusterConfiguration to defaults
|
||||
clusterCfg := &ClusterConfiguration{}
|
||||
SetDefaults_ClusterConfiguration(clusterCfg)
|
||||
return Convert_v1beta3_ClusterConfiguration_To_kubeadm_ClusterConfiguration(clusterCfg, &out.ClusterConfiguration, s)
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
@ -67,7 +67,6 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_InitConfiguration assigns default values for the InitConfiguration
|
||||
func SetDefaults_InitConfiguration(obj *InitConfiguration) {
|
||||
SetDefaults_ClusterConfiguration(&obj.ClusterConfiguration)
|
||||
SetDefaults_BootstrapTokens(obj)
|
||||
SetDefaults_APIEndpoint(&obj.LocalAPIEndpoint)
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// +build !windows
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
const (
|
||||
// DefaultCACertPath defines default location of CA certificate on Linux
|
@ -1,7 +1,7 @@
|
||||
// +build windows
|
||||
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
const (
|
||||
// DefaultCACertPath defines default location of CA certificate on Windows
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -19,32 +19,16 @@ limitations under the License.
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:conversion-gen=k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm
|
||||
|
||||
// Package v1beta1 has been deprecated by v1beta2
|
||||
// Package v1beta1 defines the v1beta1 version of the kubeadm configuration file format.
|
||||
// This version graduates the configuration format to BETA and is a big step towards GA.
|
||||
// Package v1beta3 defines the v1beta3 version of the kubeadm configuration file format.
|
||||
// This version improves on the v1beta2 format by fixing some minor issues and adding a few new fields.
|
||||
//
|
||||
//A list of changes since v1alpha3:
|
||||
// - "apiServerEndpoint" in InitConfiguration was renamed to "localAPIEndpoint" for better clarity of what the field
|
||||
// represents.
|
||||
// - Common fields in ClusterConfiguration such as "*extraArgs" and "*extraVolumes" for control plane components are now moved
|
||||
// under component structs - i.e. "apiServer", "controllerManager", "scheduler".
|
||||
// - "auditPolicy" was removed from ClusterConfiguration. Please use "extraArgs" in "apiServer" to configure this feature instead.
|
||||
// - "unifiedControlPlaneImage" in ClusterConfiguration was changed to a boolean field called "useHyperKubeImage".
|
||||
// - ClusterConfiguration now has a "dns" field which can be used to select and configure the cluster DNS addon.
|
||||
// - "featureGates" still exists under ClusterConfiguration, but there are no supported feature gates in 1.13.
|
||||
// See the Kubernetes 1.13 changelog for further details.
|
||||
// - Both "localEtcd" and "dns" configurations now support custom image repositories.
|
||||
// - The "controlPlane*"-related fields in JoinConfiguration were refactored into a sub-structure.
|
||||
// - "clusterName" was removed from JoinConfiguration and the name is now fetched from the existing cluster.
|
||||
// A list of changes since v1beta2:
|
||||
// - TODO
|
||||
//
|
||||
// Migration from old kubeadm config versions
|
||||
//
|
||||
// Please convert your v1alpha3 configuration files to v1beta1 using the "kubeadm config migrate" command of kubeadm v1.13.x
|
||||
// (conversion from older releases of kubeadm config files requires older release of kubeadm as well e.g.
|
||||
// kubeadm v1.11 should be used to migrate v1alpha1 to v1alpha2; kubeadm v1.12 should be used to translate v1alpha2 to v1alpha3)
|
||||
//
|
||||
// Nevertheless, kubeadm v1.13.x will support reading from v1alpha3 version of the kubeadm config file format, but this support
|
||||
// will be dropped in the v1.14 release.
|
||||
// - kubeadm v1.15.x and newer can be used to migrate from the v1beta1 to v1beta2.
|
||||
// - kubeadm v1.22.x no longer supports v1beta1 and older APIs, but can be used to migrate v1beta2 to v1beta3.
|
||||
//
|
||||
// Basics
|
||||
//
|
||||
@ -56,10 +40,10 @@ limitations under the License.
|
||||
//
|
||||
// kubeadm supports the following configuration types:
|
||||
//
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: InitConfiguration
|
||||
//
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: ClusterConfiguration
|
||||
//
|
||||
// apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
@ -68,7 +52,7 @@ limitations under the License.
|
||||
// apiVersion: kubeproxy.config.k8s.io/v1alpha1
|
||||
// kind: KubeProxyConfiguration
|
||||
//
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: JoinConfiguration
|
||||
//
|
||||
// To print the defaults for "init" and "join" actions use the following commands:
|
||||
@ -94,7 +78,7 @@ limitations under the License.
|
||||
// InitConfiguration, ClusterConfiguration, KubeProxyConfiguration, KubeletConfiguration, but only one
|
||||
// between InitConfiguration and ClusterConfiguration is mandatory.
|
||||
//
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: InitConfiguration
|
||||
// bootstrapTokens:
|
||||
// ...
|
||||
@ -112,7 +96,7 @@ limitations under the License.
|
||||
// - LocalAPIEndpoint, that represents the endpoint of the instance of the API server to be deployed on this node;
|
||||
// use it e.g. to customize the API server advertise address.
|
||||
//
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: ClusterConfiguration
|
||||
// networking:
|
||||
// ...
|
||||
@ -160,7 +144,7 @@ limitations under the License.
|
||||
// Here is a fully populated example of a single YAML file containing multiple
|
||||
// configuration types to be used during a `kubeadm init` run.
|
||||
//
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: InitConfiguration
|
||||
// bootstrapTokens:
|
||||
// - token: "9a08jv.c0izixklcxtmnze7"
|
||||
@ -182,11 +166,14 @@ limitations under the License.
|
||||
// effect: "NoSchedule"
|
||||
// kubeletExtraArgs:
|
||||
// v: 4
|
||||
// ignorePreflightErrors:
|
||||
// - IsPrivilegedUser
|
||||
// localAPIEndpoint:
|
||||
// advertiseAddress: "10.100.0.1"
|
||||
// bindPort: 6443
|
||||
// certificateKey: "e6a2eb8581237ab72a4f494f30285ec12a9694d750b9785706a83bfcbbbd2204"
|
||||
// ---
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: ClusterConfiguration
|
||||
// etcd:
|
||||
// # one of local or external
|
||||
@ -261,7 +248,7 @@ limitations under the License.
|
||||
//
|
||||
// When executing kubeadm join with the --config option, the JoinConfiguration type should be provided.
|
||||
//
|
||||
// apiVersion: kubeadm.k8s.io/v1beta1
|
||||
// apiVersion: kubeadm.k8s.io/v1beta3
|
||||
// kind: JoinConfiguration
|
||||
// ...
|
||||
//
|
||||
@ -275,7 +262,7 @@ limitations under the License.
|
||||
//
|
||||
// - APIEndpoint, that represents the endpoint of the instance of the API server to be eventually deployed on this node.
|
||||
//
|
||||
package v1beta1 // import "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1"
|
||||
package v1beta3 // import "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
|
||||
//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.
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -26,7 +26,7 @@ import (
|
||||
const GroupName = "kubeadm.k8s.io"
|
||||
|
||||
// SchemeGroupVersion is group version used to register these objects
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"}
|
||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta3"}
|
||||
|
||||
var (
|
||||
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes Authors.
|
||||
Copyright 2021 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.
|
||||
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
@ -23,18 +23,11 @@ import (
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// DEPRECATED - This group version of InitConfiguration is deprecated by apis/kubeadm/v1beta2/InitConfiguration.
|
||||
// InitConfiguration contains a list of elements that is specific "kubeadm init"-only runtime
|
||||
// information.
|
||||
type InitConfiguration struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// ClusterConfiguration holds the cluster-wide information, and embeds that struct (which can be (un)marshalled separately as well)
|
||||
// When InitConfiguration is marshalled to bytes in the external version, this information IS NOT preserved (which can be seen from
|
||||
// the `json:"-"` tag. This is due to that when InitConfiguration is (un)marshalled, it turns into two YAML documents, one for the
|
||||
// InitConfiguration and ClusterConfiguration. Hence, the information must not be duplicated, and is therefore omitted here.
|
||||
ClusterConfiguration `json:"-"`
|
||||
|
||||
// `kubeadm init`-only information. These fields are solely used the first time `kubeadm init` runs.
|
||||
// After that, the information in the fields IS NOT uploaded to the `kubeadm-config` ConfigMap
|
||||
// that is used by `kubeadm upgrade` for instance. These fields must be omitempty.
|
||||
@ -53,23 +46,26 @@ type InitConfiguration struct {
|
||||
// on. By default, kubeadm tries to auto-detect the IP of the default interface and use that, but in case that process
|
||||
// fails you may set the desired value here.
|
||||
LocalAPIEndpoint APIEndpoint `json:"localAPIEndpoint,omitempty"`
|
||||
|
||||
// CertificateKey sets the key with which certificates and keys are encrypted prior to being uploaded in
|
||||
// a secret in the cluster during the uploadcerts init phase.
|
||||
CertificateKey string `json:"certificateKey,omitempty"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// DEPRECATED - This group version of ClusterConfiguration is deprecated by apis/kubeadm/v1beta2/ClusterConfiguration.
|
||||
// ClusterConfiguration contains cluster-wide configuration for a kubeadm cluster
|
||||
type ClusterConfiguration struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// Etcd holds configuration for etcd.
|
||||
Etcd Etcd `json:"etcd"`
|
||||
Etcd Etcd `json:"etcd,omitempty"`
|
||||
|
||||
// Networking holds configuration for the networking topology of the cluster.
|
||||
Networking Networking `json:"networking"`
|
||||
Networking Networking `json:"networking,omitempty"`
|
||||
|
||||
// KubernetesVersion is the target version of the control plane.
|
||||
KubernetesVersion string `json:"kubernetesVersion"`
|
||||
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
|
||||
|
||||
// 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.
|
||||
@ -82,7 +78,7 @@ type ClusterConfiguration struct {
|
||||
// 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"`
|
||||
ControlPlaneEndpoint string `json:"controlPlaneEndpoint,omitempty"`
|
||||
|
||||
// APIServer contains extra settings for the API server control plane component
|
||||
APIServer APIServer `json:"apiServer,omitempty"`
|
||||
@ -94,16 +90,16 @@ type ClusterConfiguration struct {
|
||||
Scheduler ControlPlaneComponent `json:"scheduler,omitempty"`
|
||||
|
||||
// DNS defines the options for the DNS add-on installed in the cluster.
|
||||
DNS DNS `json:"dns"`
|
||||
DNS DNS `json:"dns,omitempty"`
|
||||
|
||||
// CertificatesDir specifies where to store or look for all required certificates.
|
||||
CertificatesDir string `json:"certificatesDir"`
|
||||
CertificatesDir string `json:"certificatesDir,omitempty"`
|
||||
|
||||
// ImageRepository sets the container registry to pull images from.
|
||||
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/` or `ci-cross/`)
|
||||
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
|
||||
// will be used for all the other images.
|
||||
ImageRepository string `json:"imageRepository"`
|
||||
ImageRepository string `json:"imageRepository,omitempty"`
|
||||
|
||||
// UseHyperKubeImage controls if hyperkube should be used for Kubernetes components instead of their respective separate images
|
||||
// DEPRECATED: As hyperkube is itself deprecated, this fields is too. It will be removed in future kubeadm config versions, kubeadm
|
||||
@ -185,11 +181,11 @@ type ClusterStatus struct {
|
||||
// APIEndpoint struct contains elements of API server instance deployed on a node.
|
||||
type APIEndpoint struct {
|
||||
// AdvertiseAddress sets the IP address for the API server to advertise.
|
||||
AdvertiseAddress string `json:"advertiseAddress"`
|
||||
AdvertiseAddress string `json:"advertiseAddress,omitempty"`
|
||||
|
||||
// BindPort sets the secure port for the API Server to bind to.
|
||||
// Defaults to 6443.
|
||||
BindPort int32 `json:"bindPort"`
|
||||
BindPort int32 `json:"bindPort,omitempty"`
|
||||
}
|
||||
|
||||
// NodeRegistrationOptions holds fields that relate to registering a new control-plane or node to the cluster, either via "kubeadm init" or "kubeadm join"
|
||||
@ -206,22 +202,25 @@ type NodeRegistrationOptions struct {
|
||||
// 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 control-plane 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"`
|
||||
Taints []v1.Taint `json:"taints"`
|
||||
|
||||
// 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 priority when parsing. These values are local and specific to the node kubeadm is executing on.
|
||||
KubeletExtraArgs map[string]string `json:"kubeletExtraArgs,omitempty"`
|
||||
|
||||
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered.
|
||||
IgnorePreflightErrors []string `json:"ignorePreflightErrors,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"`
|
||||
ServiceSubnet string `json:"serviceSubnet,omitempty"`
|
||||
// PodSubnet is the subnet used by pods.
|
||||
PodSubnet string `json:"podSubnet"`
|
||||
PodSubnet string `json:"podSubnet,omitempty"`
|
||||
// DNSDomain is the dns domain used by k8s services. Defaults to "cluster.local".
|
||||
DNSDomain string `json:"dnsDomain"`
|
||||
DNSDomain string `json:"dnsDomain,omitempty"`
|
||||
}
|
||||
|
||||
// BootstrapToken describes one bootstrap token, stored as a Secret in the cluster
|
||||
@ -298,18 +297,17 @@ type ExternalEtcd struct {
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// DEPRECATED - This group version of JoinConfiguration is deprecated by apis/kubeadm/v1beta2/JoinConfiguration.
|
||||
// JoinConfiguration contains elements describing a particular node.
|
||||
type JoinConfiguration struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
||||
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration"`
|
||||
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
|
||||
|
||||
// CACertPath is the path to the SSL certificate authority used to
|
||||
// secure comunications between node and control-plane.
|
||||
// Defaults to "/etc/kubernetes/pki/ca.crt".
|
||||
CACertPath string `json:"caCertPath"`
|
||||
CACertPath string `json:"caCertPath,omitempty"`
|
||||
|
||||
// Discovery specifies the options for the kubelet to use during the TLS Bootstrap process
|
||||
Discovery Discovery `json:"discovery"`
|
||||
@ -323,6 +321,10 @@ type JoinConfiguration struct {
|
||||
type JoinControlPlane struct {
|
||||
// LocalAPIEndpoint represents the endpoint of the API server instance to be deployed on this node.
|
||||
LocalAPIEndpoint APIEndpoint `json:"localAPIEndpoint,omitempty"`
|
||||
|
||||
// CertificateKey is the key that is used for decryption of certificates after they are downloaded from the secret
|
||||
// upon joining a new control plane node. The corresponding encryption key is in the InitConfiguration.
|
||||
CertificateKey string `json:"certificateKey,omitempty"`
|
||||
}
|
||||
|
||||
// Discovery specifies the options for the kubelet to use during the TLS Bootstrap process
|
||||
@ -338,7 +340,7 @@ type Discovery struct {
|
||||
// TLSBootstrapToken is a token used for TLS bootstrapping.
|
||||
// If .BootstrapToken is set, this field is defaulted to .BootstrapToken.Token, but can be overridden.
|
||||
// If .File is set, this field **must be set** in case the KubeConfigFile does not contain any other authentication information
|
||||
TLSBootstrapToken string `json:"tlsBootstrapToken"`
|
||||
TLSBootstrapToken string `json:"tlsBootstrapToken,omitempty"`
|
||||
|
||||
// Timeout modifies the discovery timeout
|
||||
Timeout *metav1.Duration `json:"timeout,omitempty"`
|
||||
@ -365,7 +367,7 @@ type BootstrapTokenDiscovery struct {
|
||||
// UnsafeSkipCAVerification allows token-based discovery
|
||||
// without CA verification via CACertHashes. This can weaken
|
||||
// the security of kubeadm since other nodes can impersonate the control-plane.
|
||||
UnsafeSkipCAVerification bool `json:"unsafeSkipCAVerification"`
|
||||
UnsafeSkipCAVerification bool `json:"unsafeSkipCAVerification,omitempty"`
|
||||
}
|
||||
|
||||
// FileDiscovery is used to specify a file or URL to a kubeconfig file from which to load cluster information
|
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,7 @@ limitations under the License.
|
||||
|
||||
// Code generated by deepcopy-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
@ -391,7 +391,6 @@ func (in *ImageMeta) DeepCopy() *ImageMeta {
|
||||
func (in *InitConfiguration) DeepCopyInto(out *InitConfiguration) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ClusterConfiguration.DeepCopyInto(&out.ClusterConfiguration)
|
||||
if in.BootstrapTokens != nil {
|
||||
in, out := &in.BootstrapTokens, &out.BootstrapTokens
|
||||
*out = make([]BootstrapToken, len(*in))
|
||||
@ -538,6 +537,11 @@ func (in *NodeRegistrationOptions) DeepCopyInto(out *NodeRegistrationOptions) {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.IgnorePreflightErrors != nil {
|
||||
in, out := &in.IgnorePreflightErrors, &out.IgnorePreflightErrors
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ limitations under the License.
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
package v1beta3
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
@ -45,7 +45,6 @@ func SetObjectDefaults_ClusterStatus(in *ClusterStatus) {
|
||||
|
||||
func SetObjectDefaults_InitConfiguration(in *InitConfiguration) {
|
||||
SetDefaults_InitConfiguration(in)
|
||||
SetObjectDefaults_ClusterConfiguration(&in.ClusterConfiguration)
|
||||
for i := range in.BootstrapTokens {
|
||||
a := &in.BootstrapTokens[i]
|
||||
SetDefaults_BootstrapToken(a)
|
@ -34,7 +34,7 @@ import (
|
||||
bootstraputil "k8s.io/cluster-bootstrap/token/util"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
kubeadmcmdoptions "k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
@ -639,7 +639,7 @@ func ValidateSocketPath(socket string, fldPath *field.Path) field.ErrorList {
|
||||
if !filepath.IsAbs(u.Path) {
|
||||
return append(allErrs, field.Invalid(fldPath, socket, fmt.Sprintf("path is not absolute: %s", socket)))
|
||||
}
|
||||
} else if u.Scheme != kubeadmapiv1beta2.DefaultUrlScheme {
|
||||
} else if u.Scheme != kubeadmapiv1.DefaultUrlScheme {
|
||||
return append(allErrs, field.Invalid(fldPath, socket, fmt.Sprintf("URL scheme %s is not supported", u.Scheme)))
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
)
|
||||
|
||||
@ -986,7 +986,7 @@ func TestValidateSocketPath(t *testing.T) {
|
||||
expectedErrors bool
|
||||
}{
|
||||
{name: "valid path", criSocket: "/some/path", expectedErrors: false},
|
||||
{name: "valid socket url", criSocket: kubeadmapiv1beta2.DefaultUrlScheme + "://" + "/some/path", expectedErrors: false},
|
||||
{name: "valid socket url", criSocket: kubeadmapiv1.DefaultUrlScheme + "://" + "/some/path", expectedErrors: false},
|
||||
{name: "unsupported url scheme", criSocket: "bla:///some/path", expectedErrors: true},
|
||||
{name: "unparseable url", criSocket: ":::", expectedErrors: true},
|
||||
{name: "invalid CRISocket (path is not absolute)", criSocket: "some/path", expectedErrors: true},
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
@ -62,7 +62,7 @@ func NewCmdKubeConfigUtility(out io.Writer) *cobra.Command {
|
||||
func newCmdUserKubeConfig(out io.Writer) *cobra.Command {
|
||||
|
||||
initCfg := cmdutil.DefaultInitConfiguration()
|
||||
clusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{}
|
||||
clusterCfg := &kubeadmapiv1.ClusterConfiguration{}
|
||||
|
||||
var (
|
||||
token, clientName, cfgPath string
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/pkiutil"
|
||||
testutil "k8s.io/kubernetes/cmd/kubeadm/test"
|
||||
@ -37,19 +37,19 @@ import (
|
||||
|
||||
func generateTestKubeadmConfig(dir, id, certDir, clusterName string) (string, error) {
|
||||
cfgPath := filepath.Join(dir, id)
|
||||
initCfg := kubeadmapiv1beta2.InitConfiguration{
|
||||
initCfg := kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
||||
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||
Kind: "InitConfiguration",
|
||||
},
|
||||
LocalAPIEndpoint: kubeadmapiv1beta2.APIEndpoint{
|
||||
LocalAPIEndpoint: kubeadmapiv1.APIEndpoint{
|
||||
AdvertiseAddress: "1.2.3.4",
|
||||
BindPort: 1234,
|
||||
},
|
||||
}
|
||||
clusterCfg := kubeadmapiv1beta2.ClusterConfiguration{
|
||||
clusterCfg := kubeadmapiv1.ClusterConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
||||
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||
Kind: "ClusterConfiguration",
|
||||
},
|
||||
CertificatesDir: certDir,
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
@ -134,7 +134,7 @@ func (o *genCSRConfig) load() (err error) {
|
||||
o.kubeadmConfig, err = configutil.LoadOrDefaultInitConfiguration(
|
||||
o.kubeadmConfigPath,
|
||||
cmdutil.DefaultInitConfiguration(),
|
||||
&kubeadmapiv1beta2.ClusterConfiguration{},
|
||||
&kubeadmapiv1.ClusterConfiguration{},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -214,14 +214,14 @@ func newCmdCertsRenewal(out io.Writer) *cobra.Command {
|
||||
type renewFlags struct {
|
||||
cfgPath string
|
||||
kubeconfigPath string
|
||||
cfg kubeadmapiv1beta2.ClusterConfiguration
|
||||
cfg kubeadmapiv1.ClusterConfiguration
|
||||
csrOnly bool
|
||||
csrPath string
|
||||
}
|
||||
|
||||
func getRenewSubCommands(out io.Writer, kdir string) []*cobra.Command {
|
||||
flags := &renewFlags{
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
// Setting kubernetes version to a default value in order to allow a not necessary internet lookup
|
||||
KubernetesVersion: kubeadmconstants.CurrentKubernetesVersion.String(),
|
||||
},
|
||||
@ -342,7 +342,7 @@ func renewCert(flags *renewFlags, kdir string, internalcfg *kubeadmapi.InitConfi
|
||||
return nil
|
||||
}
|
||||
|
||||
func getInternalCfg(cfgPath string, kubeconfigPath string, cfg kubeadmapiv1beta2.ClusterConfiguration, out io.Writer, logPrefix string) (*kubeadmapi.InitConfiguration, error) {
|
||||
func getInternalCfg(cfgPath string, kubeconfigPath string, cfg kubeadmapiv1.ClusterConfiguration, out io.Writer, logPrefix string) (*kubeadmapi.InitConfiguration, error) {
|
||||
// In case the user is not providing a custom config, try to get current config from the cluster.
|
||||
// NB. this operation should not block, because we want to allow certificate renewal also in case of not-working clusters
|
||||
if cfgPath == "" {
|
||||
@ -364,7 +364,7 @@ func getInternalCfg(cfgPath string, kubeconfigPath string, cfg kubeadmapiv1beta2
|
||||
// newCmdCertsExpiration creates a new `cert check-expiration` command.
|
||||
func newCmdCertsExpiration(out io.Writer, kdir string) *cobra.Command {
|
||||
flags := &expirationFlags{
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
// Setting kubernetes version to a default value in order to allow a not necessary internet lookup
|
||||
KubernetesVersion: kubeadmconstants.CurrentKubernetesVersion.String(),
|
||||
},
|
||||
@ -463,7 +463,7 @@ func newCmdCertsExpiration(out io.Writer, kdir string) *cobra.Command {
|
||||
type expirationFlags struct {
|
||||
cfgPath string
|
||||
kubeconfigPath string
|
||||
cfg kubeadmapiv1beta2.ClusterConfiguration
|
||||
cfg kubeadmapiv1.ClusterConfiguration
|
||||
}
|
||||
|
||||
func addExpirationFlags(cmd *cobra.Command, flags *expirationFlags) {
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
certsphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/certs"
|
||||
kubeconfigphase "k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig"
|
||||
@ -379,14 +379,14 @@ func TestGenCSRConfig(t *testing.T) {
|
||||
// A minimal kubeadm config with just enough values to avoid triggering
|
||||
// auto-detection of config values at runtime.
|
||||
var kubeadmConfig = `
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: InitConfiguration
|
||||
localAPIEndpoint:
|
||||
advertiseAddress: 192.0.2.1
|
||||
nodeRegistration:
|
||||
criSocket: /path/to/dockershim.sock
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
certificatesDir: /custom/config/certificates-dir
|
||||
kubernetesVersion: ` + kubeadmconstants.MinimumControlPlaneVersion.String()
|
||||
@ -410,7 +410,7 @@ kubernetesVersion: ` + kubeadmconstants.MinimumControlPlaneVersion.String()
|
||||
{
|
||||
name: "default",
|
||||
assertions: []assertion{
|
||||
hasCertDir(kubeadmapiv1beta2.DefaultCertificatesDir),
|
||||
hasCertDir(kubeadmapiv1.DefaultCertificatesDir),
|
||||
hasKubeConfigDir(kubeadmconstants.KubernetesDir),
|
||||
},
|
||||
},
|
||||
|
@ -37,7 +37,7 @@ 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"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
outputapischeme "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/scheme"
|
||||
outputapiv1alpha1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/v1alpha1"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
@ -91,7 +91,7 @@ func newCmdConfigPrint(out io.Writer) *cobra.Command {
|
||||
Short: "Print configuration",
|
||||
Long: dedent.Dedent(`
|
||||
This command prints configurations for subcommands provided.
|
||||
For details, see: https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2`),
|
||||
For details, see: https://pkg.go.dev/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm#section-directories`),
|
||||
RunE: cmdutil.SubCmdRunE("print"),
|
||||
}
|
||||
cmd.AddCommand(newCmdConfigPrintInitDefaults(out))
|
||||
@ -206,15 +206,15 @@ func getDefaultInitConfigBytes() ([]byte, error) {
|
||||
}
|
||||
|
||||
func getDefaultNodeConfigBytes() ([]byte, error) {
|
||||
internalcfg, err := configutil.DefaultedJoinConfiguration(&kubeadmapiv1beta2.JoinConfiguration{
|
||||
Discovery: kubeadmapiv1beta2.Discovery{
|
||||
BootstrapToken: &kubeadmapiv1beta2.BootstrapTokenDiscovery{
|
||||
internalcfg, err := configutil.DefaultedJoinConfiguration(&kubeadmapiv1.JoinConfiguration{
|
||||
Discovery: kubeadmapiv1.Discovery{
|
||||
BootstrapToken: &kubeadmapiv1.BootstrapTokenDiscovery{
|
||||
Token: configutil.PlaceholderToken.Token.String(),
|
||||
APIServerEndpoint: "kube-apiserver:6443",
|
||||
UnsafeSkipCAVerification: true, // TODO: UnsafeSkipCAVerification: true needs to be set for validation to pass, but shouldn't be recommended as the default
|
||||
},
|
||||
},
|
||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{
|
||||
CRISocket: constants.DefaultDockerCRISocket, // avoid CRI detection
|
||||
},
|
||||
})
|
||||
@ -244,7 +244,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"
|
||||
`), kubeadmapiv1beta2.SchemeGroupVersion, kubeadmapiv1beta2.SchemeGroupVersion),
|
||||
`), kubeadmapiv1.SchemeGroupVersion, kubeadmapiv1.SchemeGroupVersion),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(oldCfgPath) == 0 {
|
||||
return errors.New("the --old-config flag is mandatory")
|
||||
@ -327,9 +327,9 @@ func newCmdConfigImages(out io.Writer) *cobra.Command {
|
||||
|
||||
// newCmdConfigImagesPull returns the `kubeadm config images pull` command
|
||||
func newCmdConfigImagesPull() *cobra.Command {
|
||||
externalClusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{}
|
||||
externalClusterCfg := &kubeadmapiv1.ClusterConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(externalClusterCfg)
|
||||
externalInitCfg := &kubeadmapiv1beta2.InitConfiguration{}
|
||||
externalInitCfg := &kubeadmapiv1.InitConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(externalInitCfg)
|
||||
var cfgPath, featureGatesString string
|
||||
var err error
|
||||
@ -388,7 +388,7 @@ func PullControlPlaneImages(runtime utilruntime.ContainerRuntime, cfg *kubeadmap
|
||||
|
||||
// newCmdConfigImagesList returns the "kubeadm config images list" command
|
||||
func newCmdConfigImagesList(out io.Writer, mockK8sVersion *string) *cobra.Command {
|
||||
externalcfg := &kubeadmapiv1beta2.ClusterConfiguration{}
|
||||
externalcfg := &kubeadmapiv1.ClusterConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(externalcfg)
|
||||
var cfgPath, featureGatesString string
|
||||
var err error
|
||||
@ -430,7 +430,7 @@ func newCmdConfigImagesList(out io.Writer, mockK8sVersion *string) *cobra.Comman
|
||||
}
|
||||
|
||||
// NewImagesList returns the underlying struct for the "kubeadm config images list" command
|
||||
func NewImagesList(cfgPath string, cfg *kubeadmapiv1beta2.ClusterConfiguration) (*ImagesList, error) {
|
||||
func NewImagesList(cfgPath string, cfg *kubeadmapiv1.ClusterConfiguration) (*ImagesList, error) {
|
||||
initcfg, err := configutil.LoadOrDefaultInitConfiguration(cfgPath, cmdutil.DefaultInitConfiguration(), cfg)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not convert cfg to an internal cfg")
|
||||
@ -485,7 +485,7 @@ func (i *ImagesList) Run(out io.Writer, printer output.Printer) error {
|
||||
}
|
||||
|
||||
// AddImagesCommonConfigFlags adds the flags that configure kubeadm (and affect the images kubeadm will use)
|
||||
func AddImagesCommonConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta2.ClusterConfiguration, cfgPath *string, featureGatesString *string) {
|
||||
func AddImagesCommonConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1.ClusterConfiguration, cfgPath *string, featureGatesString *string) {
|
||||
options.AddKubernetesVersionFlag(flagSet, &cfg.KubernetesVersion)
|
||||
options.AddFeatureGatesStringFlag(flagSet, featureGatesString)
|
||||
options.AddImageMetaFlags(flagSet, &cfg.ImageRepository)
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
|
||||
"github.com/lithammer/dedent"
|
||||
"github.com/spf13/cobra"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
outputapischeme "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/scheme"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
@ -81,7 +81,7 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) {
|
||||
constants.CurrentKubernetesVersion.String(),
|
||||
},
|
||||
configContents: []byte(dedent.Dedent(fmt.Sprintf(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
kubernetesVersion: %s
|
||||
`, constants.CurrentKubernetesVersion))),
|
||||
@ -93,7 +93,7 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) {
|
||||
"coredns",
|
||||
},
|
||||
configContents: []byte(dedent.Dedent(fmt.Sprintf(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
kubernetesVersion: %s
|
||||
`, constants.MinimumControlPlaneVersion))),
|
||||
@ -119,7 +119,7 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) {
|
||||
t.Fatalf("Failed writing a config file: %v", err)
|
||||
}
|
||||
|
||||
i, err := NewImagesList(configFilePath, &kubeadmapiv1beta2.ClusterConfiguration{
|
||||
i, err := NewImagesList(configFilePath, &kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
})
|
||||
if err != nil {
|
||||
@ -146,21 +146,21 @@ func TestImagesListRunWithCustomConfigPath(t *testing.T) {
|
||||
func TestConfigImagesListRunWithoutPath(t *testing.T) {
|
||||
testcases := []struct {
|
||||
name string
|
||||
cfg kubeadmapiv1beta2.ClusterConfiguration
|
||||
cfg kubeadmapiv1.ClusterConfiguration
|
||||
expectedImages int
|
||||
}{
|
||||
{
|
||||
name: "empty config",
|
||||
expectedImages: defaultNumberOfImages,
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "external etcd configuration",
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
Etcd: kubeadmapiv1beta2.Etcd{
|
||||
External: &kubeadmapiv1beta2.ExternalEtcd{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
Etcd: kubeadmapiv1.Etcd{
|
||||
External: &kubeadmapiv1.ExternalEtcd{
|
||||
Endpoints: []string{"https://some.etcd.com:2379"},
|
||||
},
|
||||
},
|
||||
@ -170,7 +170,7 @@ func TestConfigImagesListRunWithoutPath(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "coredns enabled",
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
},
|
||||
expectedImages: defaultNumberOfImages,
|
||||
@ -223,13 +223,13 @@ func TestConfigImagesListOutput(t *testing.T) {
|
||||
|
||||
testcases := []struct {
|
||||
name string
|
||||
cfg kubeadmapiv1beta2.ClusterConfiguration
|
||||
cfg kubeadmapiv1.ClusterConfiguration
|
||||
outputFormat string
|
||||
expectedOutput string
|
||||
}{
|
||||
{
|
||||
name: "text output",
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
},
|
||||
outputFormat: "text",
|
||||
@ -244,7 +244,7 @@ k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
|
||||
},
|
||||
{
|
||||
name: "JSON output",
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
},
|
||||
outputFormat: "json",
|
||||
@ -265,7 +265,7 @@ k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
|
||||
},
|
||||
{
|
||||
name: "YAML output",
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
},
|
||||
outputFormat: "yaml",
|
||||
@ -283,7 +283,7 @@ kind: Images
|
||||
},
|
||||
{
|
||||
name: "go-template output",
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
},
|
||||
outputFormat: `go-template={{range .images}}{{.}}{{"\n"}}{{end}}`,
|
||||
@ -298,7 +298,7 @@ k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
|
||||
},
|
||||
{
|
||||
name: "JSONPATH output",
|
||||
cfg: kubeadmapiv1beta2.ClusterConfiguration{
|
||||
cfg: kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: dummyKubernetesVersionStr,
|
||||
},
|
||||
outputFormat: `jsonpath={range.images[*]}{@} {end}`,
|
||||
@ -384,7 +384,7 @@ func TestImagesPull(t *testing.T) {
|
||||
func TestMigrate(t *testing.T) {
|
||||
cfg := []byte(dedent.Dedent(`
|
||||
# This is intentionally testing an old API version. Sometimes this may be the latest version (if no old configs are supported).
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: InitConfiguration
|
||||
`))
|
||||
configFile, cleanup := tempConfig(t, cfg)
|
||||
|
@ -31,7 +31,7 @@ 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"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
phases "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/init"
|
||||
@ -99,8 +99,8 @@ type initOptions struct {
|
||||
featureGatesString string
|
||||
ignorePreflightErrors []string
|
||||
bto *options.BootstrapTokenOptions
|
||||
externalInitCfg *kubeadmapiv1beta2.InitConfiguration
|
||||
externalClusterCfg *kubeadmapiv1beta2.ClusterConfiguration
|
||||
externalInitCfg *kubeadmapiv1.InitConfiguration
|
||||
externalClusterCfg *kubeadmapiv1.ClusterConfiguration
|
||||
uploadCerts bool
|
||||
skipCertificateKeyPrint bool
|
||||
patchesDir string
|
||||
@ -204,7 +204,7 @@ func newCmdInit(out io.Writer, initOptions *initOptions) *cobra.Command {
|
||||
}
|
||||
|
||||
// AddInitConfigFlags adds init flags bound to the config to the specified flagset
|
||||
func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta2.InitConfiguration) {
|
||||
func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1.InitConfiguration) {
|
||||
flagSet.StringVar(
|
||||
&cfg.LocalAPIEndpoint.AdvertiseAddress, options.APIServerAdvertiseAddress, cfg.LocalAPIEndpoint.AdvertiseAddress,
|
||||
"The IP address the API Server will advertise it's listening on. If not set the default network interface will be used.",
|
||||
@ -225,7 +225,7 @@ func AddInitConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta2.InitConfig
|
||||
}
|
||||
|
||||
// AddClusterConfigFlags adds cluster flags bound to the config to the specified flagset
|
||||
func AddClusterConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta2.ClusterConfiguration, featureGatesString *string) {
|
||||
func AddClusterConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1.ClusterConfiguration, featureGatesString *string) {
|
||||
flagSet.StringVar(
|
||||
&cfg.Networking.ServiceSubnet, options.NetworkingServiceSubnet, cfg.Networking.ServiceSubnet,
|
||||
"Use alternative range of IP address for service VIPs.",
|
||||
@ -287,10 +287,10 @@ func AddInitOtherFlags(flagSet *flag.FlagSet, initOptions *initOptions) {
|
||||
// newInitOptions returns a struct ready for being used for creating cmd init flags.
|
||||
func newInitOptions() *initOptions {
|
||||
// initialize the public kubeadm config API by applying defaults
|
||||
externalInitCfg := &kubeadmapiv1beta2.InitConfiguration{}
|
||||
externalInitCfg := &kubeadmapiv1.InitConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(externalInitCfg)
|
||||
|
||||
externalClusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{}
|
||||
externalClusterCfg := &kubeadmapiv1.ClusterConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(externalClusterCfg)
|
||||
|
||||
// Create the options object for the bootstrap token-related flags, and override the default value for .Description
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
|
||||
const (
|
||||
testInitConfig = `---
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: InitConfiguration
|
||||
localAPIEndpoint:
|
||||
advertiseAddress: "1.2.3.4"
|
||||
@ -41,7 +41,7 @@ nodeRegistration:
|
||||
- c
|
||||
- d
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
controlPlaneEndpoint: "3.4.5.6"
|
||||
`
|
||||
|
@ -34,7 +34,7 @@ import (
|
||||
"k8s.io/klog/v2"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
phases "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/join"
|
||||
@ -127,8 +127,8 @@ type joinOptions struct {
|
||||
token string `datapolicy:"token"`
|
||||
controlPlane bool
|
||||
ignorePreflightErrors []string
|
||||
externalcfg *kubeadmapiv1beta2.JoinConfiguration
|
||||
joinControlPlane *kubeadmapiv1beta2.JoinControlPlane
|
||||
externalcfg *kubeadmapiv1.JoinConfiguration
|
||||
joinControlPlane *kubeadmapiv1.JoinControlPlane
|
||||
patchesDir string
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ func newCmdJoin(out io.Writer, joinOptions *joinOptions) *cobra.Command {
|
||||
}
|
||||
|
||||
// addJoinConfigFlags adds join flags bound to the config to the specified flagset
|
||||
func addJoinConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1beta2.JoinConfiguration, jcp *kubeadmapiv1beta2.JoinControlPlane) {
|
||||
func addJoinConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1.JoinConfiguration, jcp *kubeadmapiv1.JoinControlPlane) {
|
||||
flagSet.StringVar(
|
||||
&cfg.NodeRegistration.Name, options.NodeName, cfg.NodeRegistration.Name,
|
||||
`Specify the node name.`,
|
||||
@ -291,20 +291,20 @@ func addJoinOtherFlags(flagSet *flag.FlagSet, joinOptions *joinOptions) {
|
||||
// newJoinOptions returns a struct ready for being used for creating cmd join flags.
|
||||
func newJoinOptions() *joinOptions {
|
||||
// initialize the public kubeadm config API by applying defaults
|
||||
externalcfg := &kubeadmapiv1beta2.JoinConfiguration{}
|
||||
externalcfg := &kubeadmapiv1.JoinConfiguration{}
|
||||
|
||||
// Add optional config objects to host flags.
|
||||
// un-set objects will be cleaned up afterwards (into newJoinData func)
|
||||
externalcfg.Discovery.File = &kubeadmapiv1beta2.FileDiscovery{}
|
||||
externalcfg.Discovery.BootstrapToken = &kubeadmapiv1beta2.BootstrapTokenDiscovery{}
|
||||
externalcfg.ControlPlane = &kubeadmapiv1beta2.JoinControlPlane{}
|
||||
externalcfg.Discovery.File = &kubeadmapiv1.FileDiscovery{}
|
||||
externalcfg.Discovery.BootstrapToken = &kubeadmapiv1.BootstrapTokenDiscovery{}
|
||||
externalcfg.ControlPlane = &kubeadmapiv1.JoinControlPlane{}
|
||||
|
||||
// This object is used for storage of control-plane flags.
|
||||
joinControlPlane := &kubeadmapiv1beta2.JoinControlPlane{}
|
||||
joinControlPlane := &kubeadmapiv1.JoinControlPlane{}
|
||||
|
||||
// Apply defaults
|
||||
kubeadmscheme.Scheme.Default(externalcfg)
|
||||
kubeadmapiv1beta2.SetDefaults_JoinControlPlane(joinControlPlane)
|
||||
kubeadmapiv1.SetDefaults_JoinControlPlane(joinControlPlane)
|
||||
|
||||
return &joinOptions{
|
||||
externalcfg: externalcfg,
|
||||
@ -360,8 +360,8 @@ func newJoinData(cmd *cobra.Command, args []string, opt *joinOptions, out io.Wri
|
||||
if !opt.controlPlane {
|
||||
// Use a defaulted JoinControlPlane object to detect if the user has passed
|
||||
// other control-plane related flags.
|
||||
defaultJCP := &kubeadmapiv1beta2.JoinControlPlane{}
|
||||
kubeadmapiv1beta2.SetDefaults_JoinControlPlane(defaultJCP)
|
||||
defaultJCP := &kubeadmapiv1.JoinControlPlane{}
|
||||
kubeadmapiv1.SetDefaults_JoinControlPlane(defaultJCP)
|
||||
|
||||
// This list must match the JCP flags in addJoinConfigFlags()
|
||||
joinControlPlaneFlags := []string{
|
||||
@ -405,7 +405,7 @@ func newJoinData(cmd *cobra.Command, args []string, opt *joinOptions, out io.Wri
|
||||
return nil, errors.Errorf("File %s does not exists. Please use 'kubeadm join phase control-plane-prepare' subcommands to generate it.", adminKubeConfigPath)
|
||||
}
|
||||
klog.V(1).Infof("[preflight] found discovery flags missing for this command. using FileDiscovery: %s", adminKubeConfigPath)
|
||||
opt.externalcfg.Discovery.File = &kubeadmapiv1beta2.FileDiscovery{KubeConfigPath: adminKubeConfigPath}
|
||||
opt.externalcfg.Discovery.File = &kubeadmapiv1.FileDiscovery{KubeConfigPath: adminKubeConfigPath}
|
||||
opt.externalcfg.Discovery.BootstrapToken = nil //NB. this could be removed when we get better control on args (e.g. phases without discovery should have NoArgs )
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
testJoinConfig = `apiVersion: kubeadm.k8s.io/v1beta2
|
||||
testJoinConfig = `apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: JoinConfiguration
|
||||
discovery:
|
||||
bootstrapToken:
|
||||
|
@ -23,14 +23,14 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
bootstrapapi "k8s.io/cluster-bootstrap/token/api"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
|
||||
// NewBootstrapTokenOptions creates a new BootstrapTokenOptions object with the default values
|
||||
func NewBootstrapTokenOptions() *BootstrapTokenOptions {
|
||||
bto := &BootstrapTokenOptions{&kubeadmapiv1beta2.BootstrapToken{}, ""}
|
||||
kubeadmapiv1beta2.SetDefaults_BootstrapToken(bto.BootstrapToken)
|
||||
bto := &BootstrapTokenOptions{&kubeadmapiv1.BootstrapToken{}, ""}
|
||||
kubeadmapiv1.SetDefaults_BootstrapToken(bto.BootstrapToken)
|
||||
return bto
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ func NewBootstrapTokenOptions() *BootstrapTokenOptions {
|
||||
// and applying the parsed flags to a InitConfiguration object later at runtime
|
||||
// TODO: In the future, we might want to group the flags in a better way than adding them all individually like this
|
||||
type BootstrapTokenOptions struct {
|
||||
*kubeadmapiv1beta2.BootstrapToken
|
||||
*kubeadmapiv1.BootstrapToken
|
||||
TokenStr string `datapolicy:"token"`
|
||||
}
|
||||
|
||||
@ -89,16 +89,16 @@ func (bto *BootstrapTokenOptions) AddDescriptionFlag(fs *pflag.FlagSet) {
|
||||
|
||||
// ApplyTo applies the values set internally in the BootstrapTokenOptions object to a InitConfiguration object at runtime
|
||||
// If --token was specified in the CLI (as a string), it's parsed and validated before it's added to the BootstrapToken object.
|
||||
func (bto *BootstrapTokenOptions) ApplyTo(cfg *kubeadmapiv1beta2.InitConfiguration) error {
|
||||
func (bto *BootstrapTokenOptions) ApplyTo(cfg *kubeadmapiv1.InitConfiguration) error {
|
||||
if len(bto.TokenStr) > 0 {
|
||||
var err error
|
||||
bto.Token, err = kubeadmapiv1beta2.NewBootstrapTokenString(bto.TokenStr)
|
||||
bto.Token, err = kubeadmapiv1.NewBootstrapTokenString(bto.TokenStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Set the token specified by the flags as the first and only token to create in case --config is not specified
|
||||
cfg.BootstrapTokens = []kubeadmapiv1beta2.BootstrapToken{*bto.BootstrapToken}
|
||||
cfg.BootstrapTokens = []kubeadmapiv1.BootstrapToken{*bto.BootstrapToken}
|
||||
return nil
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
||||
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
||||
@ -156,7 +156,7 @@ func getSANDescription(certSpec *certsphase.KubeadmCert) string {
|
||||
//Defaulted config we will use to get SAN certs
|
||||
defaultConfig := cmdutil.DefaultInitConfiguration()
|
||||
// GetAPIServerAltNames errors without an AdvertiseAddress; this is as good as any.
|
||||
defaultConfig.LocalAPIEndpoint = kubeadmapiv1beta2.APIEndpoint{
|
||||
defaultConfig.LocalAPIEndpoint = kubeadmapiv1.APIEndpoint{
|
||||
AdvertiseAddress: "127.0.0.1",
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
@ -85,7 +85,7 @@ func runCleanupNode(c workflow.RunData) error {
|
||||
|
||||
// Remove contents from the config and pki directories
|
||||
klog.V(1).Infoln("[reset] Removing contents from the config and pki directories")
|
||||
if certsDir != kubeadmapiv1beta2.DefaultCertificatesDir {
|
||||
if certsDir != kubeadmapiv1.DefaultCertificatesDir {
|
||||
klog.Warningf("[reset] WARNING: Cleaning a non-default certificates directory: %q\n", certsDir)
|
||||
}
|
||||
resetConfigDir(kubeadmconstants.KubernetesDir, certsDir)
|
||||
|
@ -18,14 +18,14 @@ package phases
|
||||
|
||||
import (
|
||||
"k8s.io/component-base/version"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
)
|
||||
|
||||
// SetKubernetesVersion gets the current Kubeadm version and sets it as KubeadmVersion in the config,
|
||||
// unless it's already set to a value different from the default.
|
||||
func SetKubernetesVersion(cfg *kubeadmapiv1beta2.ClusterConfiguration) {
|
||||
func SetKubernetesVersion(cfg *kubeadmapiv1.ClusterConfiguration) {
|
||||
|
||||
if cfg.KubernetesVersion != kubeadmapiv1beta2.DefaultKubernetesVersion && cfg.KubernetesVersion != "" {
|
||||
if cfg.KubernetesVersion != kubeadmapiv1.DefaultKubernetesVersion && cfg.KubernetesVersion != "" {
|
||||
return
|
||||
}
|
||||
cfg.KubernetesVersion = version.Get().String()
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/component-base/version"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
)
|
||||
|
||||
func TestSetKubernetesVersion(t *testing.T) {
|
||||
@ -39,7 +39,7 @@ func TestSetKubernetesVersion(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "default version is processed",
|
||||
input: kubeadmapiv1beta2.DefaultKubernetesVersion,
|
||||
input: kubeadmapiv1.DefaultKubernetesVersion,
|
||||
output: ver,
|
||||
},
|
||||
{
|
||||
@ -51,7 +51,7 @@ func TestSetKubernetesVersion(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cfg := &kubeadmapiv1beta2.ClusterConfiguration{KubernetesVersion: test.input}
|
||||
cfg := &kubeadmapiv1.ClusterConfiguration{KubernetesVersion: test.input}
|
||||
SetKubernetesVersion(cfg)
|
||||
if cfg.KubernetesVersion != test.output {
|
||||
t.Fatalf("expected %q, got %q", test.output, cfg.KubernetesVersion)
|
||||
|
@ -27,7 +27,7 @@ import (
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/klog/v2"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
phases "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/reset"
|
||||
@ -81,7 +81,7 @@ type resetData struct {
|
||||
// newResetOptions returns a struct ready for being used for creating cmd join flags.
|
||||
func newResetOptions() *resetOptions {
|
||||
return &resetOptions{
|
||||
certificatesDir: kubeadmapiv1beta2.DefaultCertificatesDir,
|
||||
certificatesDir: kubeadmapiv1.DefaultCertificatesDir,
|
||||
forceReset: false,
|
||||
kubeconfigPath: kubeadmconstants.GetAdminKubeConfigPath(),
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import (
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||
outputapischeme "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/scheme"
|
||||
outputapiv1alpha1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/v1alpha1"
|
||||
@ -232,9 +233,9 @@ func newCmdTokenGenerate(out io.Writer) *cobra.Command {
|
||||
}
|
||||
|
||||
// RunCreateToken generates a new bootstrap token and stores it as a secret on the server.
|
||||
func RunCreateToken(out io.Writer, client clientset.Interface, cfgPath string, initCfg *kubeadmapiv1beta2.InitConfiguration, printJoinCommand bool, certificateKey string, kubeConfigFile string) error {
|
||||
func RunCreateToken(out io.Writer, client clientset.Interface, cfgPath string, initCfg *kubeadmapiv1.InitConfiguration, printJoinCommand bool, certificateKey string, kubeConfigFile string) error {
|
||||
// ClusterConfiguration is needed just for the call to LoadOrDefaultInitConfiguration
|
||||
clusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{
|
||||
clusterCfg := &kubeadmapiv1.ClusterConfiguration{
|
||||
// KubernetesVersion is not used, but we set this explicitly to avoid
|
||||
// the lookup of the version from the internet when executing LoadOrDefaultInitConfiguration
|
||||
KubernetesVersion: kubeadmconstants.CurrentKubernetesVersion.String(),
|
||||
@ -415,7 +416,7 @@ func RunDeleteTokens(out io.Writer, client clientset.Interface, tokenIDsOrTokens
|
||||
klog.V(1).Info("[token] parsing token")
|
||||
if !bootstraputil.IsValidBootstrapTokenID(tokenIDOrToken) {
|
||||
// Okay, the full token with both id and secret was probably passed. Parse it and extract the ID only
|
||||
bts, err := kubeadmapiv1beta2.NewBootstrapTokenString(tokenIDOrToken)
|
||||
bts, err := kubeadmapiv1.NewBootstrapTokenString(tokenIDOrToken)
|
||||
if err != nil {
|
||||
return errors.Errorf("given token didn't match pattern %q or %q",
|
||||
bootstrapapi.BootstrapTokenIDPattern, bootstrapapi.BootstrapTokenIDPattern)
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
core "k8s.io/client-go/testing"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
outputapischeme "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/scheme"
|
||||
outputapiv1alpha1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/output/v1alpha1"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/output"
|
||||
@ -156,13 +157,13 @@ func TestRunCreateToken(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
bts, err := kubeadmapiv1beta2.NewBootstrapTokenString(tc.token)
|
||||
bts, err := kubeadmapiv1.NewBootstrapTokenString(tc.token)
|
||||
if err != nil && len(tc.token) != 0 { // if tc.token is "" it's okay as it will be generated later at runtime
|
||||
t.Fatalf("token couldn't be parsed for testing: %v", err)
|
||||
}
|
||||
|
||||
cfg := &kubeadmapiv1beta2.InitConfiguration{
|
||||
BootstrapTokens: []kubeadmapiv1beta2.BootstrapToken{
|
||||
cfg := &kubeadmapiv1.InitConfiguration{
|
||||
BootstrapTokens: []kubeadmapiv1.BootstrapToken{
|
||||
{
|
||||
Token: bts,
|
||||
TTL: &metav1.Duration{Duration: 0},
|
||||
|
@ -91,7 +91,7 @@ func TestPrintConfiguration(t *testing.T) {
|
||||
},
|
||||
expectedBytes: []byte(`[upgrade/config] Configuration used:
|
||||
apiServer: {}
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
controllerManager: {}
|
||||
dns:
|
||||
type: CoreDNS
|
||||
@ -122,7 +122,7 @@ func TestPrintConfiguration(t *testing.T) {
|
||||
},
|
||||
expectedBytes: []byte(`[upgrade/config] Configuration used:
|
||||
apiServer: {}
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
controllerManager: {}
|
||||
dns:
|
||||
type: CoreDNS
|
||||
|
@ -43,7 +43,7 @@ func TestRunDiff(t *testing.T) {
|
||||
currentVersion := "v" + constants.CurrentKubernetesVersion.String()
|
||||
|
||||
// create a temporary file with valid ClusterConfiguration
|
||||
testUpgradeDiffConfigContents := []byte("apiVersion: kubeadm.k8s.io/v1beta2\n" +
|
||||
testUpgradeDiffConfigContents := []byte("apiVersion: kubeadm.k8s.io/v1beta3\n" +
|
||||
"kind: ClusterConfiguration\n" +
|
||||
"kubernetesVersion: " + currentVersion)
|
||||
testUpgradeDiffConfig, err := createTestRunDiffFile(testUpgradeDiffConfigContents)
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/klog/v2"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/options"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
@ -91,9 +91,9 @@ func AddCRISocketFlag(flagSet *pflag.FlagSet, criSocket *string) {
|
||||
|
||||
// DefaultInitConfiguration return default InitConfiguration. Avoid running the CRI auto-detection
|
||||
// code as we don't need it.
|
||||
func DefaultInitConfiguration() *kubeadmapiv1beta2.InitConfiguration {
|
||||
initCfg := &kubeadmapiv1beta2.InitConfiguration{
|
||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
||||
func DefaultInitConfiguration() *kubeadmapiv1.InitConfiguration {
|
||||
initCfg := &kubeadmapiv1.InitConfiguration{
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{
|
||||
CRISocket: kubeadmconstants.UnknownCRISocket, // avoid CRI detection
|
||||
},
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import (
|
||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
outputapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/output"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
@ -206,7 +206,7 @@ var (
|
||||
yaml: dedent.Dedent(`
|
||||
apiServer:
|
||||
timeoutForControlPlane: 4m
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
certificatesDir: /etc/kubernetes/pki
|
||||
clusterName: LeCluster
|
||||
controllerManager: {}
|
||||
@ -277,7 +277,7 @@ func TestConfigBaseMarshal(t *testing.T) {
|
||||
got := strings.TrimSpace(string(b))
|
||||
expected := strings.TrimSpace(dedent.Dedent(`
|
||||
apiServer: {}
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
clusterName: LeCluster
|
||||
controllerManager: {}
|
||||
dns:
|
||||
@ -327,7 +327,7 @@ func TestConfigBaseUnmarshal(t *testing.T) {
|
||||
func TestGeneratedConfigFromCluster(t *testing.T) {
|
||||
fakeKnownContext(func() {
|
||||
testYAML := dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
`)
|
||||
testYAMLHash := fmt.Sprintf("sha256:%x", sha256.Sum256([]byte(testYAML)))
|
||||
@ -406,7 +406,7 @@ func runClusterConfigFromTest(t *testing.T, perform func(t *testing.T, in string
|
||||
{
|
||||
name: "Unknown kind returns an error",
|
||||
in: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: Configuration
|
||||
`),
|
||||
expectErr: true,
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
@ -128,15 +128,15 @@ func (kc *kubeletConfig) Default(cfg *kubeadmapi.ClusterConfiguration, _ *kubead
|
||||
}
|
||||
|
||||
if kc.config.StaticPodPath == "" {
|
||||
kc.config.StaticPodPath = kubeadmapiv1beta2.DefaultManifestsDir
|
||||
} else if kc.config.StaticPodPath != kubeadmapiv1beta2.DefaultManifestsDir {
|
||||
warnDefaultComponentConfigValue(kind, "staticPodPath", kubeadmapiv1beta2.DefaultManifestsDir, kc.config.StaticPodPath)
|
||||
kc.config.StaticPodPath = kubeadmapiv1.DefaultManifestsDir
|
||||
} else if kc.config.StaticPodPath != kubeadmapiv1.DefaultManifestsDir {
|
||||
warnDefaultComponentConfigValue(kind, "staticPodPath", kubeadmapiv1.DefaultManifestsDir, kc.config.StaticPodPath)
|
||||
}
|
||||
|
||||
clusterDNS := ""
|
||||
dnsIP, err := constants.GetDNSIP(cfg.Networking.ServiceSubnet, features.Enabled(cfg.FeatureGates, features.IPv6DualStack))
|
||||
if err != nil {
|
||||
clusterDNS = kubeadmapiv1beta2.DefaultClusterDNSIP
|
||||
clusterDNS = kubeadmapiv1.DefaultClusterDNSIP
|
||||
} else {
|
||||
clusterDNS = dnsIP.String()
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import (
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
)
|
||||
@ -67,8 +67,8 @@ func TestKubeletDefault(t *testing.T) {
|
||||
expected: kubeletConfig{
|
||||
config: kubeletconfig.KubeletConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
ClusterDNS: []string{kubeadmapiv1beta2.DefaultClusterDNSIP},
|
||||
StaticPodPath: kubeadmapiv1.DefaultManifestsDir,
|
||||
ClusterDNS: []string{kubeadmapiv1.DefaultClusterDNSIP},
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
X509: kubeletconfig.KubeletX509Authentication{
|
||||
ClientCAFile: constants.CACertName,
|
||||
@ -100,7 +100,7 @@ func TestKubeletDefault(t *testing.T) {
|
||||
expected: kubeletConfig{
|
||||
config: kubeletconfig.KubeletConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
StaticPodPath: kubeadmapiv1.DefaultManifestsDir,
|
||||
ClusterDNS: []string{"192.168.0.10"},
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
X509: kubeletconfig.KubeletX509Authentication{
|
||||
@ -138,7 +138,7 @@ func TestKubeletDefault(t *testing.T) {
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: false,
|
||||
},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
StaticPodPath: kubeadmapiv1.DefaultManifestsDir,
|
||||
ClusterDNS: []string{"192.168.0.10"},
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
X509: kubeletconfig.KubeletX509Authentication{
|
||||
@ -176,7 +176,7 @@ func TestKubeletDefault(t *testing.T) {
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: true,
|
||||
},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
StaticPodPath: kubeadmapiv1.DefaultManifestsDir,
|
||||
ClusterDNS: []string{"192.168.0.10"},
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
X509: kubeletconfig.KubeletX509Authentication{
|
||||
@ -209,8 +209,8 @@ func TestKubeletDefault(t *testing.T) {
|
||||
expected: kubeletConfig{
|
||||
config: kubeletconfig.KubeletConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
ClusterDNS: []string{kubeadmapiv1beta2.DefaultClusterDNSIP},
|
||||
StaticPodPath: kubeadmapiv1.DefaultManifestsDir,
|
||||
ClusterDNS: []string{kubeadmapiv1.DefaultClusterDNSIP},
|
||||
ClusterDomain: "example.com",
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
X509: kubeletconfig.KubeletX509Authentication{
|
||||
@ -241,8 +241,8 @@ func TestKubeletDefault(t *testing.T) {
|
||||
expected: kubeletConfig{
|
||||
config: kubeletconfig.KubeletConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
StaticPodPath: kubeadmapiv1beta2.DefaultManifestsDir,
|
||||
ClusterDNS: []string{kubeadmapiv1beta2.DefaultClusterDNSIP},
|
||||
StaticPodPath: kubeadmapiv1.DefaultManifestsDir,
|
||||
ClusterDNS: []string{kubeadmapiv1.DefaultClusterDNSIP},
|
||||
Authentication: kubeletconfig.KubeletAuthentication{
|
||||
X509: kubeletconfig.KubeletX509Authentication{
|
||||
ClientCAFile: filepath.Join("/path/to/certs", constants.CACertName),
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
kubeproxyconfig "k8s.io/kube-proxy/config/v1alpha1"
|
||||
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
)
|
||||
@ -78,9 +78,9 @@ func (kp *kubeProxyConfig) Unmarshal(docmap kubeadmapi.DocumentMap) error {
|
||||
func kubeProxyDefaultBindAddress(localAdvertiseAddress string) string {
|
||||
ip := net.ParseIP(localAdvertiseAddress)
|
||||
if ip.To4() != nil {
|
||||
return kubeadmapiv1beta2.DefaultProxyBindAddressv4
|
||||
return kubeadmapiv1.DefaultProxyBindAddressv4
|
||||
}
|
||||
return kubeadmapiv1beta2.DefaultProxyBindAddressv6
|
||||
return kubeadmapiv1.DefaultProxyBindAddressv6
|
||||
}
|
||||
|
||||
func (kp *kubeProxyConfig) Get() interface{} {
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/features"
|
||||
)
|
||||
@ -62,7 +62,7 @@ func TestKubeProxyDefault(t *testing.T) {
|
||||
expected: kubeProxyConfig{
|
||||
config: kubeproxyconfig.KubeProxyConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
BindAddress: kubeadmapiv1beta2.DefaultProxyBindAddressv6,
|
||||
BindAddress: kubeadmapiv1.DefaultProxyBindAddressv6,
|
||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||
Kubeconfig: kubeproxyKubeConfigFileName,
|
||||
},
|
||||
@ -78,7 +78,7 @@ func TestKubeProxyDefault(t *testing.T) {
|
||||
expected: kubeProxyConfig{
|
||||
config: kubeproxyconfig.KubeProxyConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
BindAddress: kubeadmapiv1beta2.DefaultProxyBindAddressv4,
|
||||
BindAddress: kubeadmapiv1.DefaultProxyBindAddressv4,
|
||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||
Kubeconfig: kubeproxyKubeConfigFileName,
|
||||
},
|
||||
@ -96,7 +96,7 @@ func TestKubeProxyDefault(t *testing.T) {
|
||||
expected: kubeProxyConfig{
|
||||
config: kubeproxyconfig.KubeProxyConfiguration{
|
||||
FeatureGates: map[string]bool{},
|
||||
BindAddress: kubeadmapiv1beta2.DefaultProxyBindAddressv6,
|
||||
BindAddress: kubeadmapiv1.DefaultProxyBindAddressv6,
|
||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||
Kubeconfig: kubeproxyKubeConfigFileName,
|
||||
},
|
||||
@ -117,7 +117,7 @@ func TestKubeProxyDefault(t *testing.T) {
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: true,
|
||||
},
|
||||
BindAddress: kubeadmapiv1beta2.DefaultProxyBindAddressv6,
|
||||
BindAddress: kubeadmapiv1.DefaultProxyBindAddressv6,
|
||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||
Kubeconfig: kubeproxyKubeConfigFileName,
|
||||
},
|
||||
@ -137,7 +137,7 @@ func TestKubeProxyDefault(t *testing.T) {
|
||||
FeatureGates: map[string]bool{
|
||||
features.IPv6DualStack: false,
|
||||
},
|
||||
BindAddress: kubeadmapiv1beta2.DefaultProxyBindAddressv6,
|
||||
BindAddress: kubeadmapiv1.DefaultProxyBindAddressv6,
|
||||
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
|
||||
Kubeconfig: kubeproxyKubeConfigFileName,
|
||||
},
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
"k8s.io/klog/v2"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/discovery/file"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/discovery/https"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/discovery/token"
|
||||
@ -53,7 +53,7 @@ func For(cfg *kubeadmapi.JoinConfiguration) (*clientcmdapi.Config, error) {
|
||||
clusterinfo := kubeconfigutil.GetClusterFromKubeConfig(config)
|
||||
return kubeconfigutil.CreateWithToken(
|
||||
clusterinfo.Server,
|
||||
kubeadmapiv1beta2.DefaultClusterName,
|
||||
kubeadmapiv1.DefaultClusterName,
|
||||
TokenUser,
|
||||
clusterinfo.CertificateAuthorityData,
|
||||
cfg.Discovery.TLSBootstrapToken,
|
||||
@ -75,9 +75,9 @@ func DiscoverValidatedKubeConfig(cfg *kubeadmapi.JoinConfiguration) (*clientcmda
|
||||
case cfg.Discovery.File != nil:
|
||||
kubeConfigPath := cfg.Discovery.File.KubeConfigPath
|
||||
if isHTTPSURL(kubeConfigPath) {
|
||||
return https.RetrieveValidatedConfigInfo(kubeConfigPath, kubeadmapiv1beta2.DefaultClusterName, cfg.Discovery.Timeout.Duration)
|
||||
return https.RetrieveValidatedConfigInfo(kubeConfigPath, kubeadmapiv1.DefaultClusterName, cfg.Discovery.Timeout.Duration)
|
||||
}
|
||||
return file.RetrieveValidatedConfigInfo(kubeConfigPath, kubeadmapiv1beta2.DefaultClusterName, cfg.Discovery.Timeout.Duration)
|
||||
return file.RetrieveValidatedConfigInfo(kubeConfigPath, kubeadmapiv1.DefaultClusterName, cfg.Discovery.Timeout.Duration)
|
||||
case cfg.Discovery.BootstrapToken != nil:
|
||||
return token.RetrieveValidatedConfigInfo(&cfg.Discovery)
|
||||
default:
|
||||
|
@ -35,7 +35,7 @@ import (
|
||||
bootstrap "k8s.io/cluster-bootstrap/token/jws"
|
||||
"k8s.io/klog/v2"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/pubkeypin"
|
||||
@ -72,7 +72,7 @@ func retrieveValidatedConfigInfo(client clientset.Interface, cfg *kubeadmapi.Dis
|
||||
}
|
||||
|
||||
endpoint := cfg.BootstrapToken.APIServerEndpoint
|
||||
insecureBootstrapConfig := buildInsecureBootstrapKubeConfig(endpoint, kubeadmapiv1beta2.DefaultClusterName)
|
||||
insecureBootstrapConfig := buildInsecureBootstrapKubeConfig(endpoint, kubeadmapiv1.DefaultClusterName)
|
||||
clusterName := insecureBootstrapConfig.Contexts[insecureBootstrapConfig.CurrentContext].Cluster
|
||||
|
||||
klog.V(1).Infof("[discovery] Created cluster-info discovery client, requesting info from %q", endpoint)
|
||||
|
@ -55,7 +55,7 @@ const (
|
||||
waitForPodsWithLabel = "wait-for-pods-with-label"
|
||||
|
||||
testConfiguration = `
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: InitConfiguration
|
||||
nodeRegistration:
|
||||
name: foo
|
||||
@ -67,7 +67,7 @@ bootstrapTokens:
|
||||
- token: ce3aa5.5ec8455bb76b379f
|
||||
ttl: 24h
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
|
||||
apiServer:
|
||||
|
@ -46,15 +46,6 @@ var k8sVersionString = kubeadmconstants.MinimumControlPlaneVersion.String()
|
||||
var k8sVersion = version.MustParseGeneric(k8sVersionString)
|
||||
var nodeName = "mynode"
|
||||
var cfgFiles = map[string][]byte{
|
||||
"InitConfiguration_v1beta1": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: InitConfiguration
|
||||
`),
|
||||
"ClusterConfiguration_v1beta1": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
kind: ClusterConfiguration
|
||||
kubernetesVersion: ` + k8sVersionString + `
|
||||
`),
|
||||
"InitConfiguration_v1beta2": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: InitConfiguration
|
||||
@ -63,6 +54,15 @@ kind: InitConfiguration
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
kubernetesVersion: ` + k8sVersionString + `
|
||||
`),
|
||||
"InitConfiguration_v1beta3": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: InitConfiguration
|
||||
`),
|
||||
"ClusterConfiguration_v1beta3": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
kubernetesVersion: ` + k8sVersionString + `
|
||||
`),
|
||||
"Kube-proxy_componentconfig": []byte(`
|
||||
apiVersion: kubeproxy.config.k8s.io/v1alpha1
|
||||
@ -541,83 +541,6 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
||||
},
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
name: "valid v1beta1 - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
||||
staticPods: []testresources.FakeStaticPod{
|
||||
{
|
||||
NodeName: nodeName,
|
||||
Component: kubeadmconstants.KubeAPIServer,
|
||||
Annotations: map[string]string{
|
||||
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
||||
},
|
||||
},
|
||||
},
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
{
|
||||
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta1"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileContents: kubeletConfFiles["configWithEmbeddedCert"],
|
||||
node: &v1.Node{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: nodeName,
|
||||
Annotations: map[string]string{
|
||||
kubeadmconstants.AnnotationKubeadmCRISocket: "myCRIsocket",
|
||||
},
|
||||
},
|
||||
Spec: v1.NodeSpec{
|
||||
Taints: []v1.Taint{kubeadmconstants.OldControlPlaneTaint},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid v1beta1 - new control plane == true", // InitConfiguration composed with data from different places, without node specific information
|
||||
staticPods: []testresources.FakeStaticPod{
|
||||
{
|
||||
NodeName: nodeName,
|
||||
Component: kubeadmconstants.KubeAPIServer,
|
||||
Annotations: map[string]string{
|
||||
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
||||
},
|
||||
},
|
||||
},
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
{
|
||||
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta1"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
newControlPlane: true,
|
||||
},
|
||||
{
|
||||
name: "valid v1beta2 - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
||||
staticPods: []testresources.FakeStaticPod{
|
||||
@ -695,6 +618,83 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
||||
},
|
||||
newControlPlane: true,
|
||||
},
|
||||
{
|
||||
name: "valid v1beta3 - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
||||
staticPods: []testresources.FakeStaticPod{
|
||||
{
|
||||
NodeName: nodeName,
|
||||
Component: kubeadmconstants.KubeAPIServer,
|
||||
Annotations: map[string]string{
|
||||
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
||||
},
|
||||
},
|
||||
},
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
{
|
||||
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta3"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileContents: kubeletConfFiles["configWithEmbeddedCert"],
|
||||
node: &v1.Node{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: nodeName,
|
||||
Annotations: map[string]string{
|
||||
kubeadmconstants.AnnotationKubeadmCRISocket: "myCRIsocket",
|
||||
},
|
||||
},
|
||||
Spec: v1.NodeSpec{
|
||||
Taints: []v1.Taint{kubeadmconstants.OldControlPlaneTaint},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid v1beta3 - new control plane == true", // InitConfiguration composed with data from different places, without node specific information
|
||||
staticPods: []testresources.FakeStaticPod{
|
||||
{
|
||||
NodeName: nodeName,
|
||||
Component: kubeadmconstants.KubeAPIServer,
|
||||
Annotations: map[string]string{
|
||||
kubeadmconstants.KubeAPIServerAdvertiseAddressEndpointAnnotationKey: "1.2.3.4:1234",
|
||||
},
|
||||
},
|
||||
},
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
{
|
||||
Name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1beta3"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.KubeProxyConfigMap, // Kube-proxy component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeProxyConfigMapKey: string(cfgFiles["Kube-proxy_componentconfig"]),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: kubeadmconstants.GetKubeletConfigMapName(k8sVersion), // Kubelet component config from corresponding ConfigMap.
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.KubeletBaseConfigurationConfigMapKey: string(cfgFiles["Kubelet_componentconfig"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
newControlPlane: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, rt := range tests {
|
||||
@ -773,17 +773,6 @@ func TestGetGetClusterStatus(t *testing.T) {
|
||||
{
|
||||
name: "invalid missing config map",
|
||||
},
|
||||
{
|
||||
name: "valid v1beta1",
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
{
|
||||
Name: kubeadmconstants.KubeadmConfigConfigMap,
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1beta1"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid v1beta2",
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
@ -795,6 +784,17 @@ func TestGetGetClusterStatus(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "valid v1beta3",
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
{
|
||||
Name: kubeadmconstants.KubeadmConfigConfigMap,
|
||||
Data: map[string]string{
|
||||
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1beta3"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid missing ClusterStatusConfigMapKey in the config map",
|
||||
configMaps: []testresources.FakeConfigMap{
|
||||
|
@ -31,7 +31,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/version"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
)
|
||||
@ -40,9 +40,9 @@ import (
|
||||
func MarshalKubeadmConfigObject(obj runtime.Object) ([]byte, error) {
|
||||
switch internalcfg := obj.(type) {
|
||||
case *kubeadmapi.InitConfiguration:
|
||||
return MarshalInitConfigurationToBytes(internalcfg, kubeadmapiv1beta2.SchemeGroupVersion)
|
||||
return MarshalInitConfigurationToBytes(internalcfg, kubeadmapiv1.SchemeGroupVersion)
|
||||
default:
|
||||
return kubeadmutil.MarshalToYamlForCodecs(obj, kubeadmapiv1beta2.SchemeGroupVersion, kubeadmscheme.Codecs)
|
||||
return kubeadmutil.MarshalToYamlForCodecs(obj, kubeadmapiv1.SchemeGroupVersion, kubeadmscheme.Codecs)
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,16 +56,16 @@ func validateSupportedVersion(gv schema.GroupVersion, allowDeprecated bool) erro
|
||||
// v1.13: v1alpha3 read-only, writes only v1beta1 config. Errors if the user tries to use v1alpha1 or v1alpha2
|
||||
// v1.14: v1alpha3 convert only, writes only v1beta1 config. Errors if the user tries to use v1alpha1 or v1alpha2
|
||||
// v1.15: v1beta1 read-only, writes only v1beta2 config. Errors if the user tries to use v1alpha1, v1alpha2 or v1alpha3
|
||||
// v1.22: v1beta2 read-only, writes only v1beta3 config. Errors if the user tries to use v1beta1 and older
|
||||
oldKnownAPIVersions := map[string]string{
|
||||
"kubeadm.k8s.io/v1alpha1": "v1.11",
|
||||
"kubeadm.k8s.io/v1alpha2": "v1.12",
|
||||
"kubeadm.k8s.io/v1alpha3": "v1.14",
|
||||
"kubeadm.k8s.io/v1beta1": "v1.15",
|
||||
}
|
||||
|
||||
// Deprecated API versions are supported by us, but can only be used for migration.
|
||||
deprecatedAPIVersions := map[string]struct{}{
|
||||
"kubeadm.k8s.io/v1beta1": {},
|
||||
}
|
||||
deprecatedAPIVersions := map[string]struct{}{}
|
||||
|
||||
gvString := gv.String()
|
||||
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/lithammer/dedent"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
)
|
||||
@ -57,26 +57,12 @@ func TestValidateSupportedVersion(t *testing.T) {
|
||||
},
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
gv: schema.GroupVersion{
|
||||
Group: KubeadmGroupName,
|
||||
Version: "v1alpha3",
|
||||
},
|
||||
allowDeprecated: true,
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
gv: schema.GroupVersion{
|
||||
Group: KubeadmGroupName,
|
||||
Version: "v1beta1",
|
||||
},
|
||||
allowDeprecated: true,
|
||||
},
|
||||
{
|
||||
gv: schema.GroupVersion{
|
||||
Group: KubeadmGroupName,
|
||||
Version: "v1beta1",
|
||||
},
|
||||
expectedErr: true,
|
||||
},
|
||||
{
|
||||
gv: schema.GroupVersion{
|
||||
@ -84,6 +70,12 @@ func TestValidateSupportedVersion(t *testing.T) {
|
||||
Version: "v1beta2",
|
||||
},
|
||||
},
|
||||
{
|
||||
gv: schema.GroupVersion{
|
||||
Group: KubeadmGroupName,
|
||||
Version: "v1beta3",
|
||||
},
|
||||
},
|
||||
{
|
||||
gv: schema.GroupVersion{
|
||||
Group: "foo.k8s.io",
|
||||
@ -132,8 +124,8 @@ func TestLowercaseSANs(t *testing.T) {
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cfg := &kubeadmapiv1beta2.ClusterConfiguration{
|
||||
APIServer: kubeadmapiv1beta2.APIServer{
|
||||
cfg := &kubeadmapiv1.ClusterConfiguration{
|
||||
APIServer: kubeadmapiv1.APIServer{
|
||||
CertSANs: test.in,
|
||||
},
|
||||
}
|
||||
@ -218,14 +210,14 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "bad config produces error",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
`),
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
desc: "InitConfiguration only gets migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: InitConfiguration
|
||||
`),
|
||||
expectedKinds: []string{
|
||||
@ -237,7 +229,7 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "ClusterConfiguration only gets migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
`),
|
||||
expectedKinds: []string{
|
||||
@ -249,7 +241,7 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "JoinConfiguration only gets migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: JoinConfiguration
|
||||
discovery:
|
||||
bootstrapToken:
|
||||
@ -265,10 +257,10 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "Init + Cluster Configurations are migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: InitConfiguration
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
`),
|
||||
expectedKinds: []string{
|
||||
@ -280,10 +272,10 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "Init + Join Configurations are migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: InitConfiguration
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: JoinConfiguration
|
||||
discovery:
|
||||
bootstrapToken:
|
||||
@ -301,10 +293,10 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "Cluster + Join Configurations are migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: JoinConfiguration
|
||||
discovery:
|
||||
bootstrapToken:
|
||||
@ -322,13 +314,13 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "Init + Cluster + Join Configurations are migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: InitConfiguration
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: JoinConfiguration
|
||||
discovery:
|
||||
bootstrapToken:
|
||||
@ -346,13 +338,13 @@ func TestMigrateOldConfigFromFile(t *testing.T) {
|
||||
{
|
||||
desc: "component configs are not migrated",
|
||||
oldCfg: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: InitConfiguration
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: ClusterConfiguration
|
||||
---
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: JoinConfiguration
|
||||
discovery:
|
||||
bootstrapToken:
|
||||
|
@ -33,9 +33,10 @@ import (
|
||||
bootstraputil "k8s.io/cluster-bootstrap/token/util"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/config/strict"
|
||||
@ -44,8 +45,8 @@ import (
|
||||
|
||||
var (
|
||||
// PlaceholderToken is only set statically to make kubeadm not randomize the token on every run
|
||||
PlaceholderToken = kubeadmapiv1beta2.BootstrapToken{
|
||||
Token: &kubeadmapiv1beta2.BootstrapTokenString{
|
||||
PlaceholderToken = kubeadmapiv1.BootstrapToken{
|
||||
Token: &kubeadmapiv1.BootstrapTokenString{
|
||||
ID: "abcdef",
|
||||
Secret: "0123456789abcdef",
|
||||
},
|
||||
@ -181,16 +182,16 @@ func SetClusterDynamicDefaults(cfg *kubeadmapi.ClusterConfiguration, localAPIEnd
|
||||
|
||||
// DefaultedStaticInitConfiguration returns the internal InitConfiguration with static defaults.
|
||||
func DefaultedStaticInitConfiguration() (*kubeadmapi.InitConfiguration, error) {
|
||||
versionedInitCfg := &kubeadmapiv1beta2.InitConfiguration{
|
||||
LocalAPIEndpoint: kubeadmapiv1beta2.APIEndpoint{AdvertiseAddress: "1.2.3.4"},
|
||||
BootstrapTokens: []kubeadmapiv1beta2.BootstrapToken{PlaceholderToken},
|
||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
||||
versionedInitCfg := &kubeadmapiv1.InitConfiguration{
|
||||
LocalAPIEndpoint: kubeadmapiv1.APIEndpoint{AdvertiseAddress: "1.2.3.4"},
|
||||
BootstrapTokens: []kubeadmapiv1.BootstrapToken{PlaceholderToken},
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{
|
||||
CRISocket: kubeadmconstants.DefaultDockerCRISocket, // avoid CRI detection
|
||||
Name: "node",
|
||||
},
|
||||
}
|
||||
versionedClusterCfg := &kubeadmapiv1beta2.ClusterConfiguration{
|
||||
KubernetesVersion: kubeadmconstants.CurrentKubernetesVersion.String(), // avoid going to the Internet for the current Kubernetes version
|
||||
versionedClusterCfg := &kubeadmapiv1.ClusterConfiguration{
|
||||
KubernetesVersion: constants.CurrentKubernetesVersion.String(), // avoid going to the Internet for the current Kubernetes version
|
||||
}
|
||||
|
||||
internalcfg := &kubeadmapi.InitConfiguration{}
|
||||
@ -214,7 +215,7 @@ func DefaultedStaticInitConfiguration() (*kubeadmapi.InitConfiguration, error) {
|
||||
}
|
||||
|
||||
// DefaultedInitConfiguration takes a versioned init config (often populated by flags), defaults it and converts it into internal InitConfiguration
|
||||
func DefaultedInitConfiguration(versionedInitCfg *kubeadmapiv1beta2.InitConfiguration, versionedClusterCfg *kubeadmapiv1beta2.ClusterConfiguration) (*kubeadmapi.InitConfiguration, error) {
|
||||
func DefaultedInitConfiguration(versionedInitCfg *kubeadmapiv1.InitConfiguration, versionedClusterCfg *kubeadmapiv1.ClusterConfiguration) (*kubeadmapi.InitConfiguration, error) {
|
||||
internalcfg := &kubeadmapi.InitConfiguration{}
|
||||
|
||||
// Takes passed flags into account; the defaulting is executed once again enforcing assignment of
|
||||
@ -257,7 +258,7 @@ func LoadInitConfigurationFromFile(cfgPath string) (*kubeadmapi.InitConfiguratio
|
||||
// The external, versioned configuration is defaulted and converted to the internal type.
|
||||
// Right thereafter, the configuration is defaulted again with dynamic values (like IP addresses of a machine, etc)
|
||||
// Lastly, the internal config is validated and returned.
|
||||
func LoadOrDefaultInitConfiguration(cfgPath string, versionedInitCfg *kubeadmapiv1beta2.InitConfiguration, versionedClusterCfg *kubeadmapiv1beta2.ClusterConfiguration) (*kubeadmapi.InitConfiguration, error) {
|
||||
func LoadOrDefaultInitConfiguration(cfgPath string, versionedInitCfg *kubeadmapiv1.InitConfiguration, versionedClusterCfg *kubeadmapiv1.ClusterConfiguration) (*kubeadmapi.InitConfiguration, error) {
|
||||
if cfgPath != "" {
|
||||
// Loads configuration from config file, if provided
|
||||
// Nb. --config overrides command line flags
|
||||
@ -328,7 +329,7 @@ func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat
|
||||
|
||||
// If InitConfiguration wasn't given, default it by creating an external struct instance, default it and convert into the internal type
|
||||
if initcfg == nil {
|
||||
extinitcfg := &kubeadmapiv1beta2.InitConfiguration{}
|
||||
extinitcfg := &kubeadmapiv1.InitConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(extinitcfg)
|
||||
// Set initcfg to an empty struct value the deserializer will populate
|
||||
initcfg = &kubeadmapi.InitConfiguration{}
|
||||
|
@ -23,9 +23,9 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
@ -44,23 +44,6 @@ func TestLoadInitConfigurationFromFile(t *testing.T) {
|
||||
fileContents []byte
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
name: "v1beta1.partial1",
|
||||
fileContents: cfgFiles["InitConfiguration_v1beta1"],
|
||||
},
|
||||
{
|
||||
name: "v1beta1.partial2",
|
||||
fileContents: cfgFiles["ClusterConfiguration_v1beta1"],
|
||||
},
|
||||
{
|
||||
name: "v1beta1.full",
|
||||
fileContents: bytes.Join([][]byte{
|
||||
cfgFiles["InitConfiguration_v1beta1"],
|
||||
cfgFiles["ClusterConfiguration_v1beta1"],
|
||||
cfgFiles["Kube-proxy_componentconfig"],
|
||||
cfgFiles["Kubelet_componentconfig"],
|
||||
}, []byte(constants.YAMLDocumentSeparator)),
|
||||
},
|
||||
{
|
||||
name: "v1beta2.partial1",
|
||||
fileContents: cfgFiles["InitConfiguration_v1beta2"],
|
||||
@ -78,6 +61,23 @@ func TestLoadInitConfigurationFromFile(t *testing.T) {
|
||||
cfgFiles["Kubelet_componentconfig"],
|
||||
}, []byte(constants.YAMLDocumentSeparator)),
|
||||
},
|
||||
{
|
||||
name: "v1beta3.partial1",
|
||||
fileContents: cfgFiles["InitConfiguration_v1beta3"],
|
||||
},
|
||||
{
|
||||
name: "v1beta3.partial2",
|
||||
fileContents: cfgFiles["ClusterConfiguration_v1beta3"],
|
||||
},
|
||||
{
|
||||
name: "v1beta3.full",
|
||||
fileContents: bytes.Join([][]byte{
|
||||
cfgFiles["InitConfiguration_v1beta3"],
|
||||
cfgFiles["ClusterConfiguration_v1beta3"],
|
||||
cfgFiles["Kube-proxy_componentconfig"],
|
||||
cfgFiles["Kubelet_componentconfig"],
|
||||
}, []byte(constants.YAMLDocumentSeparator)),
|
||||
},
|
||||
}
|
||||
|
||||
for _, rt := range tests {
|
||||
@ -111,14 +111,14 @@ func TestLoadInitConfigurationFromFile(t *testing.T) {
|
||||
func TestDefaultTaintsMarshaling(t *testing.T) {
|
||||
tests := []struct {
|
||||
desc string
|
||||
cfg kubeadmapiv1beta2.InitConfiguration
|
||||
cfg kubeadmapiv1.InitConfiguration
|
||||
expectedTaintCnt int
|
||||
}{
|
||||
{
|
||||
desc: "Uninitialized nodeRegistration field produces a single taint (the master one)",
|
||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
||||
cfg: kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
||||
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||
Kind: constants.InitConfigurationKind,
|
||||
},
|
||||
},
|
||||
@ -126,23 +126,23 @@ func TestDefaultTaintsMarshaling(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "Uninitialized taints field produces a single taint (the master one)",
|
||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
||||
cfg: kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
||||
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||
Kind: constants.InitConfigurationKind,
|
||||
},
|
||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{},
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{},
|
||||
},
|
||||
expectedTaintCnt: 1,
|
||||
},
|
||||
{
|
||||
desc: "Forsing taints to an empty slice produces no taints",
|
||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
||||
cfg: kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
||||
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||
Kind: constants.InitConfigurationKind,
|
||||
},
|
||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{
|
||||
Taints: []v1.Taint{},
|
||||
},
|
||||
},
|
||||
@ -150,12 +150,12 @@ func TestDefaultTaintsMarshaling(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "Custom taints are used",
|
||||
cfg: kubeadmapiv1beta2.InitConfiguration{
|
||||
cfg: kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "kubeadm.k8s.io/v1beta2",
|
||||
APIVersion: "kubeadm.k8s.io/v1beta3",
|
||||
Kind: constants.InitConfigurationKind,
|
||||
},
|
||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{
|
||||
Taints: []v1.Taint{
|
||||
{Key: "taint1"},
|
||||
{Key: "taint2"},
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"k8s.io/klog/v2"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||
@ -59,7 +59,7 @@ func SetJoinControlPlaneDefaults(cfg *kubeadmapi.JoinControlPlane) error {
|
||||
// Then the external, versioned configuration is defaulted and converted to the internal type.
|
||||
// Right thereafter, the configuration is defaulted again with dynamic values (like IP addresses of a machine, etc)
|
||||
// Lastly, the internal config is validated and returned.
|
||||
func LoadOrDefaultJoinConfiguration(cfgPath string, defaultversionedcfg *kubeadmapiv1beta2.JoinConfiguration) (*kubeadmapi.JoinConfiguration, error) {
|
||||
func LoadOrDefaultJoinConfiguration(cfgPath string, defaultversionedcfg *kubeadmapiv1.JoinConfiguration) (*kubeadmapi.JoinConfiguration, error) {
|
||||
if cfgPath != "" {
|
||||
// Loads configuration from config file, if provided
|
||||
// Nb. --config overrides command line flags, TODO: fix this
|
||||
@ -129,7 +129,7 @@ func documentMapToJoinConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat
|
||||
}
|
||||
|
||||
// DefaultedJoinConfiguration takes a versioned JoinConfiguration (usually filled in by command line parameters), defaults it, converts it to internal and validates it
|
||||
func DefaultedJoinConfiguration(defaultversionedcfg *kubeadmapiv1beta2.JoinConfiguration) (*kubeadmapi.JoinConfiguration, error) {
|
||||
func DefaultedJoinConfiguration(defaultversionedcfg *kubeadmapiv1.JoinConfiguration) (*kubeadmapi.JoinConfiguration, error) {
|
||||
internalcfg := &kubeadmapi.JoinConfiguration{}
|
||||
|
||||
// Takes passed flags into account; the defaulting is executed once again enforcing assignment of
|
||||
|
@ -44,17 +44,17 @@ func TestLoadJoinConfigurationFromFile(t *testing.T) {
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "Invalid v1beta1 causes error",
|
||||
name: "Invalid v1beta2 causes error",
|
||||
fileContents: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: JoinConfiguration
|
||||
`),
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "valid v1beta1 is loaded",
|
||||
name: "valid v1beta2 is loaded",
|
||||
fileContents: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta1
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
kind: JoinConfiguration
|
||||
caCertPath: /etc/kubernetes/pki/ca.crt
|
||||
discovery:
|
||||
@ -67,17 +67,17 @@ func TestLoadJoinConfigurationFromFile(t *testing.T) {
|
||||
`),
|
||||
},
|
||||
{
|
||||
name: "Invalid v1beta2 causes error",
|
||||
name: "Invalid v1beta3 causes error",
|
||||
fileContents: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: JoinConfiguration
|
||||
`),
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "valid v1beta2 is loaded",
|
||||
name: "valid v1beta3 is loaded",
|
||||
fileContents: dedent.Dedent(`
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: JoinConfiguration
|
||||
caCertPath: /etc/kubernetes/pki/ca.crt
|
||||
discovery:
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
kubeproxyconfigv1alpha1 "k8s.io/kube-proxy/config/v1alpha1"
|
||||
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
|
||||
@ -43,13 +43,13 @@ func TestVerifyUnmarshalStrict(t *testing.T) {
|
||||
{
|
||||
fileName: "invalid_duplicate_field_clustercfg.yaml",
|
||||
kind: constants.InitConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
fileName: "invalid_duplicate_field_joincfg.yaml",
|
||||
kind: constants.JoinConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
@ -67,19 +67,19 @@ func TestVerifyUnmarshalStrict(t *testing.T) {
|
||||
{
|
||||
fileName: "invalid_unknown_field_clustercfg.yaml",
|
||||
kind: constants.ClusterConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
fileName: "invalid_unknown_field_initcfg.yaml",
|
||||
kind: constants.InitConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
fileName: "invalid_unknown_field_joincfg.yaml",
|
||||
kind: constants.JoinConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: true,
|
||||
},
|
||||
{
|
||||
@ -104,26 +104,26 @@ func TestVerifyUnmarshalStrict(t *testing.T) {
|
||||
{
|
||||
fileName: "valid_clustercfg.yaml",
|
||||
kind: "SomeUnknownKind",
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: true,
|
||||
},
|
||||
// valid tests
|
||||
{
|
||||
fileName: "valid_clustercfg.yaml",
|
||||
kind: constants.ClusterConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
fileName: "valid_initcfg.yaml",
|
||||
kind: constants.InitConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
fileName: "valid_joincfg.yaml",
|
||||
kind: constants.JoinConfigurationKind,
|
||||
groupVersion: kubeadmapiv1beta2.SchemeGroupVersion,
|
||||
groupVersion: kubeadmapiv1.SchemeGroupVersion,
|
||||
expectedError: false,
|
||||
},
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||
kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||
)
|
||||
|
||||
@ -110,44 +110,44 @@ func TestMarshalUnmarshalYaml(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMarshalUnmarshalToYamlForCodecs(t *testing.T) {
|
||||
cfg := &kubeadmapiv1beta2.InitConfiguration{
|
||||
cfg := &kubeadmapiv1.InitConfiguration{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: constants.InitConfigurationKind,
|
||||
APIVersion: kubeadmapiv1beta2.SchemeGroupVersion.String(),
|
||||
APIVersion: kubeadmapiv1.SchemeGroupVersion.String(),
|
||||
},
|
||||
NodeRegistration: kubeadmapiv1beta2.NodeRegistrationOptions{
|
||||
NodeRegistration: kubeadmapiv1.NodeRegistrationOptions{
|
||||
Name: "testNode",
|
||||
CRISocket: "/var/run/cri.sock",
|
||||
},
|
||||
BootstrapTokens: []kubeadmapiv1beta2.BootstrapToken{
|
||||
BootstrapTokens: []kubeadmapiv1.BootstrapToken{
|
||||
{
|
||||
Token: &kubeadmapiv1beta2.BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"},
|
||||
Token: &kubeadmapiv1.BootstrapTokenString{ID: "abcdef", Secret: "abcdef0123456789"},
|
||||
},
|
||||
},
|
||||
// NOTE: Using MarshalToYamlForCodecs and UnmarshalFromYamlForCodecs for ClusterConfiguration fields here won't work
|
||||
// by design. This is because we have a `json:"-"` annotation in order to avoid struct duplication. See the comment
|
||||
// at the kubeadmapiv1beta2.InitConfiguration definition.
|
||||
// at the kubeadmapiv1.InitConfiguration definition.
|
||||
}
|
||||
|
||||
kubeadmapiv1beta2.SetDefaults_InitConfiguration(cfg)
|
||||
kubeadmapiv1.SetDefaults_InitConfiguration(cfg)
|
||||
scheme := runtime.NewScheme()
|
||||
if err := kubeadmapiv1beta2.AddToScheme(scheme); err != nil {
|
||||
if err := kubeadmapiv1.AddToScheme(scheme); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
codecs := serializer.NewCodecFactory(scheme)
|
||||
|
||||
bytes, err := MarshalToYamlForCodecs(cfg, kubeadmapiv1beta2.SchemeGroupVersion, codecs)
|
||||
bytes, err := MarshalToYamlForCodecs(cfg, kubeadmapiv1.SchemeGroupVersion, codecs)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error marshalling InitConfiguration: %v", err)
|
||||
}
|
||||
t.Logf("\n%s", bytes)
|
||||
|
||||
obj, err := UnmarshalFromYamlForCodecs(bytes, kubeadmapiv1beta2.SchemeGroupVersion, codecs)
|
||||
obj, err := UnmarshalFromYamlForCodecs(bytes, kubeadmapiv1.SchemeGroupVersion, codecs)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error unmarshalling InitConfiguration: %v", err)
|
||||
}
|
||||
|
||||
cfg2, ok := obj.(*kubeadmapiv1beta2.InitConfiguration)
|
||||
cfg2, ok := obj.(*kubeadmapiv1.InitConfiguration)
|
||||
if !ok || cfg2 == nil {
|
||||
t.Fatal("did not get InitConfiguration back")
|
||||
}
|
||||
|
@ -137,28 +137,13 @@ func TestCmdInitConfig(t *testing.T) {
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "can't load old v1alpha1 config",
|
||||
args: "--config=testdata/init/v1alpha1.yaml",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "can't load old v1alpha2 config",
|
||||
args: "--config=testdata/init/v1alpha2.yaml",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "can't load old v1alpha3 config",
|
||||
args: "--config=testdata/init/v1alpha3.yaml",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "can load v1beta1 config",
|
||||
name: "can't load v1beta1 config",
|
||||
args: "--config=testdata/init/v1beta1.yaml",
|
||||
expected: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "don't allow mixed arguments v1beta1",
|
||||
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta1.yaml",
|
||||
name: "don't allow mixed arguments v1beta2",
|
||||
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta2.yaml",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
@ -167,8 +152,13 @@ func TestCmdInitConfig(t *testing.T) {
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "don't allow mixed arguments v1beta2",
|
||||
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta2.yaml",
|
||||
name: "can load v1beta3 config",
|
||||
args: "--config=testdata/init/v1beta3.yaml",
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "don't allow mixed arguments v1beta3",
|
||||
args: "--kubernetes-version=1.11.0 --config=testdata/init/v1beta3.yaml",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
---
|
||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||
|
@ -1,4 +1,4 @@
|
||||
apiVersion: kubeadm.k8s.io/v1beta2
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: ClusterConfiguration
|
||||
---
|
||||
apiVersion: kubelet.config.k8s.io/v1alpha1
|
||||
|
@ -1,2 +0,0 @@
|
||||
apiVersion: kubeadm.k8s.io/v1alpha1
|
||||
kind: MasterConfiguration
|
@ -1,2 +0,0 @@
|
||||
apiVersion: kubeadm.k8s.io/v1alpha2
|
||||
kind: MasterConfiguration
|
@ -1,2 +0,0 @@
|
||||
apiVersion: kubeadm.k8s.io/v1alpha3
|
||||
kind: InitConfiguration
|
2
cmd/kubeadm/test/cmd/testdata/init/v1beta3.yaml
vendored
Normal file
2
cmd/kubeadm/test/cmd/testdata/init/v1beta3.yaml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
apiVersion: kubeadm.k8s.io/v1beta3
|
||||
kind: InitConfiguration
|
Loading…
Reference in New Issue
Block a user