mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Automated rename from NodeConfiguration to JoinConfiguration
This commit is contained in:
parent
16c5ba4114
commit
a6b0410f83
@ -98,7 +98,7 @@ func Funcs(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
componentconfigs.Scheme.Convert(extkubeproxyconfig, obj.ComponentConfigs.KubeProxy, nil)
|
||||
componentconfigs.DefaultKubeProxyConfiguration(obj)
|
||||
},
|
||||
func(obj *kubeadm.NodeConfiguration, c fuzz.Continue) {
|
||||
func(obj *kubeadm.JoinConfiguration, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(obj)
|
||||
obj.CACertPath = "foo"
|
||||
obj.DiscoveryFile = "foo"
|
||||
|
@ -47,7 +47,7 @@ func Resource(resource string) schema.GroupResource {
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&InitConfiguration{},
|
||||
&NodeConfiguration{},
|
||||
&JoinConfiguration{},
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
@ -253,9 +253,9 @@ type ExternalEtcd struct {
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// NodeConfiguration contains elements describing a particular node.
|
||||
// JoinConfiguration contains elements describing a particular node.
|
||||
// TODO: This struct should be replaced by dynamic kubelet configuration.
|
||||
type NodeConfiguration struct {
|
||||
type JoinConfiguration struct {
|
||||
metav1.TypeMeta
|
||||
|
||||
// NodeRegistration holds fields that relate to registering the new master node to the cluster
|
||||
@ -344,7 +344,7 @@ type AuditPolicyConfiguration struct {
|
||||
}
|
||||
|
||||
// CommonConfiguration defines the list of common configuration elements and the getter
|
||||
// methods that must exist for both the InitConfiguration and NodeConfiguration objects.
|
||||
// methods that must exist for both the InitConfiguration and JoinConfiguration objects.
|
||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
||||
type CommonConfiguration interface {
|
||||
GetCRISocket() string
|
||||
@ -370,22 +370,22 @@ func (cfg *InitConfiguration) GetKubernetesVersion() string {
|
||||
return cfg.KubernetesVersion
|
||||
}
|
||||
|
||||
// GetCRISocket will return the CRISocket that is defined for the NodeConfiguration.
|
||||
// GetCRISocket will return the CRISocket that is defined for the JoinConfiguration.
|
||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
||||
func (cfg *NodeConfiguration) GetCRISocket() string {
|
||||
func (cfg *JoinConfiguration) GetCRISocket() string {
|
||||
return cfg.NodeRegistration.CRISocket
|
||||
}
|
||||
|
||||
// GetNodeName will return the NodeName that is defined for the NodeConfiguration.
|
||||
// GetNodeName will return the NodeName that is defined for the JoinConfiguration.
|
||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
||||
func (cfg *NodeConfiguration) GetNodeName() string {
|
||||
func (cfg *JoinConfiguration) GetNodeName() string {
|
||||
return cfg.NodeRegistration.Name
|
||||
}
|
||||
|
||||
// GetKubernetesVersion will return an empty string since KubernetesVersion is not a
|
||||
// defined property for NodeConfiguration. This will just cause the regex validation
|
||||
// defined property for JoinConfiguration. This will just cause the regex validation
|
||||
// of the defined version to be skipped during the preflight checks.
|
||||
// This is used internally to deduplicate the kubeadm preflight checks.
|
||||
func (cfg *NodeConfiguration) GetKubernetesVersion() string {
|
||||
func (cfg *JoinConfiguration) GetKubernetesVersion() string {
|
||||
return ""
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ const (
|
||||
// KubeproxyKubeConfigFileName defines the file name for the kube-proxy's KubeConfig file
|
||||
KubeproxyKubeConfigFileName = "/var/lib/kube-proxy/kubeconfig.conf"
|
||||
|
||||
// DefaultDiscoveryTimeout specifies the default discovery timeout for kubeadm (used unless one is specified in the NodeConfiguration)
|
||||
// DefaultDiscoveryTimeout specifies the default discovery timeout for kubeadm (used unless one is specified in the JoinConfiguration)
|
||||
DefaultDiscoveryTimeout = 5 * time.Minute
|
||||
)
|
||||
|
||||
@ -143,8 +143,8 @@ func SetDefaults_ProxyConfiguration(obj *InitConfiguration) {
|
||||
kubeproxyscheme.Scheme.Default(obj.KubeProxy.Config)
|
||||
}
|
||||
|
||||
// SetDefaults_NodeConfiguration assigns default values to a regular node
|
||||
func SetDefaults_NodeConfiguration(obj *NodeConfiguration) {
|
||||
// SetDefaults_JoinConfiguration assigns default values to a regular node
|
||||
func SetDefaults_JoinConfiguration(obj *JoinConfiguration) {
|
||||
if obj.CACertPath == "" {
|
||||
obj.CACertPath = DefaultCACertPath
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func Resource(resource string) schema.GroupResource {
|
||||
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&NodeConfiguration{},
|
||||
&JoinConfiguration{},
|
||||
)
|
||||
scheme.AddKnownTypeWithName(SchemeGroupVersion.WithKind("MasterConfiguration"), &InitConfiguration{})
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
|
@ -229,9 +229,9 @@ type ExternalEtcd struct {
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// NodeConfiguration contains elements describing a particular node.
|
||||
// JoinConfiguration contains elements describing a particular node.
|
||||
// TODO: This struct should be replaced by dynamic kubelet configuration.
|
||||
type NodeConfiguration struct {
|
||||
type JoinConfiguration struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// NodeRegistration holds fields that relate to registering the new master node to the cluster
|
||||
|
@ -53,7 +53,7 @@ const (
|
||||
DefaultProxyBindAddressv4 = "0.0.0.0"
|
||||
// DefaultProxyBindAddressv6 is the default bind address when the advertise address is v6
|
||||
DefaultProxyBindAddressv6 = "::"
|
||||
// DefaultDiscoveryTimeout specifies the default discovery timeout for kubeadm (used unless one is specified in the NodeConfiguration)
|
||||
// DefaultDiscoveryTimeout specifies the default discovery timeout for kubeadm (used unless one is specified in the JoinConfiguration)
|
||||
DefaultDiscoveryTimeout = 5 * time.Minute
|
||||
)
|
||||
|
||||
@ -115,8 +115,8 @@ func SetDefaults_Etcd(obj *InitConfiguration) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetDefaults_NodeConfiguration assigns default values to a regular node
|
||||
func SetDefaults_NodeConfiguration(obj *NodeConfiguration) {
|
||||
// SetDefaults_JoinConfiguration assigns default values to a regular node
|
||||
func SetDefaults_JoinConfiguration(obj *JoinConfiguration) {
|
||||
if obj.CACertPath == "" {
|
||||
obj.CACertPath = DefaultCACertPath
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func Resource(resource string) schema.GroupResource {
|
||||
func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
scheme.AddKnownTypes(SchemeGroupVersion,
|
||||
&InitConfiguration{},
|
||||
&NodeConfiguration{},
|
||||
&JoinConfiguration{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
|
@ -223,9 +223,9 @@ type ExternalEtcd struct {
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// NodeConfiguration contains elements describing a particular node.
|
||||
// JoinConfiguration contains elements describing a particular node.
|
||||
// TODO: This struct should be replaced by dynamic kubelet configuration.
|
||||
type NodeConfiguration struct {
|
||||
type JoinConfiguration struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
|
||||
// NodeRegistration holds fields that relate to registering the new master node to the cluster
|
||||
|
@ -55,8 +55,8 @@ func ValidateInitConfiguration(c *kubeadm.InitConfiguration) field.ErrorList {
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateNodeConfiguration validates node configuration and collects all encountered errors
|
||||
func ValidateNodeConfiguration(c *kubeadm.NodeConfiguration) field.ErrorList {
|
||||
// ValidateJoinConfiguration validates node configuration and collects all encountered errors
|
||||
func ValidateJoinConfiguration(c *kubeadm.JoinConfiguration) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, ValidateDiscovery(c)...)
|
||||
allErrs = append(allErrs, ValidateNodeRegistrationOptions(&c.NodeRegistration, field.NewPath("nodeRegistration"))...)
|
||||
@ -81,7 +81,7 @@ func ValidateNodeRegistrationOptions(nro *kubeadm.NodeRegistrationOptions, fldPa
|
||||
}
|
||||
|
||||
// ValidateDiscovery validates discovery related configuration and collects all encountered errors
|
||||
func ValidateDiscovery(c *kubeadm.NodeConfiguration) field.ErrorList {
|
||||
func ValidateDiscovery(c *kubeadm.JoinConfiguration) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if len(c.DiscoveryToken) != 0 {
|
||||
allErrs = append(allErrs, ValidateToken(c.DiscoveryToken, field.NewPath("discoveryToken"))...)
|
||||
@ -97,7 +97,7 @@ func ValidateDiscovery(c *kubeadm.NodeConfiguration) field.ErrorList {
|
||||
}
|
||||
|
||||
// ValidateArgSelection validates discovery related configuration and collects all encountered errors
|
||||
func ValidateArgSelection(cfg *kubeadm.NodeConfiguration, fldPath *field.Path) field.ErrorList {
|
||||
func ValidateArgSelection(cfg *kubeadm.JoinConfiguration, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if len(cfg.DiscoveryToken) != 0 && len(cfg.DiscoveryFile) != 0 {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath, "", "discoveryToken and discoveryFile cannot both be set"))
|
||||
|
@ -33,17 +33,17 @@ import (
|
||||
|
||||
func TestValidateToken(t *testing.T) {
|
||||
var tests = []struct {
|
||||
c *kubeadm.NodeConfiguration
|
||||
c *kubeadm.JoinConfiguration
|
||||
f *field.Path
|
||||
expected bool
|
||||
}{
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, true},
|
||||
{&kubeadm.NodeConfiguration{Token: ".6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, false},
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, false},
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"2001:db8::100:6443"}}, nil, true},
|
||||
{&kubeadm.NodeConfiguration{Token: ".6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"2001:db8::100:6443"}}, nil, false},
|
||||
{&kubeadm.NodeConfiguration{Token: "772ef5.", DiscoveryTokenAPIServers: []string{"2001:db8::100:6443"}}, nil, false},
|
||||
{&kubeadm.NodeConfiguration{Token: "abcdef.1234567890123456@foobar", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, false},
|
||||
{&kubeadm.JoinConfiguration{Token: "772ef5.6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, true},
|
||||
{&kubeadm.JoinConfiguration{Token: ".6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, false},
|
||||
{&kubeadm.JoinConfiguration{Token: "772ef5.", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, false},
|
||||
{&kubeadm.JoinConfiguration{Token: "772ef5.6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"2001:db8::100:6443"}}, nil, true},
|
||||
{&kubeadm.JoinConfiguration{Token: ".6b6baab1d4a0a171", DiscoveryTokenAPIServers: []string{"2001:db8::100:6443"}}, nil, false},
|
||||
{&kubeadm.JoinConfiguration{Token: "772ef5.", DiscoveryTokenAPIServers: []string{"2001:db8::100:6443"}}, nil, false},
|
||||
{&kubeadm.JoinConfiguration{Token: "abcdef.1234567890123456@foobar", DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"}}, nil, false},
|
||||
}
|
||||
for _, rt := range tests {
|
||||
err := ValidateToken(rt.c.Token, rt.f).ToAggregate()
|
||||
@ -557,23 +557,23 @@ func TestValidateInitConfiguration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateNodeConfiguration(t *testing.T) {
|
||||
func TestValidateJoinConfiguration(t *testing.T) {
|
||||
var tests = []struct {
|
||||
s *kubeadm.NodeConfiguration
|
||||
s *kubeadm.JoinConfiguration
|
||||
expected bool
|
||||
}{
|
||||
{&kubeadm.NodeConfiguration{}, false},
|
||||
{&kubeadm.NodeConfiguration{
|
||||
{&kubeadm.JoinConfiguration{}, false},
|
||||
{&kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "foo",
|
||||
DiscoveryToken: "abcdef.1234567890123456@foobar",
|
||||
CACertPath: "/some/cert.crt",
|
||||
}, false},
|
||||
}
|
||||
for _, rt := range tests {
|
||||
actual := ValidateNodeConfiguration(rt.s)
|
||||
actual := ValidateJoinConfiguration(rt.s)
|
||||
if (len(actual) == 0) != rt.expected {
|
||||
t.Errorf(
|
||||
"failed ValidateNodeConfiguration:\n\texpected: %t\n\t actual: %t",
|
||||
"failed ValidateJoinConfiguration:\n\texpected: %t\n\t actual: %t",
|
||||
rt.expected,
|
||||
(len(actual) == 0),
|
||||
)
|
||||
@ -679,12 +679,12 @@ func TestValidateIgnorePreflightErrors(t *testing.T) {
|
||||
func TestValidateArgSelection(t *testing.T) {
|
||||
var tests = []struct {
|
||||
name string
|
||||
c *kubeadm.NodeConfiguration
|
||||
c *kubeadm.JoinConfiguration
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
"invalid: DiscoveryToken and DiscoveryFile cannot both be set",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "https://url/file.conf",
|
||||
DiscoveryToken: "abcdef.1234567890123456",
|
||||
},
|
||||
@ -692,7 +692,7 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"invalid: DiscoveryToken or DiscoveryFile must be set",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "",
|
||||
DiscoveryToken: "",
|
||||
},
|
||||
@ -700,14 +700,14 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"invalid: DiscoveryTokenAPIServers not set",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryToken: "abcdef.1234567890123456",
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid: DiscoveryTokenCACertHashes cannot be used with DiscoveryFile",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "https://url/file.conf",
|
||||
DiscoveryTokenCACertHashes: []string{"sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
|
||||
},
|
||||
@ -715,7 +715,7 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"invalid: using token-based discovery without DiscoveryTokenCACertHashes and DiscoveryTokenUnsafeSkipCAVerification",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryToken: "abcdef.1234567890123456",
|
||||
DiscoveryTokenUnsafeSkipCAVerification: false,
|
||||
DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"},
|
||||
@ -724,7 +724,7 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"WARNING: kubeadm doesn't fully support multiple API Servers yet",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryToken: "abcdef.1234567890123456",
|
||||
DiscoveryTokenUnsafeSkipCAVerification: true,
|
||||
DiscoveryTokenAPIServers: []string{"192.168.122.100:6443", "192.168.122.88:6443"},
|
||||
@ -733,7 +733,7 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"valid: DiscoveryFile with DiscoveryTokenAPIServers",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "https://url/file.conf",
|
||||
DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"},
|
||||
},
|
||||
@ -741,14 +741,14 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"valid: DiscoveryFile without DiscoveryTokenAPIServers",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "https://url/file.conf",
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"valid: using token-based discovery with DiscoveryTokenCACertHashes",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryToken: "abcdef.1234567890123456",
|
||||
DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"},
|
||||
DiscoveryTokenCACertHashes: []string{"sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
|
||||
@ -758,7 +758,7 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"valid: using token-based discovery with DiscoveryTokenCACertHashe but skip ca verification",
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryToken: "abcdef.1234567890123456",
|
||||
DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"},
|
||||
DiscoveryTokenCACertHashes: []string{"sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"},
|
||||
@ -782,17 +782,17 @@ func TestValidateArgSelection(t *testing.T) {
|
||||
|
||||
func TestValidateJoinDiscoveryTokenAPIServer(t *testing.T) {
|
||||
var tests = []struct {
|
||||
s *kubeadm.NodeConfiguration
|
||||
s *kubeadm.JoinConfiguration
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryTokenAPIServers: []string{"192.168.122.100"},
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
&kubeadm.NodeConfiguration{
|
||||
&kubeadm.JoinConfiguration{
|
||||
DiscoveryTokenAPIServers: []string{"192.168.122.100:6443"},
|
||||
},
|
||||
true,
|
||||
|
@ -96,7 +96,7 @@ func NewCmdConfigPrintDefault(out io.Writer) *cobra.Command {
|
||||
Short: "Print the default values for a kubeadm configuration object.",
|
||||
Long: fmt.Sprintf(dedent.Dedent(`
|
||||
This command prints the default InitConfiguration object that is used for 'kubeadm init' and 'kubeadm upgrade',
|
||||
and the default NodeConfiguration object that is used for 'kubeadm join'.
|
||||
and the default JoinConfiguration object that is used for 'kubeadm join'.
|
||||
|
||||
Note that sensitive values like the Bootstrap Token fields are replaced with silly values like %q in order to pass validation but
|
||||
not perform the real computation for creating a token.
|
||||
@ -124,7 +124,7 @@ func getDefaultAPIObjectBytes(apiObject string) ([]byte, error) {
|
||||
case constants.InitConfigurationKind, constants.MasterConfigurationKind:
|
||||
return getDefaultInitConfigBytes()
|
||||
|
||||
case constants.NodeConfigurationKind:
|
||||
case constants.JoinConfigurationKind:
|
||||
return getDefaultNodeConfigBytes()
|
||||
|
||||
default:
|
||||
@ -139,7 +139,7 @@ func getDefaultAPIObjectBytes(apiObject string) ([]byte, error) {
|
||||
|
||||
// getSupportedAPIObjects returns all currently supported API object names
|
||||
func getSupportedAPIObjects() []string {
|
||||
objects := []string{constants.InitConfigurationKind, constants.NodeConfigurationKind}
|
||||
objects := []string{constants.InitConfigurationKind, constants.JoinConfigurationKind}
|
||||
for componentType := range componentconfigs.Known {
|
||||
objects = append(objects, string(componentType))
|
||||
}
|
||||
@ -172,7 +172,7 @@ func getDefaultInitConfigBytes() ([]byte, error) {
|
||||
}
|
||||
|
||||
func getDefaultNodeConfigBytes() ([]byte, error) {
|
||||
internalcfg, err := configutil.NodeConfigFileAndDefaultsToInternalConfig("", &kubeadmapiv1alpha3.NodeConfiguration{
|
||||
internalcfg, err := configutil.NodeConfigFileAndDefaultsToInternalConfig("", &kubeadmapiv1alpha3.JoinConfiguration{
|
||||
Token: sillyToken.Token.String(),
|
||||
DiscoveryTokenAPIServers: []string{"kube-apiserver:6443"},
|
||||
DiscoveryTokenUnsafeSkipCAVerification: true, // TODO: DiscoveryTokenUnsafeSkipCAVerification: true needs to be set for validation to pass, but shouldn't be recommended as the default
|
||||
|
@ -117,7 +117,7 @@ var (
|
||||
|
||||
// NewCmdJoin returns "kubeadm join" command.
|
||||
func NewCmdJoin(out io.Writer) *cobra.Command {
|
||||
cfg := &kubeadmapiv1alpha3.NodeConfiguration{}
|
||||
cfg := &kubeadmapiv1alpha3.JoinConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(cfg)
|
||||
|
||||
var skipPreFlight bool
|
||||
@ -143,7 +143,7 @@ func NewCmdJoin(out io.Writer) *cobra.Command {
|
||||
}
|
||||
|
||||
// NewValidJoin validates the command line that are passed to the cobra command
|
||||
func NewValidJoin(flagSet *flag.FlagSet, cfg *kubeadmapiv1alpha3.NodeConfiguration, args []string, skipPreFlight bool, cfgPath, featureGatesString string, ignorePreflightErrors []string) (*Join, error) {
|
||||
func NewValidJoin(flagSet *flag.FlagSet, cfg *kubeadmapiv1alpha3.JoinConfiguration, args []string, skipPreFlight bool, cfgPath, featureGatesString string, ignorePreflightErrors []string) (*Join, error) {
|
||||
cfg.DiscoveryTokenAPIServers = args
|
||||
|
||||
var err error
|
||||
@ -164,7 +164,7 @@ func NewValidJoin(flagSet *flag.FlagSet, cfg *kubeadmapiv1alpha3.NodeConfigurati
|
||||
}
|
||||
|
||||
// AddJoinConfigFlags adds join flags bound to the config to the specified flagset
|
||||
func AddJoinConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1alpha3.NodeConfiguration, featureGatesString *string) {
|
||||
func AddJoinConfigFlags(flagSet *flag.FlagSet, cfg *kubeadmapiv1alpha3.JoinConfiguration, featureGatesString *string) {
|
||||
flagSet.StringVar(
|
||||
&cfg.DiscoveryFile, "discovery-file", "",
|
||||
"A file or url from which to load cluster information.")
|
||||
@ -215,12 +215,12 @@ func AddJoinOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipPreFlight *bo
|
||||
|
||||
// Join defines struct used by kubeadm join command
|
||||
type Join struct {
|
||||
cfg *kubeadmapi.NodeConfiguration
|
||||
cfg *kubeadmapi.JoinConfiguration
|
||||
ignorePreflightErrors sets.String
|
||||
}
|
||||
|
||||
// NewJoin instantiates Join struct with given arguments
|
||||
func NewJoin(cfgPath string, args []string, defaultcfg *kubeadmapiv1alpha3.NodeConfiguration, ignorePreflightErrors sets.String) (*Join, error) {
|
||||
func NewJoin(cfgPath string, args []string, defaultcfg *kubeadmapiv1alpha3.JoinConfiguration, ignorePreflightErrors sets.String) (*Join, error) {
|
||||
|
||||
if defaultcfg.NodeRegistration.Name == "" {
|
||||
glog.V(1).Infoln("[join] found NodeName empty")
|
||||
|
@ -79,7 +79,7 @@ func TestNewValidJoin(t *testing.T) {
|
||||
testJoinValidate bool
|
||||
testJoinRun bool
|
||||
cmdPersistentFlags map[string]string
|
||||
nodeConfig *kubeadm.NodeConfiguration
|
||||
nodeConfig *kubeadm.JoinConfiguration
|
||||
expectedError bool
|
||||
}{
|
||||
{
|
||||
@ -146,7 +146,7 @@ func TestNewValidJoin(t *testing.T) {
|
||||
}
|
||||
|
||||
var out bytes.Buffer
|
||||
cfg := &kubeadmapiv1alpha3.NodeConfiguration{}
|
||||
cfg := &kubeadmapiv1alpha3.JoinConfiguration{}
|
||||
kubeadmscheme.Scheme.Default(cfg)
|
||||
|
||||
errorFormat := "Test case %q: NewValidJoin expected error: %v, saw: %v, error: %v"
|
||||
|
@ -39,7 +39,7 @@ import (
|
||||
var (
|
||||
kubeletWriteEnvFileLongDesc = normalizer.LongDesc(`
|
||||
Writes an environment file with flags that should be passed to the kubelet executing on the master or node.
|
||||
This --config flag can either consume a InitConfiguration object or a NodeConfiguration one, as this
|
||||
This --config flag can either consume a InitConfiguration object or a JoinConfiguration one, as this
|
||||
function is used for both "kubeadm init" and "kubeadm join".
|
||||
` + cmdutil.AlphaDisclaimer)
|
||||
|
||||
@ -47,7 +47,7 @@ var (
|
||||
# Writes a dynamic environment file with kubelet flags from a InitConfiguration file.
|
||||
kubeadm alpha phase kubelet write-env-file --config masterconfig.yaml
|
||||
|
||||
# Writes a dynamic environment file with kubelet flags from a NodeConfiguration file.
|
||||
# Writes a dynamic environment file with kubelet flags from a JoinConfiguration file.
|
||||
kubeadm alpha phase kubelet write-env-file --config nodeconfig.yaml
|
||||
`)
|
||||
|
||||
@ -115,7 +115,7 @@ func NewCmdKubelet() *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
// NewCmdKubeletWriteEnvFile calls cobra.Command for writing the dynamic kubelet env file based on a InitConfiguration or NodeConfiguration object
|
||||
// NewCmdKubeletWriteEnvFile calls cobra.Command for writing the dynamic kubelet env file based on a InitConfiguration or JoinConfiguration object
|
||||
func NewCmdKubeletWriteEnvFile() *cobra.Command {
|
||||
var cfgPath string
|
||||
|
||||
@ -150,7 +150,7 @@ func RunKubeletWriteEnvFile(cfgPath string) error {
|
||||
nodeRegistrationObj = &cfg.NodeRegistration
|
||||
featureGates = cfg.FeatureGates
|
||||
registerWithTaints = false
|
||||
case *kubeadmapi.NodeConfiguration:
|
||||
case *kubeadmapi.JoinConfiguration:
|
||||
nodeRegistrationObj = &cfg.NodeRegistration
|
||||
featureGates = cfg.FeatureGates
|
||||
registerWithTaints = true
|
||||
|
@ -86,7 +86,7 @@ func NewCmdPreFlightNode() *cobra.Command {
|
||||
Long: nodePreflightLongDesc,
|
||||
Example: nodePreflightExample,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
cfg := &kubeadmapi.NodeConfiguration{}
|
||||
cfg := &kubeadmapi.JoinConfiguration{}
|
||||
err := preflight.RunJoinNodeChecks(utilsexec.New(), cfg, sets.NewString())
|
||||
kubeadmutil.CheckErr(err)
|
||||
},
|
||||
|
@ -293,8 +293,8 @@ const (
|
||||
// In v1alpha3 and higher, this struct is now named InitConfiguration
|
||||
MasterConfigurationKind = "MasterConfiguration"
|
||||
|
||||
// NodeConfigurationKind is the string kind value for the InitConfiguration struct
|
||||
NodeConfigurationKind = "NodeConfiguration"
|
||||
// JoinConfigurationKind is the string kind value for the InitConfiguration struct
|
||||
JoinConfigurationKind = "JoinConfiguration"
|
||||
|
||||
// YAMLDocumentSeparator is the separator for YAML documents
|
||||
// TODO: Find a better place for this constant
|
||||
|
@ -33,7 +33,7 @@ const TokenUser = "tls-bootstrap-token-user"
|
||||
|
||||
// For returns a KubeConfig object that can be used for doing the TLS Bootstrap with the right credentials
|
||||
// Also, before returning anything, it makes sure it can trust the API Server
|
||||
func For(cfg *kubeadmapi.NodeConfiguration) (*clientcmdapi.Config, error) {
|
||||
func For(cfg *kubeadmapi.JoinConfiguration) (*clientcmdapi.Config, error) {
|
||||
// TODO: Print summary info about the CA certificate, along with the checksum signature
|
||||
// we also need an ability for the user to configure the client to validate received CA cert against a checksum
|
||||
clusterinfo, err := GetValidatedClusterInfoObject(cfg)
|
||||
@ -51,7 +51,7 @@ func For(cfg *kubeadmapi.NodeConfiguration) (*clientcmdapi.Config, error) {
|
||||
}
|
||||
|
||||
// GetValidatedClusterInfoObject returns a validated Cluster object that specifies where the cluster is and the CA cert to trust
|
||||
func GetValidatedClusterInfoObject(cfg *kubeadmapi.NodeConfiguration) (*clientcmdapi.Cluster, error) {
|
||||
func GetValidatedClusterInfoObject(cfg *kubeadmapi.JoinConfiguration) (*clientcmdapi.Cluster, error) {
|
||||
switch {
|
||||
case len(cfg.DiscoveryFile) != 0:
|
||||
if isHTTPSURL(cfg.DiscoveryFile) {
|
||||
|
@ -24,30 +24,30 @@ import (
|
||||
|
||||
func TestFor(t *testing.T) {
|
||||
tests := []struct {
|
||||
d kubeadm.NodeConfiguration
|
||||
d kubeadm.JoinConfiguration
|
||||
expect bool
|
||||
}{
|
||||
{d: kubeadm.NodeConfiguration{}, expect: false},
|
||||
{d: kubeadm.JoinConfiguration{}, expect: false},
|
||||
{
|
||||
d: kubeadm.NodeConfiguration{
|
||||
d: kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "notnil",
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
d: kubeadm.NodeConfiguration{
|
||||
d: kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "https://localhost",
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
d: kubeadm.NodeConfiguration{
|
||||
d: kubeadm.JoinConfiguration{
|
||||
DiscoveryFile: "notnil",
|
||||
},
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
d: kubeadm.NodeConfiguration{
|
||||
d: kubeadm.JoinConfiguration{
|
||||
DiscoveryToken: "foo.bar@foobar",
|
||||
},
|
||||
expect: false,
|
||||
|
@ -43,7 +43,7 @@ const BootstrapUser = "token-bootstrap-client"
|
||||
// RetrieveValidatedClusterInfo connects to the API Server and tries to fetch the cluster-info ConfigMap
|
||||
// It then makes sure it can trust the API Server by looking at the JWS-signed tokens and (if cfg.DiscoveryTokenCACertHashes is not empty)
|
||||
// validating the cluster CA against a set of pinned public keys
|
||||
func RetrieveValidatedClusterInfo(cfg *kubeadmapi.NodeConfiguration) (*clientcmdapi.Cluster, error) {
|
||||
func RetrieveValidatedClusterInfo(cfg *kubeadmapi.JoinConfiguration) (*clientcmdapi.Cluster, error) {
|
||||
token, err := kubeadmapi.NewBootstrapTokenString(cfg.DiscoveryToken)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -913,7 +913,7 @@ func RunInitMasterChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigu
|
||||
}
|
||||
|
||||
// RunJoinNodeChecks executes all individual, applicable to node checks.
|
||||
func RunJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.NodeConfiguration, ignorePreflightErrors sets.String) error {
|
||||
func RunJoinNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.JoinConfiguration, ignorePreflightErrors sets.String) error {
|
||||
// First, check if we're root separately from the other preflight checks and fail fast
|
||||
if err := RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
||||
return err
|
||||
|
@ -238,21 +238,21 @@ func TestRunInitMasterChecks(t *testing.T) {
|
||||
|
||||
func TestRunJoinNodeChecks(t *testing.T) {
|
||||
var tests = []struct {
|
||||
cfg *kubeadmapi.NodeConfiguration
|
||||
cfg *kubeadmapi.JoinConfiguration
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
cfg: &kubeadmapi.NodeConfiguration{},
|
||||
cfg: &kubeadmapi.JoinConfiguration{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
cfg: &kubeadmapi.NodeConfiguration{
|
||||
cfg: &kubeadmapi.JoinConfiguration{
|
||||
DiscoveryTokenAPIServers: []string{"192.168.1.15"},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
cfg: &kubeadmapi.NodeConfiguration{
|
||||
cfg: &kubeadmapi.JoinConfiguration{
|
||||
DiscoveryTokenAPIServers: []string{"2001:1234::1:15"},
|
||||
},
|
||||
expected: false,
|
||||
|
@ -32,7 +32,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/util/version"
|
||||
)
|
||||
|
||||
// AnyConfigFileAndDefaultsToInternal reads either a InitConfiguration or NodeConfiguration and unmarshals it
|
||||
// AnyConfigFileAndDefaultsToInternal reads either a InitConfiguration or JoinConfiguration and unmarshals it
|
||||
func AnyConfigFileAndDefaultsToInternal(cfgPath string) (runtime.Object, error) {
|
||||
b, err := ioutil.ReadFile(cfgPath)
|
||||
if err != nil {
|
||||
@ -48,8 +48,8 @@ func AnyConfigFileAndDefaultsToInternal(cfgPath string) (runtime.Object, error)
|
||||
if kubeadmutil.GroupVersionKindsHasInitConfiguration(gvks...) {
|
||||
return ConfigFileAndDefaultsToInternalConfig(cfgPath, &kubeadmapiv1alpha3.InitConfiguration{})
|
||||
}
|
||||
if kubeadmutil.GroupVersionKindsHasNodeConfiguration(gvks) {
|
||||
return NodeConfigFileAndDefaultsToInternalConfig(cfgPath, &kubeadmapiv1alpha3.NodeConfiguration{})
|
||||
if kubeadmutil.GroupVersionKindsHasJoinConfiguration(gvks) {
|
||||
return NodeConfigFileAndDefaultsToInternalConfig(cfgPath, &kubeadmapiv1alpha3.JoinConfiguration{})
|
||||
}
|
||||
return nil, fmt.Errorf("didn't recognize types with GroupVersionKind: %v", gvks)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ kind: InitConfiguration
|
||||
`),
|
||||
"Node_v1alpha1": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1alpha1
|
||||
kind: NodeConfiguration
|
||||
kind: JoinConfiguration
|
||||
`),
|
||||
"Master_v1alpha3": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1alpha3
|
||||
@ -39,7 +39,7 @@ kind: InitConfiguration
|
||||
`),
|
||||
"Node_v1alpha3": []byte(`
|
||||
apiVersion: kubeadm.k8s.io/v1alpha3
|
||||
kind: NodeConfiguration
|
||||
kind: JoinConfiguration
|
||||
`),
|
||||
"NoKind": []byte(`
|
||||
apiVersion: baz.k8s.io/v1
|
||||
|
@ -30,15 +30,15 @@ import (
|
||||
"k8s.io/kubernetes/pkg/util/node"
|
||||
)
|
||||
|
||||
// SetJoinDynamicDefaults checks and sets configuration values for the NodeConfiguration object
|
||||
func SetJoinDynamicDefaults(cfg *kubeadmapi.NodeConfiguration) error {
|
||||
// SetJoinDynamicDefaults checks and sets configuration values for the JoinConfiguration object
|
||||
func SetJoinDynamicDefaults(cfg *kubeadmapi.JoinConfiguration) error {
|
||||
cfg.NodeRegistration.Name = node.GetHostname(cfg.NodeRegistration.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
// NodeConfigFileAndDefaultsToInternalConfig
|
||||
func NodeConfigFileAndDefaultsToInternalConfig(cfgPath string, defaultversionedcfg *kubeadmapiv1alpha3.NodeConfiguration) (*kubeadmapi.NodeConfiguration, error) {
|
||||
internalcfg := &kubeadmapi.NodeConfiguration{}
|
||||
func NodeConfigFileAndDefaultsToInternalConfig(cfgPath string, defaultversionedcfg *kubeadmapiv1alpha3.JoinConfiguration) (*kubeadmapi.JoinConfiguration, error) {
|
||||
internalcfg := &kubeadmapi.JoinConfiguration{}
|
||||
|
||||
if cfgPath != "" {
|
||||
// Loads configuration from config file, if provided
|
||||
@ -69,7 +69,7 @@ func NodeConfigFileAndDefaultsToInternalConfig(cfgPath string, defaultversionedc
|
||||
return nil, err
|
||||
}
|
||||
// Validates cfg (flags/configs + defaults)
|
||||
if err := validation.ValidateNodeConfiguration(internalcfg).ToAggregate(); err != nil {
|
||||
if err := validation.ValidateJoinConfiguration(internalcfg).ToAggregate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ func TestNodeConfigFileAndDefaultsToInternalConfig(t *testing.T) {
|
||||
for _, rt := range tests {
|
||||
t.Run(rt.name, func(t2 *testing.T) {
|
||||
|
||||
internalcfg, err := NodeConfigFileAndDefaultsToInternalConfig(rt.in, &kubeadmapiv1alpha3.NodeConfiguration{})
|
||||
internalcfg, err := NodeConfigFileAndDefaultsToInternalConfig(rt.in, &kubeadmapiv1alpha3.JoinConfiguration{})
|
||||
if err != nil {
|
||||
if rt.expectedErr {
|
||||
return
|
||||
|
@ -154,7 +154,7 @@ func GroupVersionKindsHasInitConfiguration(gvks ...schema.GroupVersionKind) bool
|
||||
return GroupVersionKindsHasKind(gvks, constants.InitConfigurationKind) || GroupVersionKindsHasKind(gvks, constants.MasterConfigurationKind)
|
||||
}
|
||||
|
||||
// GroupVersionKindsHasNodeConfiguration returns whether the following gvk slice contains a NodeConfiguration object
|
||||
func GroupVersionKindsHasNodeConfiguration(gvks []schema.GroupVersionKind) bool {
|
||||
return GroupVersionKindsHasKind(gvks, constants.NodeConfigurationKind)
|
||||
// GroupVersionKindsHasJoinConfiguration returns whether the following gvk slice contains a JoinConfiguration object
|
||||
func GroupVersionKindsHasJoinConfiguration(gvks []schema.GroupVersionKind) bool {
|
||||
return GroupVersionKindsHasKind(gvks, constants.JoinConfigurationKind)
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ func TestGroupVersionKindsHasInitConfiguration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGroupVersionKindsHasNodeConfiguration(t *testing.T) {
|
||||
func TestGroupVersionKindsHasJoinConfiguration(t *testing.T) {
|
||||
var tests = []struct {
|
||||
name string
|
||||
gvks []schema.GroupVersionKind
|
||||
@ -382,17 +382,17 @@ func TestGroupVersionKindsHasNodeConfiguration(t *testing.T) {
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "NoNodeConfiguration",
|
||||
name: "NoJoinConfiguration",
|
||||
gvks: []schema.GroupVersionKind{
|
||||
{Group: "foo.k8s.io", Version: "v1", Kind: "Foo"},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "NodeConfigurationFound",
|
||||
name: "JoinConfigurationFound",
|
||||
gvks: []schema.GroupVersionKind{
|
||||
{Group: "foo.k8s.io", Version: "v1", Kind: "Foo"},
|
||||
{Group: "bar.k8s.io", Version: "v2", Kind: "NodeConfiguration"},
|
||||
{Group: "bar.k8s.io", Version: "v2", Kind: "JoinConfiguration"},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
@ -401,9 +401,9 @@ func TestGroupVersionKindsHasNodeConfiguration(t *testing.T) {
|
||||
for _, rt := range tests {
|
||||
t.Run(rt.name, func(t2 *testing.T) {
|
||||
|
||||
actual := GroupVersionKindsHasNodeConfiguration(rt.gvks)
|
||||
actual := GroupVersionKindsHasJoinConfiguration(rt.gvks)
|
||||
if rt.expected != actual {
|
||||
t2.Errorf("expected gvks has NodeConfiguration: %t\n\tactual: %t\n", rt.expected, actual)
|
||||
t2.Errorf("expected gvks has JoinConfiguration: %t\n\tactual: %t\n", rt.expected, actual)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user