mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Merge pull request #119279 from chendave/dryrun_init
kubeadm: Make dry-run is configurable in initConfiguration and joinConfiguration
This commit is contained in:
commit
5054f2954d
@ -64,6 +64,7 @@ func fuzzInitConfiguration(obj *kubeadm.InitConfiguration, c fuzz.Continue) {
|
|||||||
obj.SkipPhases = nil
|
obj.SkipPhases = nil
|
||||||
obj.NodeRegistration.ImagePullPolicy = corev1.PullIfNotPresent
|
obj.NodeRegistration.ImagePullPolicy = corev1.PullIfNotPresent
|
||||||
obj.Patches = nil
|
obj.Patches = nil
|
||||||
|
obj.DryRun = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func fuzzNodeRegistration(obj *kubeadm.NodeRegistrationOptions, c fuzz.Continue) {
|
func fuzzNodeRegistration(obj *kubeadm.NodeRegistrationOptions, c fuzz.Continue) {
|
||||||
@ -129,6 +130,7 @@ func fuzzJoinConfiguration(obj *kubeadm.JoinConfiguration, c fuzz.Continue) {
|
|||||||
obj.SkipPhases = nil
|
obj.SkipPhases = nil
|
||||||
obj.NodeRegistration.ImagePullPolicy = corev1.PullIfNotPresent
|
obj.NodeRegistration.ImagePullPolicy = corev1.PullIfNotPresent
|
||||||
obj.Patches = nil
|
obj.Patches = nil
|
||||||
|
obj.DryRun = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func fuzzJoinControlPlane(obj *kubeadm.JoinControlPlane, c fuzz.Continue) {
|
func fuzzJoinControlPlane(obj *kubeadm.JoinControlPlane, c fuzz.Continue) {
|
||||||
|
@ -44,6 +44,9 @@ type InitConfiguration struct {
|
|||||||
// BootstrapTokens is respected at `kubeadm init` time and describes a set of Bootstrap Tokens to create.
|
// BootstrapTokens is respected at `kubeadm init` time and describes a set of Bootstrap Tokens to create.
|
||||||
BootstrapTokens []bootstraptokenv1.BootstrapToken
|
BootstrapTokens []bootstraptokenv1.BootstrapToken
|
||||||
|
|
||||||
|
// DryRun tells if the dry run mode is enabled, don't apply any change if it is and just output what would be done.
|
||||||
|
DryRun bool
|
||||||
|
|
||||||
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
||||||
NodeRegistration NodeRegistrationOptions
|
NodeRegistration NodeRegistrationOptions
|
||||||
|
|
||||||
@ -299,6 +302,9 @@ type ExternalEtcd struct {
|
|||||||
type JoinConfiguration struct {
|
type JoinConfiguration struct {
|
||||||
metav1.TypeMeta
|
metav1.TypeMeta
|
||||||
|
|
||||||
|
// DryRun tells if the dry run mode is enabled, don't apply any change if it is and just output what would be done.
|
||||||
|
DryRun bool
|
||||||
|
|
||||||
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
||||||
NodeRegistration NodeRegistrationOptions
|
NodeRegistration NodeRegistrationOptions
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ func Convert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in *kubeadm.
|
|||||||
return autoConvert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in, out, s)
|
return autoConvert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in, out, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Convert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
||||||
|
return autoConvert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in, out, s)
|
||||||
|
}
|
||||||
|
|
||||||
func Convert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConfiguration, out *kubeadm.InitConfiguration, s conversion.Scope) error {
|
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)
|
err := autoConvert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in, out, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -154,11 +154,6 @@ func RegisterConversions(s *runtime.Scheme) error {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := s.AddGeneratedConversionFunc((*kubeadm.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
|
||||||
return Convert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(a.(*kubeadm.JoinConfiguration), b.(*JoinConfiguration), scope)
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := s.AddGeneratedConversionFunc((*JoinControlPlane)(nil), (*kubeadm.JoinControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
if err := s.AddGeneratedConversionFunc((*JoinControlPlane)(nil), (*kubeadm.JoinControlPlane)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||||
return Convert_v1beta3_JoinControlPlane_To_kubeadm_JoinControlPlane(a.(*JoinControlPlane), b.(*kubeadm.JoinControlPlane), scope)
|
return Convert_v1beta3_JoinControlPlane_To_kubeadm_JoinControlPlane(a.(*JoinControlPlane), b.(*kubeadm.JoinControlPlane), scope)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -209,6 +204,11 @@ func RegisterConversions(s *runtime.Scheme) error {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := s.AddConversionFunc((*kubeadm.JoinConfiguration)(nil), (*JoinConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||||
|
return Convert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(a.(*kubeadm.JoinConfiguration), b.(*JoinConfiguration), scope)
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := s.AddConversionFunc((*kubeadm.LocalEtcd)(nil), (*LocalEtcd)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
if err := s.AddConversionFunc((*kubeadm.LocalEtcd)(nil), (*LocalEtcd)(nil), func(a, b interface{}, scope conversion.Scope) error {
|
||||||
return Convert_kubeadm_LocalEtcd_To_v1beta3_LocalEtcd(a.(*kubeadm.LocalEtcd), b.(*LocalEtcd), scope)
|
return Convert_kubeadm_LocalEtcd_To_v1beta3_LocalEtcd(a.(*kubeadm.LocalEtcd), b.(*LocalEtcd), scope)
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
@ -591,6 +591,7 @@ func autoConvert_v1beta3_InitConfiguration_To_kubeadm_InitConfiguration(in *Init
|
|||||||
func autoConvert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error {
|
func autoConvert_kubeadm_InitConfiguration_To_v1beta3_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error {
|
||||||
// WARNING: in.ClusterConfiguration requires manual conversion: does not exist in peer-type
|
// WARNING: in.ClusterConfiguration requires manual conversion: does not exist in peer-type
|
||||||
out.BootstrapTokens = *(*[]bootstraptokenv1.BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens))
|
out.BootstrapTokens = *(*[]bootstraptokenv1.BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens))
|
||||||
|
// WARNING: in.DryRun requires manual conversion: does not exist in peer-type
|
||||||
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta3_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta3_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -623,6 +624,7 @@ func Convert_v1beta3_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
func autoConvert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
||||||
|
// WARNING: in.DryRun requires manual conversion: does not exist in peer-type
|
||||||
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta3_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta3_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -636,11 +638,6 @@ func autoConvert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in *kube
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration is an autogenerated conversion function.
|
|
||||||
func Convert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
|
||||||
return autoConvert_kubeadm_JoinConfiguration_To_v1beta3_JoinConfiguration(in, out, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func autoConvert_v1beta3_JoinControlPlane_To_kubeadm_JoinControlPlane(in *JoinControlPlane, out *kubeadm.JoinControlPlane, s conversion.Scope) error {
|
func autoConvert_v1beta3_JoinControlPlane_To_kubeadm_JoinControlPlane(in *JoinControlPlane, out *kubeadm.JoinControlPlane, s conversion.Scope) error {
|
||||||
if err := Convert_v1beta3_APIEndpoint_To_kubeadm_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil {
|
if err := Convert_v1beta3_APIEndpoint_To_kubeadm_APIEndpoint(&in.LocalAPIEndpoint, &out.LocalAPIEndpoint, s); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -28,6 +28,7 @@ limitations under the License.
|
|||||||
// - Support custom environment variables in control plane components under `ClusterConfiguration`.
|
// - Support custom environment variables in control plane components under `ClusterConfiguration`.
|
||||||
// Use `APIServer.ExtraEnvs`, `ControllerManager.ExtraEnvs`, `Scheduler.ExtraEnvs`, `Etcd.Local.ExtraEnvs`.
|
// Use `APIServer.ExtraEnvs`, `ControllerManager.ExtraEnvs`, `Scheduler.ExtraEnvs`, `Etcd.Local.ExtraEnvs`.
|
||||||
// - The ResetConfiguration API type is now supported in v1beta4. Users are able to reset a node by passing a --config file to "kubeadm reset".
|
// - The ResetConfiguration API type is now supported in v1beta4. Users are able to reset a node by passing a --config file to "kubeadm reset".
|
||||||
|
// - `dry-run` mode in is now configurable in InitConfiguration and JoinConfiguration config files.
|
||||||
//
|
//
|
||||||
// Migration from old kubeadm config versions
|
// Migration from old kubeadm config versions
|
||||||
//
|
//
|
||||||
|
@ -39,6 +39,10 @@ type InitConfiguration struct {
|
|||||||
// +optional
|
// +optional
|
||||||
BootstrapTokens []bootstraptokenv1.BootstrapToken `json:"bootstrapTokens,omitempty"`
|
BootstrapTokens []bootstraptokenv1.BootstrapToken `json:"bootstrapTokens,omitempty"`
|
||||||
|
|
||||||
|
// DryRun tells if the dry run mode is enabled, don't apply any change if it is and just output what would be done.
|
||||||
|
// +optional
|
||||||
|
DryRun bool `json:"dryRun,omitempty"`
|
||||||
|
|
||||||
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
||||||
// +optional
|
// +optional
|
||||||
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
|
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
|
||||||
@ -326,6 +330,10 @@ type ExternalEtcd struct {
|
|||||||
type JoinConfiguration struct {
|
type JoinConfiguration struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
|
||||||
|
// DryRun tells if the dry run mode is enabled, don't apply any change if it is and just output what would be done.
|
||||||
|
// +optional
|
||||||
|
DryRun bool `json:"dryRun,omitempty"`
|
||||||
|
|
||||||
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
// NodeRegistration holds fields that relate to registering the new control-plane node to the cluster
|
||||||
// +optional
|
// +optional
|
||||||
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
|
NodeRegistration NodeRegistrationOptions `json:"nodeRegistration,omitempty"`
|
||||||
|
@ -581,6 +581,7 @@ func Convert_kubeadm_ImageMeta_To_v1beta4_ImageMeta(in *kubeadm.ImageMeta, out *
|
|||||||
|
|
||||||
func autoConvert_v1beta4_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConfiguration, out *kubeadm.InitConfiguration, s conversion.Scope) error {
|
func autoConvert_v1beta4_InitConfiguration_To_kubeadm_InitConfiguration(in *InitConfiguration, out *kubeadm.InitConfiguration, s conversion.Scope) error {
|
||||||
out.BootstrapTokens = *(*[]bootstraptokenv1.BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens))
|
out.BootstrapTokens = *(*[]bootstraptokenv1.BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens))
|
||||||
|
out.DryRun = in.DryRun
|
||||||
if err := Convert_v1beta4_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
if err := Convert_v1beta4_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -596,6 +597,7 @@ func autoConvert_v1beta4_InitConfiguration_To_kubeadm_InitConfiguration(in *Init
|
|||||||
func autoConvert_kubeadm_InitConfiguration_To_v1beta4_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error {
|
func autoConvert_kubeadm_InitConfiguration_To_v1beta4_InitConfiguration(in *kubeadm.InitConfiguration, out *InitConfiguration, s conversion.Scope) error {
|
||||||
// WARNING: in.ClusterConfiguration requires manual conversion: does not exist in peer-type
|
// WARNING: in.ClusterConfiguration requires manual conversion: does not exist in peer-type
|
||||||
out.BootstrapTokens = *(*[]bootstraptokenv1.BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens))
|
out.BootstrapTokens = *(*[]bootstraptokenv1.BootstrapToken)(unsafe.Pointer(&in.BootstrapTokens))
|
||||||
|
out.DryRun = in.DryRun
|
||||||
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta4_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta4_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -609,6 +611,7 @@ func autoConvert_kubeadm_InitConfiguration_To_v1beta4_InitConfiguration(in *kube
|
|||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_v1beta4_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error {
|
func autoConvert_v1beta4_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConfiguration, out *kubeadm.JoinConfiguration, s conversion.Scope) error {
|
||||||
|
out.DryRun = in.DryRun
|
||||||
if err := Convert_v1beta4_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
if err := Convert_v1beta4_NodeRegistrationOptions_To_kubeadm_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -628,6 +631,7 @@ func Convert_v1beta4_JoinConfiguration_To_kubeadm_JoinConfiguration(in *JoinConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
func autoConvert_kubeadm_JoinConfiguration_To_v1beta4_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
func autoConvert_kubeadm_JoinConfiguration_To_v1beta4_JoinConfiguration(in *kubeadm.JoinConfiguration, out *JoinConfiguration, s conversion.Scope) error {
|
||||||
|
out.DryRun = in.DryRun
|
||||||
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta4_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
if err := Convert_kubeadm_NodeRegistrationOptions_To_v1beta4_NodeRegistrationOptions(&in.NodeRegistration, &out.NodeRegistration, s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -279,15 +279,15 @@ func newInitOptions() *initOptions {
|
|||||||
// newInitData returns a new initData struct to be used for the execution of the kubeadm init workflow.
|
// newInitData returns a new initData struct to be used for the execution of the kubeadm init workflow.
|
||||||
// This func takes care of validating initOptions passed to the command, and then it converts
|
// This func takes care of validating initOptions passed to the command, and then it converts
|
||||||
// options into the internal InitConfiguration type that is used as input all the phases in the kubeadm init workflow
|
// options into the internal InitConfiguration type that is used as input all the phases in the kubeadm init workflow
|
||||||
func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io.Writer) (*initData, error) {
|
func newInitData(cmd *cobra.Command, args []string, initOptions *initOptions, out io.Writer) (*initData, error) {
|
||||||
// Re-apply defaults to the public kubeadm API (this will set only values not exposed/not set as a flags)
|
// Re-apply defaults to the public kubeadm API (this will set only values not exposed/not set as a flags)
|
||||||
kubeadmscheme.Scheme.Default(options.externalInitCfg)
|
kubeadmscheme.Scheme.Default(initOptions.externalInitCfg)
|
||||||
kubeadmscheme.Scheme.Default(options.externalClusterCfg)
|
kubeadmscheme.Scheme.Default(initOptions.externalClusterCfg)
|
||||||
|
|
||||||
// Validate standalone flags values and/or combination of flags and then assigns
|
// Validate standalone flags values and/or combination of flags and then assigns
|
||||||
// validated values to the public kubeadm config API when applicable
|
// validated values to the public kubeadm config API when applicable
|
||||||
var err error
|
var err error
|
||||||
if options.externalClusterCfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, options.featureGatesString); err != nil {
|
if initOptions.externalClusterCfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, initOptions.featureGatesString); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,18 +295,18 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = options.bto.ApplyTo(options.externalInitCfg); err != nil {
|
if err = initOptions.bto.ApplyTo(initOptions.externalInitCfg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either use the config file if specified, or convert public kubeadm API to the internal InitConfiguration
|
// Either use the config file if specified, or convert public kubeadm API to the internal InitConfiguration
|
||||||
// and validates InitConfiguration
|
// and validates InitConfiguration
|
||||||
cfg, err := configutil.LoadOrDefaultInitConfiguration(options.cfgPath, options.externalInitCfg, options.externalClusterCfg)
|
cfg, err := configutil.LoadOrDefaultInitConfiguration(initOptions.cfgPath, initOptions.externalInitCfg, initOptions.externalClusterCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(options.ignorePreflightErrors, cfg.NodeRegistration.IgnorePreflightErrors)
|
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(initOptions.ignorePreflightErrors, cfg.NodeRegistration.IgnorePreflightErrors)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -314,8 +314,8 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
|
|||||||
cfg.NodeRegistration.IgnorePreflightErrors = sets.List(ignorePreflightErrorsSet)
|
cfg.NodeRegistration.IgnorePreflightErrors = sets.List(ignorePreflightErrorsSet)
|
||||||
|
|
||||||
// override node name from the command line option
|
// override node name from the command line option
|
||||||
if options.externalInitCfg.NodeRegistration.Name != "" {
|
if initOptions.externalInitCfg.NodeRegistration.Name != "" {
|
||||||
cfg.NodeRegistration.Name = options.externalInitCfg.NodeRegistration.Name
|
cfg.NodeRegistration.Name = initOptions.externalInitCfg.NodeRegistration.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := configutil.VerifyAPIServerBindAddress(cfg.LocalAPIEndpoint.AdvertiseAddress); err != nil {
|
if err := configutil.VerifyAPIServerBindAddress(cfg.LocalAPIEndpoint.AdvertiseAddress); err != nil {
|
||||||
@ -327,7 +327,7 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
|
|||||||
|
|
||||||
// if dry running creates a temporary folder for saving kubeadm generated files
|
// if dry running creates a temporary folder for saving kubeadm generated files
|
||||||
dryRunDir := ""
|
dryRunDir := ""
|
||||||
if options.dryRun {
|
if initOptions.dryRun || cfg.DryRun {
|
||||||
// the KUBEADM_INIT_DRYRUN_DIR environment variable allows overriding the dry-run temporary
|
// the KUBEADM_INIT_DRYRUN_DIR environment variable allows overriding the dry-run temporary
|
||||||
// directory from the command line. This makes it possible to run "kubeadm init" integration
|
// directory from the command line. This makes it possible to run "kubeadm init" integration
|
||||||
// tests without root.
|
// tests without root.
|
||||||
@ -347,7 +347,7 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
|
|||||||
|
|
||||||
// Validate that also the required kubeconfig files exists and are invalid, because
|
// Validate that also the required kubeconfig files exists and are invalid, because
|
||||||
// kubeadm can't regenerate them without the CA Key
|
// kubeadm can't regenerate them without the CA Key
|
||||||
kubeconfigDir := options.kubeconfigDir
|
kubeconfigDir := initOptions.kubeconfigDir
|
||||||
if err := kubeconfigphase.ValidateKubeconfigsForExternalCA(kubeconfigDir, cfg); err != nil {
|
if err := kubeconfigphase.ValidateKubeconfigsForExternalCA(kubeconfigDir, cfg); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -363,24 +363,24 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.uploadCerts && (externalCA || externalFrontProxyCA) {
|
if initOptions.uploadCerts && (externalCA || externalFrontProxyCA) {
|
||||||
return nil, errors.New("can't use upload-certs with an external CA or an external front-proxy CA")
|
return nil, errors.New("can't use upload-certs with an external CA or an external front-proxy CA")
|
||||||
}
|
}
|
||||||
|
|
||||||
return &initData{
|
return &initData{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
certificatesDir: cfg.CertificatesDir,
|
certificatesDir: cfg.CertificatesDir,
|
||||||
skipTokenPrint: options.skipTokenPrint,
|
skipTokenPrint: initOptions.skipTokenPrint,
|
||||||
dryRun: options.dryRun,
|
dryRun: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.DryRun, cfg.DryRun, initOptions.dryRun).(bool),
|
||||||
dryRunDir: dryRunDir,
|
dryRunDir: dryRunDir,
|
||||||
kubeconfigDir: options.kubeconfigDir,
|
kubeconfigDir: initOptions.kubeconfigDir,
|
||||||
kubeconfigPath: options.kubeconfigPath,
|
kubeconfigPath: initOptions.kubeconfigPath,
|
||||||
ignorePreflightErrors: ignorePreflightErrorsSet,
|
ignorePreflightErrors: ignorePreflightErrorsSet,
|
||||||
externalCA: externalCA,
|
externalCA: externalCA,
|
||||||
outputWriter: out,
|
outputWriter: out,
|
||||||
uploadCerts: options.uploadCerts,
|
uploadCerts: initOptions.uploadCerts,
|
||||||
skipCertificateKeyPrint: options.skipCertificateKeyPrint,
|
skipCertificateKeyPrint: initOptions.skipCertificateKeyPrint,
|
||||||
patchesDir: options.patchesDir,
|
patchesDir: initOptions.patchesDir,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,7 @@ func newJoinData(cmd *cobra.Command, args []string, opt *joinOptions, out io.Wri
|
|||||||
|
|
||||||
// if dry running, creates a temporary folder to save kubeadm generated files
|
// if dry running, creates a temporary folder to save kubeadm generated files
|
||||||
dryRunDir := ""
|
dryRunDir := ""
|
||||||
if opt.dryRun {
|
if opt.dryRun || cfg.DryRun {
|
||||||
if dryRunDir, err = kubeadmconstants.CreateTempDirForKubeadm("", "kubeadm-join-dryrun"); err != nil {
|
if dryRunDir, err = kubeadmconstants.CreateTempDirForKubeadm("", "kubeadm-join-dryrun"); err != nil {
|
||||||
return nil, errors.Wrap(err, "couldn't create a temporary directory on dryrun")
|
return nil, errors.Wrap(err, "couldn't create a temporary directory on dryrun")
|
||||||
}
|
}
|
||||||
@ -462,11 +462,11 @@ func newJoinData(cmd *cobra.Command, args []string, opt *joinOptions, out io.Wri
|
|||||||
|
|
||||||
return &joinData{
|
return &joinData{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
|
dryRun: cmdutil.ValueFromFlagsOrConfig(cmd.Flags(), options.DryRun, cfg.DryRun, opt.dryRun).(bool),
|
||||||
tlsBootstrapCfg: tlsBootstrapCfg,
|
tlsBootstrapCfg: tlsBootstrapCfg,
|
||||||
ignorePreflightErrors: ignorePreflightErrorsSet,
|
ignorePreflightErrors: ignorePreflightErrorsSet,
|
||||||
outputWriter: out,
|
outputWriter: out,
|
||||||
patchesDir: opt.patchesDir,
|
patchesDir: opt.patchesDir,
|
||||||
dryRun: opt.dryRun,
|
|
||||||
dryRunDir: dryRunDir,
|
dryRunDir: dryRunDir,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user