mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
kubeadm: improve some grammar issues
This commit is contained in:
parent
ea61d04db1
commit
da234c9b23
@ -106,7 +106,7 @@ func runCoreDNSAddon(c workflow.RunData) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// runKubeProxyAddon upgrades the KubeProxy addon.
|
// runKubeProxyAddon upgrades the kube-proxy addon.
|
||||||
func runKubeProxyAddon(c workflow.RunData) error {
|
func runKubeProxyAddon(c workflow.RunData) error {
|
||||||
cfg, client, _, out, dryRun, err := getInitData(c)
|
cfg, client, _, out, dryRun, err := getInitData(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
kubeletConfigLongDesc = cmdutil.LongDesc(`
|
kubeletConfigLongDesc = cmdutil.LongDesc(`
|
||||||
Download the kubelet configuration from the kubelet-config ConfigMap stored in the cluster
|
Upgrade the kubelet configuration for this node by downloading it from the kubelet-config ConfigMap stored in the cluster
|
||||||
`)
|
`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
func NewPostUpgradePhase() workflow.Phase {
|
func NewPostUpgradePhase() workflow.Phase {
|
||||||
return workflow.Phase{
|
return workflow.Phase{
|
||||||
Name: "post-upgrade",
|
Name: "post-upgrade",
|
||||||
Short: "Run the post upgrade tasks",
|
Short: "Run post upgrade tasks",
|
||||||
Run: runPostUpgrade,
|
Run: runPostUpgrade,
|
||||||
InheritFlags: []string{
|
InheritFlags: []string{
|
||||||
options.CfgPath,
|
options.CfgPath,
|
||||||
@ -43,7 +43,7 @@ func runPostUpgrade(c workflow.RunData) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("preflight phase invoked with an invalid data struct")
|
return errors.New("preflight phase invoked with an invalid data struct")
|
||||||
}
|
}
|
||||||
// TODO: add the post upgrade tasks here when needed
|
// PLACEHOLDER: this phase should contain any release specific post-upgrade tasks.
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -68,30 +68,30 @@ func runPreflight(c workflow.RunData) error {
|
|||||||
|
|
||||||
initCfg, client, ignorePreflightErrors := data.InitCfg(), data.Client(), data.IgnorePreflightErrors()
|
initCfg, client, ignorePreflightErrors := data.InitCfg(), data.Client(), data.IgnorePreflightErrors()
|
||||||
|
|
||||||
// First, check if we're root separately from the other preflight checks and fail fast
|
// First, check if we're root separately from the other preflight checks and fail fast.
|
||||||
if err := preflight.RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
if err := preflight.RunRootCheckOnly(ignorePreflightErrors); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run CoreDNS migration check
|
// Run CoreDNS migration check.
|
||||||
if err := upgrade.RunCoreDNSMigrationCheck(client, ignorePreflightErrors); err != nil {
|
if err := upgrade.RunCoreDNSMigrationCheck(client, ignorePreflightErrors); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run healthchecks against the cluster
|
// Run healthchecks against the cluster.
|
||||||
klog.V(1).Infoln("[upgrade/preflight] Verifying the cluster health")
|
klog.V(1).Infoln("[upgrade/preflight] Verifying the cluster health")
|
||||||
if err := upgrade.CheckClusterHealth(client, &initCfg.ClusterConfiguration, ignorePreflightErrors, printer); err != nil {
|
if err := upgrade.CheckClusterHealth(client, &initCfg.ClusterConfiguration, ignorePreflightErrors, printer); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if feature gate flags used in the cluster are consistent with the set of features currently supported by kubeadm
|
// Check if feature gate flags used in the cluster are consistent with the set of features currently supported by kubeadm.
|
||||||
if msg := features.CheckDeprecatedFlags(&features.InitFeatureGates, initCfg.FeatureGates); len(msg) > 0 {
|
if msg := features.CheckDeprecatedFlags(&features.InitFeatureGates, initCfg.FeatureGates); len(msg) > 0 {
|
||||||
for _, m := range msg {
|
for _, m := range msg {
|
||||||
_, _ = printer.Printf("[upgrade/preflight] %s\n", m)
|
_, _ = printer.Printf("[upgrade/preflight] %s\n", m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate requested and validate actual version
|
// Validate requested and validate actual version.
|
||||||
klog.V(1).Infoln("[upgrade/preflight] Validating requested and actual version")
|
klog.V(1).Infoln("[upgrade/preflight] Validating requested and actual version")
|
||||||
if err := configutil.NormalizeKubernetesVersion(&initCfg.ClusterConfiguration); err != nil {
|
if err := configutil.NormalizeKubernetesVersion(&initCfg.ClusterConfiguration); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -132,8 +132,8 @@ func runPreflight(c workflow.RunData) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// enforceVersionPolicies makes sure that the version the user specified is valid to upgrade to
|
// enforceVersionPolicies makes sure that the version the user specified is valid to upgrade to.
|
||||||
// There are both fatal and skippable (with --force) errors
|
// It handles both fatal and skippable (with --force) errors.
|
||||||
func enforceVersionPolicies(newK8sVersionStr string, newK8sVersion *version.Version, allowExperimentalUpgrades, allowRCUpgrades, force bool, versionGetter upgrade.VersionGetter) error {
|
func enforceVersionPolicies(newK8sVersionStr string, newK8sVersion *version.Version, allowExperimentalUpgrades, allowRCUpgrades, force bool, versionGetter upgrade.VersionGetter) error {
|
||||||
fmt.Printf("[upgrade/preflight] You have chosen to upgrade the cluster version to %q\n", newK8sVersionStr)
|
fmt.Printf("[upgrade/preflight] You have chosen to upgrade the cluster version to %q\n", newK8sVersionStr)
|
||||||
|
|
||||||
@ -146,12 +146,12 @@ func enforceVersionPolicies(newK8sVersionStr string, newK8sVersion *version.Vers
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(versionSkewErrs.Skippable) > 0 {
|
if len(versionSkewErrs.Skippable) > 0 {
|
||||||
// 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 !force {
|
if !force {
|
||||||
return errors.Errorf("the version argument is invalid due to these errors:\n\n%v\nCan be bypassed if you pass the --force flag",
|
return errors.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))
|
kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
|
||||||
}
|
}
|
||||||
// Soft errors found, but --force was specified
|
// Soft errors found, but --force was specified.
|
||||||
fmt.Printf("[upgrade/preflight] 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/preflight] Found %d potential version compatibility errors but skipping since the --force flag is set: \n\n%v", len(versionSkewErrs.Skippable), kubeadmutil.FormatErrMsg(versionSkewErrs.Skippable))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func getUploadConfigPhaseFlags() []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// runUploadKubeadmConfig uploads the kubeadm configuration to a ConfigMap
|
// runUploadKubeadmConfig uploads the kubeadm configuration to a ConfigMap.
|
||||||
func runUploadKubeadmConfig(c workflow.RunData) error {
|
func runUploadKubeadmConfig(c workflow.RunData) error {
|
||||||
cfg, client, dryRun, err := getUploadConfigData(c)
|
cfg, client, dryRun, err := getUploadConfigData(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -91,7 +91,7 @@ func runUploadKubeadmConfig(c workflow.RunData) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// runUploadKubeletConfig uploads the kubelet configuration to a ConfigMap
|
// runUploadKubeletConfig uploads the kubelet configuration to a ConfigMap.
|
||||||
func runUploadKubeletConfig(c workflow.RunData) error {
|
func runUploadKubeletConfig(c workflow.RunData) error {
|
||||||
cfg, client, dryRun, err := getUploadConfigData(c)
|
cfg, client, dryRun, err := getUploadConfigData(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -109,7 +109,7 @@ func runUploadKubeletConfig(c workflow.RunData) error {
|
|||||||
return errors.Wrap(err, "error creating kubelet configuration ConfigMap")
|
return errors.Wrap(err, "error creating kubelet configuration ConfigMap")
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(1).Infoln("[upgrade/upload-config] Preserving the CRISocket information for the control-plane node")
|
klog.V(1).Infoln("[upgrade/upload-config] Preserving the CRISocket information for this control-plane node")
|
||||||
if err := patchnodephase.AnnotateCRISocket(client, cfg.NodeRegistration.Name, cfg.NodeRegistration.CRISocket); err != nil {
|
if err := patchnodephase.AnnotateCRISocket(client, cfg.NodeRegistration.Name, cfg.NodeRegistration.CRISocket); err != nil {
|
||||||
return errors.Wrap(err, "error writing Crisocket information for the control-plane node")
|
return errors.Wrap(err, "error writing Crisocket information for the control-plane node")
|
||||||
}
|
}
|
||||||
|
@ -139,8 +139,8 @@ func newCmdApply(apf *applyPlanFlags) *cobra.Command {
|
|||||||
applyRunner.AppendPhase(phases.NewAddonPhase())
|
applyRunner.AppendPhase(phases.NewAddonPhase())
|
||||||
applyRunner.AppendPhase(phases.NewPostUpgradePhase())
|
applyRunner.AppendPhase(phases.NewPostUpgradePhase())
|
||||||
|
|
||||||
// Sets the data builder function, that will be used by the runner
|
// Sets the data builder function, that will be used by the runner,
|
||||||
// both when running the entire workflow or single phases
|
// both when running the entire workflow or single phases.
|
||||||
applyRunner.SetDataInitializer(func(cmd *cobra.Command, args []string) (workflow.RunData, error) {
|
applyRunner.SetDataInitializer(func(cmd *cobra.Command, args []string) (workflow.RunData, error) {
|
||||||
data, err := newApplyData(cmd, args, flags)
|
data, err := newApplyData(cmd, args, flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -154,7 +154,7 @@ func newCmdApply(apf *applyPlanFlags) *cobra.Command {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Binds the Runner to kubeadm upgrade apply command by altering
|
// Binds the Runner to kubeadm upgrade apply command by altering
|
||||||
// command help, adding --skip-phases flag and by adding phases subcommands
|
// command help, adding --skip-phases flag and by adding phases subcommands.
|
||||||
applyRunner.BindToCommand(cmd)
|
applyRunner.BindToCommand(cmd)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
@ -170,7 +170,7 @@ func newApplyData(cmd *cobra.Command, args []string, applyFlags *applyFlags) (*a
|
|||||||
}
|
}
|
||||||
|
|
||||||
upgradeVersion := upgradeCfg.Apply.KubernetesVersion
|
upgradeVersion := upgradeCfg.Apply.KubernetesVersion
|
||||||
// The version arg is mandatory, unless it's specified in the config file
|
// The version arg is mandatory, unless it's specified in the config file.
|
||||||
if upgradeVersion == "" {
|
if upgradeVersion == "" {
|
||||||
if err := cmdutil.ValidateExactArgNumber(args, []string{"version"}); err != nil {
|
if err := cmdutil.ValidateExactArgNumber(args, []string{"version"}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -229,7 +229,7 @@ func newApplyData(cmd *cobra.Command, args []string, applyFlags *applyFlags) (*a
|
|||||||
|
|
||||||
printer := &output.TextPrinter{}
|
printer := &output.TextPrinter{}
|
||||||
|
|
||||||
// Fetches the cluster configuration
|
// Fetches the cluster configuration.
|
||||||
klog.V(1).Infoln("[upgrade] retrieving configuration from cluster")
|
klog.V(1).Infoln("[upgrade] retrieving configuration from cluster")
|
||||||
initCfg, err := configutil.FetchInitConfigurationFromCluster(client, nil, "upgrade", false, false)
|
initCfg, err := configutil.FetchInitConfigurationFromCluster(client, nil, "upgrade", false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -238,7 +238,7 @@ func newApplyData(cmd *cobra.Command, args []string, applyFlags *applyFlags) (*a
|
|||||||
_, _ = printer.Printf("[upgrade] Use 'kubeadm init phase upload-config --config your-config.yaml' to re-upload it.\n")
|
_, _ = printer.Printf("[upgrade] Use 'kubeadm init phase upload-config --config your-config.yaml' to re-upload it.\n")
|
||||||
err = errors.Errorf("the ConfigMap %q in the %q namespace was not found", constants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
|
err = errors.Errorf("the ConfigMap %q in the %q namespace was not found", constants.KubeadmConfigConfigMap, metav1.NamespaceSystem)
|
||||||
}
|
}
|
||||||
return nil, errors.Wrap(err, "[upgrade/init config] FATAL")
|
return nil, errors.Wrap(err, "[upgrade] FATAL")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also set the union of pre-flight errors to InitConfiguration, to provide a consistent view of the runtime configuration:
|
// Also set the union of pre-flight errors to InitConfiguration, to provide a consistent view of the runtime configuration:
|
||||||
|
@ -112,7 +112,7 @@ func TestNewApplyData(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
// initialize an external apply flags and inject it to the apply cmd
|
// Initialize an external apply flags and inject it to the apply cmd.
|
||||||
apf := &applyPlanFlags{
|
apf := &applyPlanFlags{
|
||||||
kubeConfigPath: kubeadmconstants.GetAdminKubeConfigPath(),
|
kubeConfigPath: kubeadmconstants.GetAdminKubeConfigPath(),
|
||||||
cfgPath: "",
|
cfgPath: "",
|
||||||
@ -125,7 +125,7 @@ func TestNewApplyData(t *testing.T) {
|
|||||||
|
|
||||||
cmd := newCmdApply(apf)
|
cmd := newCmdApply(apf)
|
||||||
|
|
||||||
// sets cmd flags (that will be reflected on the init options)
|
// Sets cmd flags (that will be reflected on the init options).
|
||||||
for f, v := range tc.flags {
|
for f, v := range tc.flags {
|
||||||
_ = cmd.Flags().Set(f, v)
|
_ = cmd.Flags().Set(f, v)
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ func TestNewApplyData(t *testing.T) {
|
|||||||
renewCerts: true,
|
renewCerts: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// test newApplyData method
|
// Test newApplyData method.
|
||||||
data, err := newApplyData(cmd, tc.args, flags)
|
data, err := newApplyData(cmd, tc.args, flags)
|
||||||
if err == nil && len(tc.expectedError) != 0 {
|
if err == nil && len(tc.expectedError) != 0 {
|
||||||
t.Error("Expected error, but got success")
|
t.Error("Expected error, but got success")
|
||||||
@ -145,7 +145,7 @@ func TestNewApplyData(t *testing.T) {
|
|||||||
t.Fatalf("newApplyData returned unexpected error, expected: %s, got %v", tc.expectedError, err)
|
t.Fatalf("newApplyData returned unexpected error, expected: %s, got %v", tc.expectedError, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec additional validation on the returned value
|
// Exec additional validation on the returned value.
|
||||||
if tc.validate != nil {
|
if tc.validate != nil {
|
||||||
tc.validate(t, data)
|
tc.validate(t, data)
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func AllowBootstrapTokensToPostCSRs(client clientset.Interface) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AllowBootstrapTokensToGetNodes creates RBAC rules to allow Node Bootstrap Tokens to list nodes
|
// AllowBootstrapTokensToGetNodes creates RBAC rules to allow Node Bootstrap Tokens to list nodes.
|
||||||
func AllowBootstrapTokensToGetNodes(client clientset.Interface) error {
|
func AllowBootstrapTokensToGetNodes(client clientset.Interface) error {
|
||||||
fmt.Println("[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes")
|
fmt.Println("[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes")
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ func PerformAddonsUpgrade(client clientset.Interface, cfg *kubeadmapi.InitConfig
|
|||||||
return errorsutil.NewAggregate(errs)
|
return errorsutil.NewAggregate(errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnupgradedControlPlaneInstances returns a list of control palne instances that have not yet been upgraded.
|
// UnupgradedControlPlaneInstances returns a list of control plane instances that have not yet been upgraded.
|
||||||
//
|
//
|
||||||
// NB. This function can only be called after the current control plane instance has been upgraded already.
|
// NB. This function can only be called after the current control plane instance has been upgraded already.
|
||||||
// Because it determines whether the other control plane instances have been upgraded by checking whether
|
// Because it determines whether the other control plane instances have been upgraded by checking whether
|
||||||
|
Loading…
Reference in New Issue
Block a user