Skip to content

Commit

Permalink
Merge pull request #35 from ibrokethecloud/support-v2.8.1
Browse files Browse the repository at this point in the history
instructions to patch local cluster resource for v2.8.1
  • Loading branch information
bk201 authored Jan 30, 2024
2 parents 1ae847b + 805ca0a commit 8961506
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/plan/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plan
import (
"context"
"fmt"
"strings"

"github.com/rancher/system-agent/pkg/applyinator"

Expand Down Expand Up @@ -134,6 +135,13 @@ func (p *plan) addInstructions(cfg *config.Config, dataDir string) error {
return err
}

// currently instruction is only needed for v2.8.x
if strings.HasPrefix(cfg.RancherVersion, "v2.8") {
if err := p.addInstruction(rancher.PatchLocalProvisioningClusterStatus(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
return err
}
}

if err := p.addInstruction(rancher.ToWaitSUCInstruction(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
return err
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/rancher/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,19 @@ func ToScaleUpFleetControllerInstruction(imageOverride, systemDefaultRegistry, k
Command: cmd,
}, nil
}

// Needs to patch status subresource
// k patch cluster.provisioning local -n fleet-local --subresource=status --type=merge --patch '{"status":{"fleetWorkspaceName": "fleet-local"}}'
func PatchLocalProvisioningClusterStatus(imageOverride, systemDefaultRegistry, k8sVersion string) (*applyinator.Instruction, error) {
cmd, err := self.Self()
if err != nil {
return nil, fmt.Errorf("resolving location of %s: %w", os.Args[0], err)
}
return &applyinator.Instruction{
Name: "wait-suc-plan-resolved",
SaveOutput: true,
Args: []string{"retry", kubectl.Command(k8sVersion), "-n", "fleet-local", "patch", "cluster.provisioning", "local", "--subresource=status", "--type=merge", "--patch", "{\"status\":{\"fleetWorkspaceName\": \"fleet-local\"}}"},
Env: kubectl.Env(k8sVersion),
Command: cmd,
}, nil
}
3 changes: 3 additions & 0 deletions pkg/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func ToBootstrapFile(config *config.Config, path string) (*applyinator.File, err
"metadata": map[string]interface{}{
"name": "local",
"namespace": "fleet-local",
"labels": map[string]interface{}{
"provisioning.cattle.io/management-cluster-name": "local",
},
},
"spec": map[string]interface{}{
"kubernetesVersion": k8sVersion,
Expand Down

0 comments on commit 8961506

Please sign in to comment.