returnfmt.Errorf("given token or token id %q didn't match pattern %q or %q",tokenIDOrToken,bootstrapapi.BootstrapTokenIDPattern,bootstrapapi.BootstrapTokenIDPattern)
returnerrors.Errorf("given token or token id %q didn't match pattern %q or %q",
returnfmt.Errorf("The --version argument is invalid due to these fatal errors:\n\n%v\nPlease fix the misalignments highlighted above and try upgrading again",kubeadmutil.FormatErrMsg(versionSkewErrs.Mandatory))
returnerrors.Errorf("the --version argument is invalid due to these fatal errors:\n\n%v\nPlease fix the misalignments highlighted above and try upgrading again",
// Return the error if the user hasn't specified the --force flag
// Return the error if the user hasn't specified the --force flag
if!flags.force{
if!flags.force{
returnfmt.Errorf("The --version argument is invalid due to these errors:\n\n%v\nCan be bypassed if you pass the --force flag",kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
returnerrors.Errorf("the --version argument is invalid due to these errors:\n\n%v\nCan be bypassed if you pass the --force flag",
fmt.Printf("[upgrade/version] Found %d potential version compatibility errors but skipping since the --force flag is set: \n\n%v",len(versionSkewErrs.Skippable),kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
fmt.Printf("[upgrade/version] Found %d potential version compatibility errors but skipping since the --force flag is set: \n\n%v",len(versionSkewErrs.Skippable),kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
fmt.Printf("\t- OPTION 2: Run 'kubeadm config upload from-file' and specify the same config file you passed to 'kubeadm init' when you created your master.\n")
fmt.Printf("\t- OPTION 2: Run 'kubeadm config upload from-file' and specify the same config file you passed to 'kubeadm init' when you created your master.\n")
fmt.Printf("\t- OPTION 3: Pass a config file to 'kubeadm upgrade' using the --config flag.\n")
fmt.Printf("\t- OPTION 3: Pass a config file to 'kubeadm upgrade' using the --config flag.\n")
fmt.Println("")
fmt.Println("")
err=fmt.Errorf("the ConfigMap %q in the %s namespace used for getting configuration information was not found",constants.KubeadmConfigConfigMap,metav1.NamespaceSystem)
err=errors.Errorf("the ConfigMap %q in the %s namespace used for getting configuration information was not found",constants.KubeadmConfigConfigMap,metav1.NamespaceSystem)
returnnil,fmt.Errorf("there is no %s key in the %s ConfigMap. This API Server isn't set up for token bootstrapping, can't connect",bootstrapapi.KubeConfigKey,bootstrapapi.ConfigMapClusterInfo)
returnnil,errors.Errorf("there is no %s key in the %s ConfigMap. This API Server isn't set up for token bootstrapping, can't connect",
returnnil,fmt.Errorf("token id %q is invalid for this cluster or it has expired. Use \"kubeadm token create\" on the master node to creating a new valid token",token.ID)
returnnil,errors.Errorf("token id %q is invalid for this cluster or it has expired. Use \"kubeadm token create\" on the master node to creating a new valid token",token.ID)
returnnil,fmt.Errorf("expected the kubeconfig file in the %s configmap to have a single cluster, but it had %d",bootstrapapi.ConfigMapClusterInfo,len(insecureConfig.Clusters))
returnnil,errors.Errorf("expected the kubeconfig file in the %s configmap to have a single cluster, but it had %d",bootstrapapi.ConfigMapClusterInfo,len(insecureConfig.Clusters))
returnnil,fmt.Errorf("the second kubeconfig from the %s configmap (using validated TLS) was different from the first",bootstrapapi.ConfigMapClusterInfo)
returnnil,errors.Errorf("the second kubeconfig from the %s configmap (using validated TLS) was different from the first",bootstrapapi.ConfigMapClusterInfo)
returnnil,fmt.Errorf("couldn't parse the kubeconfig file in the %s configmap: %v",bootstrapapi.ConfigMapClusterInfo,err)
returnnil,errors.Wrapf(err,"couldn't parse the kubeconfig file in the %s configmap",bootstrapapi.ConfigMapClusterInfo)
}
}
fmt.Printf("[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server %q\n",endpoint)
fmt.Printf("[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server %q\n",endpoint)
returnnil,fmt.Errorf("error parsing APIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",cfg.APIEndpoint.AdvertiseAddress)
returnnil,errors.Errorf("error parsing APIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",
returnnil,fmt.Errorf("error parsing APIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",cfg.APIEndpoint.AdvertiseAddress)
returnnil,errors.Errorf("error parsing APIEndpoint AdvertiseAddress %v: is not a valid textual representation of an IP address",
returnfmt.Errorf("failed to create static pod manifest file for %q: %v",componentName,err)
returnerrors.Wrapf(err,"failed to create static pod manifest file for %q",componentName)
}
}
fmt.Printf("[controlplane] wrote Static Pod manifest for component %s to %q\n",componentName,kubeadmconstants.GetStaticPodFilepath(componentName,manifestDir))
fmt.Printf("[controlplane] wrote Static Pod manifest for component %s to %q\n",componentName,kubeadmconstants.GetStaticPodFilepath(componentName,manifestDir))
returnfmt.Errorf("The control plane seems to be Static Pod-hosted, but some of the manifests don't seem to exist on disk. This probably means you're running 'kubeadm upgrade' on a remote machine, which is not supported for a Static Pod-hosted cluster. Manifest files not found: %v",nonExistentManifests)
returnerrors.Errorf("The control plane seems to be Static Pod-hosted, but some of the manifests don't seem to exist on disk. This probably means you're running 'kubeadm upgrade' on a remote machine, which is not supported for a Static Pod-hosted cluster. Manifest files not found: %v",nonExistentManifests)
}
}
// IsControlPlaneSelfHosted returns whether the control plane is self hosted or not
// IsControlPlaneSelfHosted returns whether the control plane is self hosted or not
returnfmt.Errorf("current number of scheduled Pods ('%d') doesn't match the amount of desired Pods ('%d')",dsStatus.CurrentNumberScheduled,dsStatus.DesiredNumberScheduled)
returnerrors.Errorf("current number of scheduled Pods ('%d') doesn't match the amount of desired Pods ('%d')",
// This must not happen, kubeadm always supports a minimum version; and we can't go below that
// This must not happen, kubeadm always supports a minimum version; and we can't go below that
skewErrors.Mandatory=append(skewErrors.Mandatory,fmt.Errorf("Specified version to upgrade to %q is equal to or lower than the minimum supported version %q. Please specify a higher version to upgrade to",newK8sVersionStr,clusterVersionStr))
skewErrors.Mandatory=append(skewErrors.Mandatory,errors.Errorf("Specified version to upgrade to %q is equal to or lower than the minimum supported version %q. Please specify a higher version to upgrade to",newK8sVersionStr,clusterVersionStr))
}
}
// kubeadm doesn't support upgrades between two minor versions; e.g. a v1.7 -> v1.9 upgrade is not supported right away
// kubeadm doesn't support upgrades between two minor versions; e.g. a v1.7 -> v1.9 upgrade is not supported right away
tooLargeUpgradeSkewErr:=fmt.Errorf("Specified version to upgrade to %q is too high; kubeadm can upgrade only %d minor version at a time",newK8sVersionStr,MaximumAllowedMinorVersionUpgradeSkew)
tooLargeUpgradeSkewErr:=errors.Errorf("Specified version to upgrade to %q is too high; kubeadm can upgrade only %d minor version at a time",newK8sVersionStr,MaximumAllowedMinorVersionUpgradeSkew)
// If the version that we're about to upgrade to is a released version, we should fully enforce this policy
// If the version that we're about to upgrade to is a released version, we should fully enforce this policy
// If the version is a CI/dev/experimental version, it's okay to jump two minor version steps, but then require the -f flag
// If the version is a CI/dev/experimental version, it's okay to jump two minor version steps, but then require the -f flag
tooLargeDowngradeSkewErr:=fmt.Errorf("Specified version to downgrade to %q is too low; kubeadm can downgrade only %d minor version at a time",newK8sVersionStr,MaximumAllowedMinorVersionDowngradeSkew)
tooLargeDowngradeSkewErr:=errors.Errorf("Specified version to downgrade to %q is too low; kubeadm can downgrade only %d minor version at a time",newK8sVersionStr,MaximumAllowedMinorVersionDowngradeSkew)
// If the version that we're about to downgrade to is a released version, we should fully enforce this policy
// If the version that we're about to downgrade to is a released version, we should fully enforce this policy
// If the version is a CI/dev/experimental version, it's okay to jump two minor version steps, but then require the -f flag
// If the version is a CI/dev/experimental version, it's okay to jump two minor version steps, but then require the -f flag
// If the kubeadm version is lower than what we want to upgrade to; error
// If the kubeadm version is lower than what we want to upgrade to; error
ifkubeadmVersion.LessThan(newK8sVersion){
ifkubeadmVersion.LessThan(newK8sVersion){
ifnewK8sVersion.Minor()>kubeadmVersion.Minor(){
ifnewK8sVersion.Minor()>kubeadmVersion.Minor(){
tooLargeKubeadmSkew:=fmt.Errorf("Specified version to upgrade to %q is at least one minor release higher than the kubeadm minor release (%d > %d). Such an upgrade is not supported",newK8sVersionStr,newK8sVersion.Minor(),kubeadmVersion.Minor())
tooLargeKubeadmSkew:=errors.Errorf("Specified version to upgrade to %q is at least one minor release higher than the kubeadm minor release (%d > %d). Such an upgrade is not supported",newK8sVersionStr,newK8sVersion.Minor(),kubeadmVersion.Minor())
// This is unsupported; kubeadm has no idea how it should handle a newer minor release than itself
// This is unsupported; kubeadm has no idea how it should handle a newer minor release than itself
// If the version is a CI/dev/experimental version though, lower the severity of this check, but then require the -f flag
// If the version is a CI/dev/experimental version though, lower the severity of this check, but then require the -f flag
// Upgrading to a higher patch version than kubeadm is ok if the user specifies --force. Not recommended, but possible.
// Upgrading to a higher patch version than kubeadm is ok if the user specifies --force. Not recommended, but possible.
skewErrors.Skippable=append(skewErrors.Skippable,fmt.Errorf("Specified version to upgrade to %q is higher than the kubeadm version %q. Upgrade kubeadm first using the tool you used to install kubeadm",newK8sVersionStr,kubeadmVersionStr))
skewErrors.Skippable=append(skewErrors.Skippable,errors.Errorf("Specified version to upgrade to %q is higher than the kubeadm version %q. Upgrade kubeadm first using the tool you used to install kubeadm",newK8sVersionStr,kubeadmVersionStr))
}
}
}
}
ifkubeadmVersion.Major()>newK8sVersion.Major()||
ifkubeadmVersion.Major()>newK8sVersion.Major()||
kubeadmVersion.Minor()>newK8sVersion.Minor(){
kubeadmVersion.Minor()>newK8sVersion.Minor(){
skewErrors.Skippable=append(skewErrors.Skippable,fmt.Errorf("Kubeadm version %s can only be used to upgrade to Kubernetes version %d.%d",kubeadmVersionStr,kubeadmVersion.Major(),kubeadmVersion.Minor()))
skewErrors.Skippable=append(skewErrors.Skippable,errors.Errorf("Kubeadm version %s can only be used to upgrade to Kubernetes version %d.%d",kubeadmVersionStr,kubeadmVersion.Major(),kubeadmVersion.Minor()))
}
}
// Detect if the version is unstable and the user didn't allow that
// Detect if the version is unstable and the user didn't allow that
returnfmt.Errorf("Specified version to upgrade to %q is an unstable version and such upgrades weren't allowed via setting the --allow-*-upgrades flags",newK8sVersionStr)
returnerrors.Errorf("Specified version to upgrade to %q is an unstable version and such upgrades weren't allowed via setting the --allow-*-upgrades flags",newK8sVersionStr)
}
}
// detectTooOldKubelets errors out if the kubelet versions are so old that an unsupported skew would happen if the cluster was upgraded
// detectTooOldKubelets errors out if the kubelet versions are so old that an unsupported skew would happen if the cluster was upgraded
returnfalse,fmt.Errorf("the desired etcd version for this Kubernetes version %q is %q, but the current etcd version is %q. Won't downgrade etcd, instead just continue",cfg.KubernetesVersion,desiredEtcdVersion.String(),currentEtcdVersion.String())
returnfalse,errors.Errorf("the desired etcd version for this Kubernetes version %q is %q, but the current etcd version is %q. Won't downgrade etcd, instead just continue",cfg.KubernetesVersion,desiredEtcdVersion.String(),currentEtcdVersion.String())
}
}
// For the case when desired etcd version is the same as current etcd version
// For the case when desired etcd version is the same as current etcd version
returnnil,fmt.Errorf("didn't recognize types with GroupVersionKind: %v",gvks)
returnnil,errors.Errorf("didn't recognize types with GroupVersionKind: %v",gvks)
}
}
// MarshalKubeadmConfigObject marshals an Object registered in the kubeadm scheme. If the object is a InitConfiguration or ClusterConfiguration, some extra logic is run
// MarshalKubeadmConfigObject marshals an Object registered in the kubeadm scheme. If the object is a InitConfiguration or ClusterConfiguration, some extra logic is run
returnfmt.Errorf("your configuration file uses an old API spec: %q. Please use kubeadm %s instead and run 'kubeadm config migrate --old-config old.yaml --new-config new.yaml', which will write the new, similar spec using a newer API version.",gvk.GroupVersion().String(),useKubeadmVersion)
returnerrors.Errorf("your configuration file uses an old API spec: %q. Please use kubeadm %s instead and run 'kubeadm config migrate --old-config old.yaml --new-config new.yaml', which will write the new, similar spec using a newer API version.",gvk.GroupVersion().String(),useKubeadmVersion)
returnfmt.Errorf("this version of kubeadm only supports deploying clusters with the control plane version >= %s. Current version: %s",constants.MinimumControlPlaneVersion.String(),cfg.KubernetesVersion)
returnerrors.Errorf("this version of kubeadm only supports deploying clusters with the control plane version >= %s. Current version: %s",constants.MinimumControlPlaneVersion.String(),cfg.KubernetesVersion)
returnfmt.Errorf("couldn't use \"%s\" as \"apiserver-advertise-address\", must be ipv4 or ipv6 address",cfg.AdvertiseAddress)
returnerrors.Errorf("couldn't use \"%s\" as \"apiserver-advertise-address\", must be ipv4 or ipv6 address",cfg.AdvertiseAddress)
}
}
// This is the same logic as the API Server uses, except that if no interface is found the address is set to 0.0.0.0, which is invalid and cannot be used
// This is the same logic as the API Server uses, except that if no interface is found the address is set to 0.0.0.0, which is invalid and cannot be used
// Invalid: The caller asked to not print the componentconfigs if defaulted, but defaultComponentConfigs() wasn't able to create default objects to use for reference
// Invalid: The caller asked to not print the componentconfigs if defaulted, but defaultComponentConfigs() wasn't able to create default objects to use for reference
if!ok{
if!ok{
return[]byte{},fmt.Errorf("couldn't create a default componentconfig object")
return[]byte{},errors.New("couldn't create a default componentconfig object")
}
}
// If the real ComponentConfig object differs from the default, print it out. If not, there's no need to print it out, so skip it
// If the real ComponentConfig object differs from the default, print it out. If not, there's no need to print it out, so skip it
errs=append(errs,fmt.Errorf("invalid configuration: kind and apiVersion is mandatory information that needs to be specified in all YAML documents"))
errs=append(errs,pkgerrors.New("invalid configuration: kind and apiVersion is mandatory information that needs to be specified in all YAML documents"))
continue
continue
}
}
// Check whether the kind has been registered before. If it has, throw an error
// Check whether the kind has been registered before. If it has, throw an error
ifknown:=knownKinds[typeMetaInfo.Kind];known{
ifknown:=knownKinds[typeMetaInfo.Kind];known{
errs=append(errs,fmt.Errorf("invalid configuration: kind %q is specified twice in YAML file",typeMetaInfo.Kind))
errs=append(errs,pkgerrors.Errorf("invalid configuration: kind %q is specified twice in YAML file",typeMetaInfo.Kind))
continue
continue
}
}
knownKinds[typeMetaInfo.Kind]=true
knownKinds[typeMetaInfo.Kind]=true
...
@@ -110,7 +110,7 @@ func SplitYAMLDocuments(yamlBytes []byte) (map[schema.GroupVersionKind][]byte, e
...
@@ -110,7 +110,7 @@ func SplitYAMLDocuments(yamlBytes []byte) (map[schema.GroupVersionKind][]byte, e
// Build a GroupVersionKind object from the deserialized TypeMeta object
// Build a GroupVersionKind object from the deserialized TypeMeta object