diff --git a/cmd/kubeadm/app/util/config/cluster.go b/cmd/kubeadm/app/util/config/cluster.go index 1c228b6a6a9..4547da040ee 100644 --- a/cmd/kubeadm/app/util/config/cluster.go +++ b/cmd/kubeadm/app/util/config/cluster.go @@ -60,7 +60,7 @@ func FetchInitConfigurationFromCluster(client clientset.Interface, printer outpu } _, _ = printer.Printf("[%s] Reading configuration from the %q ConfigMap in namespace %q...\n", logPrefix, constants.KubeadmConfigConfigMap, metav1.NamespaceSystem) - _, _ = printer.Printf("[%s] Use 'kubeadm init phase upload-config --config your-config.yaml' to re-upload it.\n", logPrefix) + _, _ = printer.Printf("[%s] Use 'kubeadm init phase upload-config --config your-config-file' to re-upload it.\n", logPrefix) // Fetch the actual config from cluster cfg, err := getInitConfigurationFromCluster(constants.KubernetesDir, client, newControlPlane, skipComponentConfigs) @@ -214,7 +214,7 @@ func GetNodeRegistration(kubeconfigFile string, client clientset.Interface, node // getNodeNameFromKubeletConfig gets the node name from a kubelet config file // TODO: in future we want to switch to a more canonical way for doing this e.g. by having this -// information in the local kubelet config.yaml +// information in the local kubelet config configuration file. func getNodeNameFromKubeletConfig(fileName string) (string, error) { // loads the kubelet.conf file config, err := clientcmd.LoadFromFile(fileName) diff --git a/cmd/kubeadm/app/util/config/common.go b/cmd/kubeadm/app/util/config/common.go index 4df881a0bcd..7edadd2d2fd 100644 --- a/cmd/kubeadm/app/util/config/common.go +++ b/cmd/kubeadm/app/util/config/common.go @@ -94,11 +94,11 @@ func validateSupportedVersion(gvk schema.GroupVersionKind, allowDeprecated, allo gvString := gvk.GroupVersion().String() if useKubeadmVersion := oldKnownAPIVersions[gvString]; useKubeadmVersion != "" { - return errors.Errorf("your configuration file uses an old API spec: %q (kind: %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.", gvString, gvk.Kind, useKubeadmVersion) + return errors.Errorf("your configuration file uses an old API spec: %q (kind: %q). Please use kubeadm %s instead and run 'kubeadm config migrate --old-config old-config-file --new-config new-config-file', which will write the new, similar spec using a newer API version.", gvString, gvk.Kind, useKubeadmVersion) } if _, present := deprecatedAPIVersions[gvString]; present && !allowDeprecated { - klog.Warningf("your configuration file uses a deprecated API spec: %q (kind: %q). Please use 'kubeadm config migrate --old-config old.yaml --new-config new.yaml', which will write the new, similar spec using a newer API version.", gvString, gvk.Kind) + klog.Warningf("your configuration file uses a deprecated API spec: %q (kind: %q). Please use 'kubeadm config migrate --old-config old-config-file --new-config new-config-file', which will write the new, similar spec using a newer API version.", gvString, gvk.Kind) } if _, present := experimentalAPIVersions[gvString]; present && !allowExperimental { diff --git a/cmd/kubeadm/app/util/config/initconfiguration.go b/cmd/kubeadm/app/util/config/initconfiguration.go index 1566b8b1b5f..203d219c1f9 100644 --- a/cmd/kubeadm/app/util/config/initconfiguration.go +++ b/cmd/kubeadm/app/util/config/initconfiguration.go @@ -291,7 +291,7 @@ func LoadOrDefaultInitConfiguration(cfgPath string, versionedInitCfg *kubeadmapi } // BytesToInitConfiguration converts a byte slice to an internal, defaulted and validated InitConfiguration object. -// The map may contain many different YAML documents. These YAML documents are parsed one-by-one +// The map may contain many different YAML/JSON documents. These YAML/JSON documents are parsed one-by-one // and well-known ComponentConfig GroupVersionKinds are stored inside of the internal InitConfiguration struct. // The resulting InitConfiguration is then dynamically defaulted and validated prior to return. func BytesToInitConfiguration(b []byte, skipCRIDetect bool) (*kubeadmapi.InitConfiguration, error) { @@ -303,7 +303,7 @@ func BytesToInitConfiguration(b []byte, skipCRIDetect bool) (*kubeadmapi.InitCon return documentMapToInitConfiguration(gvkmap, false, false, false, skipCRIDetect) } -// documentMapToInitConfiguration converts a map of GVKs and YAML documents to defaulted and validated configuration object. +// documentMapToInitConfiguration converts a map of GVKs and YAML/JSON documents to defaulted and validated configuration object. func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated, allowExperimental, strictErrors, skipCRIDetect bool) (*kubeadmapi.InitConfiguration, error) { var initcfg *kubeadmapi.InitConfiguration var clustercfg *kubeadmapi.ClusterConfiguration @@ -326,7 +326,7 @@ func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat return nil, err } - // verify the validity of the YAML + // verify the validity of the JSON/YAML if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme, componentconfigs.Scheme}, gvk, fileContent); err != nil { if !strictErrors { klog.Warning(err.Error()) @@ -358,13 +358,13 @@ func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat // If the group is neither a kubeadm core type or of a supported component config group, we dump a warning about it being ignored if !componentconfigs.Scheme.IsGroupRegistered(gvk.Group) { - klog.Warningf("[config] WARNING: Ignored YAML document with GroupVersionKind %v\n", gvk) + klog.Warningf("[config] WARNING: Ignored configuration document with GroupVersionKind %v\n", gvk) } } - // Enforce that InitConfiguration and/or ClusterConfiguration has to exist among the YAML documents + // Enforce that InitConfiguration and/or ClusterConfiguration has to exist among the configuration documents if initcfg == nil && clustercfg == nil { - return nil, errors.New("no InitConfiguration or ClusterConfiguration kind was found in the YAML file") + return nil, errors.New("no InitConfiguration or ClusterConfiguration kind was found in the configuration file") } // If InitConfiguration wasn't given, default it by creating an external struct instance, default it and convert into the internal type @@ -408,7 +408,7 @@ func documentMapToInitConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat } // MarshalInitConfigurationToBytes marshals the internal InitConfiguration object to bytes. It writes the embedded -// ClusterConfiguration object with ComponentConfigs out as separate YAML documents +// ClusterConfiguration object with ComponentConfigs out as separate YAML/JSON documents func MarshalInitConfigurationToBytes(cfg *kubeadmapi.InitConfiguration, gv schema.GroupVersion) ([]byte, error) { initbytes, err := kubeadmutil.MarshalToYamlForCodecs(cfg, gv, kubeadmscheme.Codecs) if err != nil { diff --git a/cmd/kubeadm/app/util/config/joinconfiguration.go b/cmd/kubeadm/app/util/config/joinconfiguration.go index 6aa4f4c5b74..133763074dd 100644 --- a/cmd/kubeadm/app/util/config/joinconfiguration.go +++ b/cmd/kubeadm/app/util/config/joinconfiguration.go @@ -95,7 +95,7 @@ func LoadJoinConfigurationFromFile(cfgPath string, opts LoadOrDefaultConfigurati return documentMapToJoinConfiguration(gvkmap, false, false, false, opts.SkipCRIDetect) } -// documentMapToJoinConfiguration takes a map between GVKs and YAML documents (as returned by SplitYAMLDocuments), +// documentMapToJoinConfiguration takes a map between GVKs and YAML/JSON documents (as returned by SplitYAMLDocuments), // finds a JoinConfiguration, decodes it, dynamically defaults it and then validates it prior to return. func documentMapToJoinConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated, allowExperimental, strictErrors, skipCRIDetect bool) (*kubeadmapi.JoinConfiguration, error) { joinBytes := []byte{} @@ -110,7 +110,7 @@ func documentMapToJoinConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecat return nil, err } - // verify the validity of the YAML + // verify the validity of the YAML/JSON if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme}, gvk, bytes); err != nil { if !strictErrors { klog.Warning(err.Error()) diff --git a/cmd/kubeadm/app/util/config/resetconfiguration.go b/cmd/kubeadm/app/util/config/resetconfiguration.go index 06616bc18e3..6e08b0b3c36 100644 --- a/cmd/kubeadm/app/util/config/resetconfiguration.go +++ b/cmd/kubeadm/app/util/config/resetconfiguration.go @@ -99,7 +99,7 @@ func LoadResetConfigurationFromFile(cfgPath string, opts LoadOrDefaultConfigurat return documentMapToResetConfiguration(gvkmap, false, opts.AllowExperimental, false, opts.SkipCRIDetect) } -// documentMapToResetConfiguration takes a map between GVKs and YAML documents (as returned by SplitYAMLDocuments), +// documentMapToResetConfiguration takes a map between GVKs and YAML/JSON documents (as returned by SplitYAMLDocuments), // finds a ResetConfiguration, decodes it, dynamically defaults it and then validates it prior to return. func documentMapToResetConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated, allowExperimental bool, strictErrors bool, skipCRIDetect bool) (*kubeadmapi.ResetConfiguration, error) { resetBytes := []byte{} @@ -114,7 +114,7 @@ func documentMapToResetConfiguration(gvkmap kubeadmapi.DocumentMap, allowDepreca return nil, err } - // verify the validity of the YAML + // verify the validity of the YAML/JSON if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme}, gvk, bytes); err != nil { if !strictErrors { klog.Warning(err.Error()) diff --git a/cmd/kubeadm/app/util/config/upgradeconfiguration.go b/cmd/kubeadm/app/util/config/upgradeconfiguration.go index c5688a551f7..19488422d4a 100644 --- a/cmd/kubeadm/app/util/config/upgradeconfiguration.go +++ b/cmd/kubeadm/app/util/config/upgradeconfiguration.go @@ -28,25 +28,19 @@ import ( kubeadmscheme "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme" kubeadmapiv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta4" "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation" - "k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs" "k8s.io/kubernetes/cmd/kubeadm/app/constants" kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util" "k8s.io/kubernetes/cmd/kubeadm/app/util/config/strict" ) -// documentMapToUpgradeConfiguration takes a map between GVKs and YAML documents (as returned by SplitYAMLDocuments), +// documentMapToUpgradeConfiguration takes a map between GVKs and YAML/JSON documents (as returned by SplitYAMLDocuments), // finds a UpgradeConfiguration, decodes it, dynamically defaults it and then validates it prior to return. func documentMapToUpgradeConfiguration(gvkmap kubeadmapi.DocumentMap, allowDeprecated bool) (*kubeadmapi.UpgradeConfiguration, error) { upgradeBytes := []byte{} for gvk, bytes := range gvkmap { - if kubeadmutil.GroupVersionKindsHasInitConfiguration(gvk) || kubeadmutil.GroupVersionKindsHasClusterConfiguration(gvk) || componentconfigs.Scheme.IsGroupRegistered(gvk.Group) { - klog.Warningf("[config] WARNING: YAML document with GroupVersionKind %v is deprecated for upgrade, please use config file with kind of UpgradeConfiguration instead \n", gvk) - continue - } - if gvk.Kind != constants.UpgradeConfigurationKind { - klog.Warningf("[config] WARNING: Ignored YAML document with GroupVersionKind %v\n", gvk) + klog.Warningf("[config] WARNING: Ignored configuration document with GroupVersionKind %v\n", gvk) continue } @@ -55,7 +49,7 @@ func documentMapToUpgradeConfiguration(gvkmap kubeadmapi.DocumentMap, allowDepre return nil, err } - // verify the validity of the YAML + // verify the validity of the YAML/JSON if err := strict.VerifyUnmarshalStrict([]*runtime.Scheme{kubeadmscheme.Scheme}, gvk, bytes); err != nil { klog.Warning(err.Error()) } @@ -99,7 +93,7 @@ func LoadUpgradeConfigurationFromFile(cfgPath string, _ LoadOrDefaultConfigurati return nil, errors.Wrapf(err, "unable to load config from file %q", cfgPath) } - // Split the YAML documents in the file into a DocumentMap + // Split the YAML/JSON documents in the file into a DocumentMap docmap, err := kubeadmutil.SplitYAMLDocuments(configBytes) if err != nil { return nil, err