mirror of https://github.com/k3s-io/k3s
kubeadm: override node registration options from command line
'kubeadm init' silently ignores --node-name and --cri-socket command line options if --config option is specified. Implemented setting 'name' and 'criSocket' options from the command line even if --config command line option is used.pull/58/head
parent
a19bf332de
commit
b4b4718fc1
|
@ -399,7 +399,7 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
|
||||||
|
|
||||||
mixedInvalidFlags := []string{}
|
mixedInvalidFlags := []string{}
|
||||||
flag.Visit(func(f *pflag.Flag) {
|
flag.Visit(func(f *pflag.Flag) {
|
||||||
if f.Name == "config" || f.Name == "ignore-preflight-errors" || strings.HasPrefix(f.Name, "skip-") || f.Name == "dry-run" || f.Name == "kubeconfig" || f.Name == "v" || f.Name == "rootfs" || f.Name == "print-join-command" {
|
if f.Name == "config" || f.Name == "ignore-preflight-errors" || strings.HasPrefix(f.Name, "skip-") || f.Name == "dry-run" || f.Name == "kubeconfig" || f.Name == "v" || f.Name == "rootfs" || f.Name == "print-join-command" || f.Name == "node-name" || f.Name == "cri-socket" {
|
||||||
// "--skip-*" flags or other whitelisted flags can be set with --config
|
// "--skip-*" flags or other whitelisted flags can be set with --config
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,6 +305,15 @@ func newInitData(cmd *cobra.Command, options *initOptions, out io.Writer) (initD
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return initData{}, err
|
return initData{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// override node name and CRI socket from the command line options
|
||||||
|
if options.externalcfg.NodeRegistration.Name != "" {
|
||||||
|
cfg.NodeRegistration.Name = options.externalcfg.NodeRegistration.Name
|
||||||
|
}
|
||||||
|
if options.externalcfg.NodeRegistration.CRISocket != kubeadmapiv1beta1.DefaultCRISocket {
|
||||||
|
cfg.NodeRegistration.CRISocket = options.externalcfg.NodeRegistration.CRISocket
|
||||||
|
}
|
||||||
|
|
||||||
if err := configutil.VerifyAPIServerBindAddress(cfg.LocalAPIEndpoint.AdvertiseAddress); err != nil {
|
if err := configutil.VerifyAPIServerBindAddress(cfg.LocalAPIEndpoint.AdvertiseAddress); err != nil {
|
||||||
return initData{}, err
|
return initData{}, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue