returnnil,fmt.Errorf("didn't recognize types with GroupVersionKind: %v",gvks)
}
// DetectUnsupportedVersion reads YAML bytes, extracts the TypeMeta information and errors out with an user-friendly message if the API spec is too old for this kubeadm version
// TODO: On our way to making the kubeadm API beta and higher, give good user output in case they use an old config file with a new kubeadm version, and
// tell them how to upgrade. The support matrix will look something like this now and in the future:
// v1.10 and earlier: v1alpha1
// v1.11: v1alpha1 read-only, writes only v1alpha2 config
// v1.12: v1alpha2 read-only, writes only v1beta1 config. Warns if the user tries to use v1alpha1
// v1.13 and v1.14: v1beta1 read-only, writes only v1 config. Warns if the user tries to use v1alpha1 or v1alpha2.
// v1.15: v1 is the only supported format.
oldKnownAPIVersions:=map[string]string{
"kubeadm.k8s.io/v1alpha1":"v1.11",
}
// If we find an old API version in this gvk list, error out and tell the user why this doesn't work
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)
}
}
returnnil
}
// NormalizeKubernetesVersion resolves version labels, sets alternative
// image registry if requested for CI builds, and validates minimal
// version that kubeadm SetInitDynamicDefaultssupports.
returnfmt.Errorf("this version of kubeadm only supports deploying clusters with the control plane version >= %s. Current version: %s",constants.MinimumControlPlaneVersion.String(),cfg.KubernetesVersion)
}
returnnil
}
// LowercaseSANs can be used to force all SANs to be lowercase so it passes IsDNS1123Subdomain
funcLowercaseSANs(sans[]string){
fori,san:=rangesans{
lowercase:=strings.ToLower(san)
iflowercase!=san{
glog.V(1).Infof("lowercasing SAN %q to %q",san,lowercase)
// DetectUnsupportedVersion reads YAML bytes, extracts the TypeMeta information and errors out with an user-friendly message if the API spec is too old for this kubeadm version
// TODO: On our way to making the kubeadm API beta and higher, give good user output in case they use an old config file with a new kubeadm version, and
// tell them how to upgrade. The support matrix will look something like this now and in the future:
// v1.10 and earlier: v1alpha1
// v1.11: v1alpha1 read-only, writes only v1alpha2 config
// v1.12: v1alpha2 read-only, writes only v1beta1 config. Warns if the user tries to use v1alpha1
// v1.13 and v1.14: v1beta1 read-only, writes only v1 config. Warns if the user tries to use v1alpha1 or v1alpha2.
returnfmt.Errorf("your configuration file seem to use an old API spec. 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.",useKubeadmVersion)
}
returnnil
}
// NormalizeKubernetesVersion resolves version labels, sets alternative
// image registry if requested for CI builds, and validates minimal
returnfmt.Errorf("this version of kubeadm only supports deploying clusters with the control plane version >= %s. Current version: %s",kubeadmconstants.MinimumControlPlaneVersion.String(),cfg.KubernetesVersion)
}
returnnil
}
// LowercaseSANs can be used to force all SANs to be lowercase so it passes IsDNS1123Subdomain
funcLowercaseSANs(sans[]string){
fori,san:=rangesans{
lowercase:=strings.ToLower(san)
iflowercase!=san{
glog.V(1).Infof("lowercasing SAN %q to %q",san,lowercase)