mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
kubeadm: fail faster when the version is not provided
Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
parent
567d1a2e22
commit
aa5dfd8b28
@ -163,24 +163,6 @@ func enforceRequirements(flags *applyPlanFlags, args []string, dryRun bool, upgr
|
|||||||
newK8sVersion = cfg.KubernetesVersion
|
newK8sVersion = cfg.KubernetesVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(flags.ignorePreflightErrors, cfg.NodeRegistration.IgnorePreflightErrors)
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, nil, err
|
|
||||||
}
|
|
||||||
// Also set the union of pre-flight errors to InitConfiguration, to provide a consistent view of the runtime configuration:
|
|
||||||
cfg.NodeRegistration.IgnorePreflightErrors = ignorePreflightErrorsSet.List()
|
|
||||||
|
|
||||||
// Ensure the user is root
|
|
||||||
klog.V(1).Info("running preflight checks")
|
|
||||||
if err := runPreflightChecks(client, ignorePreflightErrorsSet, &cfg.ClusterConfiguration, printer); err != nil {
|
|
||||||
return nil, nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run healthchecks against the cluster
|
|
||||||
if err := upgrade.CheckClusterHealth(client, &cfg.ClusterConfiguration, ignorePreflightErrorsSet); err != nil {
|
|
||||||
return nil, nil, nil, errors.Wrap(err, "[upgrade/health] FATAL")
|
|
||||||
}
|
|
||||||
|
|
||||||
// The version arg is mandatory, during upgrade apply, unless it's specified in the config file
|
// The version arg is mandatory, during upgrade apply, unless it's specified in the config file
|
||||||
if upgradeApply && newK8sVersion == "" {
|
if upgradeApply && newK8sVersion == "" {
|
||||||
if err := cmdutil.ValidateExactArgNumber(args, []string{"version"}); err != nil {
|
if err := cmdutil.ValidateExactArgNumber(args, []string{"version"}); err != nil {
|
||||||
@ -202,6 +184,24 @@ func enforceRequirements(flags *applyPlanFlags, args []string, dryRun bool, upgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(flags.ignorePreflightErrors, cfg.NodeRegistration.IgnorePreflightErrors)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
// Also set the union of pre-flight errors to InitConfiguration, to provide a consistent view of the runtime configuration:
|
||||||
|
cfg.NodeRegistration.IgnorePreflightErrors = ignorePreflightErrorsSet.List()
|
||||||
|
|
||||||
|
// Ensure the user is root
|
||||||
|
klog.V(1).Info("running preflight checks")
|
||||||
|
if err := runPreflightChecks(client, ignorePreflightErrorsSet, &cfg.ClusterConfiguration, printer); err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run healthchecks against the cluster
|
||||||
|
if err := upgrade.CheckClusterHealth(client, &cfg.ClusterConfiguration, ignorePreflightErrorsSet); err != nil {
|
||||||
|
return nil, nil, nil, errors.Wrap(err, "[upgrade/health] FATAL")
|
||||||
|
}
|
||||||
|
|
||||||
// If features gates are passed to the command line, use it (otherwise use featureGates from configuration)
|
// If features gates are passed to the command line, use it (otherwise use featureGates from configuration)
|
||||||
if flags.featureGatesString != "" {
|
if flags.featureGatesString != "" {
|
||||||
cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, flags.featureGatesString)
|
cfg.FeatureGates, err = features.NewFeatureGate(&features.InitFeatureGates, flags.featureGatesString)
|
||||||
|
@ -65,7 +65,6 @@ func (c *healthCheck) Name() string {
|
|||||||
// CheckClusterHealth makes sure:
|
// CheckClusterHealth makes sure:
|
||||||
// - the API /healthz endpoint is healthy
|
// - the API /healthz endpoint is healthy
|
||||||
// - all control-plane Nodes are Ready
|
// - all control-plane Nodes are Ready
|
||||||
// - (if self-hosted) that there are DaemonSets with at least one Pod for all control plane components
|
|
||||||
// - (if static pod-hosted) that all required Static Pod manifests exist on disk
|
// - (if static pod-hosted) that all required Static Pod manifests exist on disk
|
||||||
func CheckClusterHealth(client clientset.Interface, cfg *kubeadmapi.ClusterConfiguration, ignoreChecksErrors sets.String) error {
|
func CheckClusterHealth(client clientset.Interface, cfg *kubeadmapi.ClusterConfiguration, ignoreChecksErrors sets.String) error {
|
||||||
fmt.Println("[upgrade] Running cluster health checks")
|
fmt.Println("[upgrade] Running cluster health checks")
|
||||||
|
Loading…
Reference in New Issue
Block a user