mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Rename the constant that refers to the kubeadm-config
ConfigMap
This commit is contained in:
parent
6a8a8597f5
commit
824ed161d5
@ -70,7 +70,7 @@ func NewCmdConfig(out io.Writer) *cobra.Command {
|
|||||||
cluster. kubeadm CLI v1.8.0+ automatically creates this ConfigMap with the config used with 'kubeadm init', but if you
|
cluster. kubeadm CLI v1.8.0+ automatically creates this ConfigMap with the config used with 'kubeadm init', but if you
|
||||||
initialized your cluster using kubeadm v1.7.x or lower, you must use the 'config upload' command to create this
|
initialized your cluster using kubeadm v1.7.x or lower, you must use the 'config upload' command to create this
|
||||||
ConfigMap. This is required so that 'kubeadm upgrade' can configure your upgraded cluster correctly.
|
ConfigMap. This is required so that 'kubeadm upgrade' can configure your upgraded cluster correctly.
|
||||||
`), metav1.NamespaceSystem, constants.InitConfigurationConfigMap),
|
`), metav1.NamespaceSystem, constants.KubeadmConfigConfigMap),
|
||||||
// Without this callback, if a user runs just the "upload"
|
// Without this callback, if a user runs just the "upload"
|
||||||
// command without a subcommand, or with an invalid subcommand,
|
// command without a subcommand, or with an invalid subcommand,
|
||||||
// cobra will print usage information, but still exit cleanly.
|
// cobra will print usage information, but still exit cleanly.
|
||||||
@ -284,7 +284,7 @@ func NewCmdConfigView(out io.Writer, kubeConfigFile *string) *cobra.Command {
|
|||||||
Using this command, you can view the ConfigMap in the cluster where the configuration for kubeadm is located.
|
Using this command, you can view the ConfigMap in the cluster where the configuration for kubeadm is located.
|
||||||
|
|
||||||
The configuration is located in the %q namespace in the %q ConfigMap.
|
The configuration is located in the %q namespace in the %q ConfigMap.
|
||||||
`), metav1.NamespaceSystem, constants.InitConfigurationConfigMap),
|
`), metav1.NamespaceSystem, constants.KubeadmConfigConfigMap),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
glog.V(1).Infoln("[config] retrieving ClientSet from file")
|
glog.V(1).Infoln("[config] retrieving ClientSet from file")
|
||||||
client, err := kubeconfigutil.ClientSetFromFile(*kubeConfigFile)
|
client, err := kubeconfigutil.ClientSetFromFile(*kubeConfigFile)
|
||||||
@ -309,7 +309,7 @@ func NewCmdConfigUploadFromFile(out io.Writer, kubeConfigFile *string) *cobra.Co
|
|||||||
same config file before upgrading to v1.8 using 'kubeadm upgrade'.
|
same config file before upgrading to v1.8 using 'kubeadm upgrade'.
|
||||||
|
|
||||||
The configuration is located in the %q namespace in the %q ConfigMap.
|
The configuration is located in the %q namespace in the %q ConfigMap.
|
||||||
`), metav1.NamespaceSystem, constants.InitConfigurationConfigMap),
|
`), metav1.NamespaceSystem, constants.KubeadmConfigConfigMap),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if len(cfgPath) == 0 {
|
if len(cfgPath) == 0 {
|
||||||
kubeadmutil.CheckErr(fmt.Errorf("The --config flag is mandatory"))
|
kubeadmutil.CheckErr(fmt.Errorf("The --config flag is mandatory"))
|
||||||
@ -348,7 +348,7 @@ func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.C
|
|||||||
same flags before upgrading to v1.8 using 'kubeadm upgrade'.
|
same flags before upgrading to v1.8 using 'kubeadm upgrade'.
|
||||||
|
|
||||||
The configuration is located in the %q namespace in the %q ConfigMap.
|
The configuration is located in the %q namespace in the %q ConfigMap.
|
||||||
`), metav1.NamespaceSystem, constants.InitConfigurationConfigMap),
|
`), metav1.NamespaceSystem, constants.KubeadmConfigConfigMap),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var err error
|
var err error
|
||||||
glog.V(1).Infoln("[config] creating new FeatureGates")
|
glog.V(1).Infoln("[config] creating new FeatureGates")
|
||||||
@ -374,7 +374,7 @@ func NewCmdConfigUploadFromFlags(out io.Writer, kubeConfigFile *string) *cobra.C
|
|||||||
func RunConfigView(out io.Writer, client clientset.Interface) error {
|
func RunConfigView(out io.Writer, client clientset.Interface) error {
|
||||||
|
|
||||||
glog.V(1).Infoln("[config] getting the cluster configuration")
|
glog.V(1).Infoln("[config] getting the cluster configuration")
|
||||||
cfgConfigMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.InitConfigurationConfigMap, metav1.GetOptions{})
|
cfgConfigMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.KubeadmConfigConfigMap, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ var (
|
|||||||
This enables correct configuration of system components and a seamless user experience when upgrading.
|
This enables correct configuration of system components and a seamless user experience when upgrading.
|
||||||
|
|
||||||
Alternatively, you can use kubeadm config.
|
Alternatively, you can use kubeadm config.
|
||||||
`+cmdutil.AlphaDisclaimer), kubeadmconstants.InitConfigurationConfigMap, metav1.NamespaceSystem)
|
`+cmdutil.AlphaDisclaimer), kubeadmconstants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
|
||||||
|
|
||||||
uploadConfigExample = normalizer.Examples(`
|
uploadConfigExample = normalizer.Examples(`
|
||||||
# uploads the configuration of your cluster
|
# uploads the configuration of your cluster
|
||||||
|
@ -67,7 +67,7 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
|
|||||||
cfg, err := configutil.FetchConfigFromFileOrCluster(client, os.Stdout, "upgrade/config", flags.cfgPath, false)
|
cfg, err := configutil.FetchConfigFromFileOrCluster(client, os.Stdout, "upgrade/config", flags.cfgPath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
fmt.Printf("[upgrade/config] In order to upgrade, a ConfigMap called %q in the %s namespace must exist.\n", constants.InitConfigurationConfigMap, metav1.NamespaceSystem)
|
fmt.Printf("[upgrade/config] In order to upgrade, a ConfigMap called %q in the %s namespace must exist.\n", constants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
|
||||||
fmt.Println("[upgrade/config] Without this information, 'kubeadm upgrade' won't know how to configure your upgraded cluster.")
|
fmt.Println("[upgrade/config] Without this information, 'kubeadm upgrade' won't know how to configure your upgraded cluster.")
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
fmt.Println("[upgrade/config] Next steps:")
|
fmt.Println("[upgrade/config] Next steps:")
|
||||||
@ -75,7 +75,7 @@ func enforceRequirements(flags *applyPlanFlags, dryRun bool, newK8sVersion strin
|
|||||||
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.InitConfigurationConfigMap, metav1.NamespaceSystem)
|
err = fmt.Errorf("the ConfigMap %q in the %s namespace used for getting configuration information was not found", constants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("[upgrade/config] FATAL: %v", err)
|
return nil, fmt.Errorf("[upgrade/config] FATAL: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,8 @@ const (
|
|||||||
// init/join time for use later. kubeadm annotates the node object with this information
|
// init/join time for use later. kubeadm annotates the node object with this information
|
||||||
AnnotationKubeadmCRISocket = "kubeadm.alpha.kubernetes.io/cri-socket"
|
AnnotationKubeadmCRISocket = "kubeadm.alpha.kubernetes.io/cri-socket"
|
||||||
|
|
||||||
// InitConfigurationConfigMap specifies in what ConfigMap in the kube-system namespace the `kubeadm init` configuration should be stored
|
// KubeadmConfigConfigMap specifies in what ConfigMap in the kube-system namespace the `kubeadm init` configuration should be stored
|
||||||
// TODO: Rename this to KubeadmConfigConfigMap
|
KubeadmConfigConfigMap = "kubeadm-config"
|
||||||
InitConfigurationConfigMap = "kubeadm-config"
|
|
||||||
|
|
||||||
// ClusterConfigurationConfigMapKey specifies in what ConfigMap key the cluster configuration should be stored
|
// ClusterConfigurationConfigMapKey specifies in what ConfigMap key the cluster configuration should be stored
|
||||||
ClusterConfigurationConfigMapKey = "ClusterConfiguration"
|
ClusterConfigurationConfigMapKey = "ClusterConfiguration"
|
||||||
|
@ -42,7 +42,7 @@ const (
|
|||||||
|
|
||||||
// UploadConfiguration saves the InitConfiguration used for later reference (when upgrading for instance)
|
// UploadConfiguration saves the InitConfiguration used for later reference (when upgrading for instance)
|
||||||
func UploadConfiguration(cfg *kubeadmapi.InitConfiguration, client clientset.Interface) error {
|
func UploadConfiguration(cfg *kubeadmapi.InitConfiguration, client clientset.Interface) error {
|
||||||
fmt.Printf("[uploadconfig] storing the configuration used in ConfigMap %q in the %q Namespace\n", kubeadmconstants.InitConfigurationConfigMap, metav1.NamespaceSystem)
|
fmt.Printf("[uploadconfig] storing the configuration used in ConfigMap %q in the %q Namespace\n", kubeadmconstants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
|
||||||
|
|
||||||
// Prepare the ClusterConfiguration for upload
|
// Prepare the ClusterConfiguration for upload
|
||||||
// The components store their config in their own ConfigMaps, then reset the .ComponentConfig struct;
|
// The components store their config in their own ConfigMaps, then reset the .ComponentConfig struct;
|
||||||
@ -78,7 +78,7 @@ func UploadConfiguration(cfg *kubeadmapi.InitConfiguration, client clientset.Int
|
|||||||
|
|
||||||
err = apiclient.CreateOrUpdateConfigMap(client, &v1.ConfigMap{
|
err = apiclient.CreateOrUpdateConfigMap(client, &v1.ConfigMap{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: kubeadmconstants.InitConfigurationConfigMap,
|
Name: kubeadmconstants.KubeadmConfigConfigMap,
|
||||||
Namespace: metav1.NamespaceSystem,
|
Namespace: metav1.NamespaceSystem,
|
||||||
},
|
},
|
||||||
Data: map[string]string{
|
Data: map[string]string{
|
||||||
@ -97,7 +97,7 @@ func UploadConfiguration(cfg *kubeadmapi.InitConfiguration, client clientset.Int
|
|||||||
Namespace: metav1.NamespaceSystem,
|
Namespace: metav1.NamespaceSystem,
|
||||||
},
|
},
|
||||||
Rules: []rbac.PolicyRule{
|
Rules: []rbac.PolicyRule{
|
||||||
rbachelper.NewRule("get").Groups("").Resources("configmaps").Names(kubeadmconstants.InitConfigurationConfigMap).RuleOrDie(),
|
rbachelper.NewRule("get").Groups("").Resources("configmaps").Names(kubeadmconstants.KubeadmConfigConfigMap).RuleOrDie(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -134,7 +134,7 @@ func getClusterStatus(client clientset.Interface) (*kubeadmapi.ClusterStatus, er
|
|||||||
obj := &kubeadmapi.ClusterStatus{}
|
obj := &kubeadmapi.ClusterStatus{}
|
||||||
|
|
||||||
// Read the ConfigMap from the cluster
|
// Read the ConfigMap from the cluster
|
||||||
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(kubeadmconstants.InitConfigurationConfigMap, metav1.GetOptions{})
|
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(kubeadmconstants.KubeadmConfigConfigMap, metav1.GetOptions{})
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
return obj, nil
|
return obj, nil
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ func TestUploadConfiguration(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if tt.verifyResult {
|
if tt.verifyResult {
|
||||||
masterCfg, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(kubeadmconstants.InitConfigurationConfigMap, metav1.GetOptions{})
|
masterCfg, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(kubeadmconstants.KubeadmConfigConfigMap, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t2.Fatalf("Fail to query ConfigMap error = %v", err)
|
t2.Fatalf("Fail to query ConfigMap error = %v", err)
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ func createConfigMapWithStatus(statusToCreate *kubeadmapi.ClusterStatus, client
|
|||||||
|
|
||||||
return apiclient.CreateOrUpdateConfigMap(client, &v1.ConfigMap{
|
return apiclient.CreateOrUpdateConfigMap(client, &v1.ConfigMap{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: kubeadmconstants.InitConfigurationConfigMap,
|
Name: kubeadmconstants.KubeadmConfigConfigMap,
|
||||||
Namespace: metav1.NamespaceSystem,
|
Namespace: metav1.NamespaceSystem,
|
||||||
},
|
},
|
||||||
Data: map[string]string{
|
Data: map[string]string{
|
||||||
|
@ -61,7 +61,7 @@ func loadConfiguration(client clientset.Interface, w io.Writer, logPrefix, cfgPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, "[%s] Reading configuration from the cluster...\n", logPrefix)
|
fmt.Fprintf(w, "[%s] Reading configuration from the cluster...\n", logPrefix)
|
||||||
fmt.Fprintf(w, "[%s] FYI: You can look at this config file with 'kubectl -n %s get cm %s -oyaml'\n", logPrefix, metav1.NamespaceSystem, constants.InitConfigurationConfigMap)
|
fmt.Fprintf(w, "[%s] FYI: You can look at this config file with 'kubectl -n %s get cm %s -oyaml'\n", logPrefix, metav1.NamespaceSystem, constants.KubeadmConfigConfigMap)
|
||||||
return getInitConfigurationFromCluster(constants.KubernetesDir, client, newControlPlane)
|
return getInitConfigurationFromCluster(constants.KubernetesDir, client, newControlPlane)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func loadInitConfigurationFromFile(cfgPath string) (*kubeadmapi.InitConfiguratio
|
|||||||
func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Interface, newControlPlane bool) (*kubeadmapi.InitConfiguration, error) {
|
func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Interface, newControlPlane bool) (*kubeadmapi.InitConfiguration, error) {
|
||||||
// TODO: This code should support reading the MasterConfiguration key as well for backwards-compat
|
// TODO: This code should support reading the MasterConfiguration key as well for backwards-compat
|
||||||
// Also, the config map really should be KubeadmConfigConfigMap...
|
// Also, the config map really should be KubeadmConfigConfigMap...
|
||||||
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.InitConfigurationConfigMap, metav1.GetOptions{})
|
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.KubeadmConfigConfigMap, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ func TestGetAPIEndpoint(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "valid",
|
name: "valid",
|
||||||
configMap: fakeConfigMap{
|
configMap: fakeConfigMap{
|
||||||
name: kubeadmconstants.InitConfigurationConfigMap, // ClusterConfiguration from kubeadm-config.
|
name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
data: map[string]string{
|
data: map[string]string{
|
||||||
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1alpha3"]),
|
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1alpha3"]),
|
||||||
},
|
},
|
||||||
@ -375,7 +375,7 @@ func TestGetAPIEndpoint(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "invalid - No CLusterStatus in kubeadm-config ConfigMap",
|
name: "invalid - No CLusterStatus in kubeadm-config ConfigMap",
|
||||||
configMap: fakeConfigMap{
|
configMap: fakeConfigMap{
|
||||||
name: kubeadmconstants.InitConfigurationConfigMap, // ClusterConfiguration from kubeadm-config.
|
name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
data: map[string]string{},
|
data: map[string]string{},
|
||||||
},
|
},
|
||||||
expectedError: true,
|
expectedError: true,
|
||||||
@ -383,7 +383,7 @@ func TestGetAPIEndpoint(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "invalid - CLusterStatus without APIEndopoints",
|
name: "invalid - CLusterStatus without APIEndopoints",
|
||||||
configMap: fakeConfigMap{
|
configMap: fakeConfigMap{
|
||||||
name: kubeadmconstants.InitConfigurationConfigMap, // ClusterConfiguration from kubeadm-config.
|
name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
data: map[string]string{
|
data: map[string]string{
|
||||||
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1alpha3_Without_APIEndpoints"]),
|
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1alpha3_Without_APIEndpoints"]),
|
||||||
},
|
},
|
||||||
@ -520,7 +520,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
|||||||
name: "invalid - No CLusterConfiguration in kubeadm-config ConfigMap",
|
name: "invalid - No CLusterConfiguration in kubeadm-config ConfigMap",
|
||||||
configMaps: []fakeConfigMap{
|
configMaps: []fakeConfigMap{
|
||||||
{
|
{
|
||||||
name: kubeadmconstants.InitConfigurationConfigMap, // ClusterConfiguration from kubeadm-config.
|
name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
data: map[string]string{},
|
data: map[string]string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -530,7 +530,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
|||||||
name: "valid - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
name: "valid - new control plane == false", // InitConfiguration composed with data from different places, with also node specific information from ClusterStatus and node
|
||||||
configMaps: []fakeConfigMap{
|
configMaps: []fakeConfigMap{
|
||||||
{
|
{
|
||||||
name: kubeadmconstants.InitConfigurationConfigMap, // ClusterConfiguration from kubeadm-config.
|
name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
data: map[string]string{
|
data: map[string]string{
|
||||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1alpha3"]),
|
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1alpha3"]),
|
||||||
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1alpha3"]),
|
kubeadmconstants.ClusterStatusConfigMapKey: string(cfgFiles["ClusterStatus_v1alpha3"]),
|
||||||
@ -566,7 +566,7 @@ func TestGetInitConfigurationFromCluster(t *testing.T) {
|
|||||||
name: "valid - new control plane == true", // InitConfiguration composed with data from different places, without node specific information
|
name: "valid - new control plane == true", // InitConfiguration composed with data from different places, without node specific information
|
||||||
configMaps: []fakeConfigMap{
|
configMaps: []fakeConfigMap{
|
||||||
{
|
{
|
||||||
name: kubeadmconstants.InitConfigurationConfigMap, // ClusterConfiguration from kubeadm-config.
|
name: kubeadmconstants.KubeadmConfigConfigMap, // ClusterConfiguration from kubeadm-config.
|
||||||
data: map[string]string{
|
data: map[string]string{
|
||||||
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1alpha3"]),
|
kubeadmconstants.ClusterConfigurationConfigMapKey: string(cfgFiles["ClusterConfiguration_v1alpha3"]),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user