Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
cluster/apply: honor --upgrade-kubelets
Browse files Browse the repository at this point in the history
It was being ignored and kubelets were being upgraded no matter what.
  • Loading branch information
iaguis committed Jul 1, 2021
1 parent f1b6714 commit 5e4e3b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/cmd/cluster/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func Apply(contextLogger *log.Entry, options ApplyOptions) error {
if exists && !options.SkipControlPlaneUpdate && !c.platform.Meta().Managed {
fmt.Printf("\nEnsuring that cluster controlplane is up to date.\n")

if err := c.upgradeControlPlane(contextLogger, kubeconfig); err != nil {
if err := c.upgradeControlPlane(contextLogger, kubeconfig, options.UpgradeKubelets); err != nil {
return fmt.Errorf("running controlplane upgrade: %v", err)
}
}
Expand Down
4 changes: 3 additions & 1 deletion cli/cmd/cluster/certificate-rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ func rotateControlPlaneCerts(contextLogger *log.Entry, cc clusterConfig) error {

contextLogger.Log(log.InfoLevel, "Applying a controlplane update with the new CA")

if err := c.upgradeControlPlane(contextLogger, kubeconfig); err != nil {
upgradeKubelets := true

if err := c.upgradeControlPlane(contextLogger, kubeconfig, upgradeKubelets); err != nil {
return fmt.Errorf("running controlplane upgrade: %v", err)
}

Expand Down
7 changes: 6 additions & 1 deletion cli/cmd/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (cc clusterConfig) initialize(contextLogger *log.Entry) (*cluster, error) {

// upgradeControlPlane unpacks the controlplane charts for a given platform
// into user assets on disk.
func (c *cluster) upgradeControlPlane(contextLogger *log.Entry, kubeconfig []byte) error {
func (c *cluster) upgradeControlPlane(contextLogger *log.Entry, kubeconfig []byte, upgradeKubelets bool) error {
cu := controlplaneUpdater{
kubeconfig: kubeconfig,
assetDir: c.assetDir,
Expand All @@ -130,6 +130,11 @@ func (c *cluster) upgradeControlPlane(contextLogger *log.Entry, kubeconfig []byt
}

for _, cpChart := range c.platform.Meta().ControlplaneCharts {
// Skip kubelet if the user doesn't want to upgrade it.
if cpChart.Name == platform.KubeletChartName && !upgradeKubelets {
continue
}

if err := cu.upgradeComponent(cpChart.Name, cpChart.Namespace); err != nil {
return fmt.Errorf("upgrading controlplane component %q: %w", cpChart.Name, err)
}
Expand Down

0 comments on commit 5e4e3b2

Please sign in to comment.