Skip to content

Commit

Permalink
Restart fleet-controller while setting client secret
Browse files Browse the repository at this point in the history
Restarting fleet-controller speed up the bootstrap process.

Signed-off-by: Kiefer Chang <[email protected]>
  • Loading branch information
bk201 authored and guangbochen committed Jun 15, 2023
1 parent 26d06f3 commit f70e187
Show file tree
Hide file tree
Showing 2 changed files with 36 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 @@ -111,10 +111,18 @@ func (p *plan) addInstructions(cfg *config.Config, dataDir string) error {
return err
}

if err := p.addInstruction(rancher.ToScaleDownFleetControllerInstruction(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
return err
}

if err := p.addInstruction(rancher.ToUpdateClientSecretInstruction(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
return err
}

if err := p.addInstruction(rancher.ToScaleUpFleetControllerInstruction(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion)); err != nil {
return err
}

if err := p.addInstruction(resources.ToInstruction(cfg.RancherInstallerImage, cfg.SystemDefaultRegistry, k8sVersion, dataDir)); err != nil {
return err
}
Expand Down
28 changes: 28 additions & 0 deletions pkg/rancher/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,31 @@ func ToUpdateClientSecretInstruction(imageOverride, systemDefaultRegistry, k8sVe
Command: cmd,
}, nil
}

func ToScaleDownFleetControllerInstruction(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: "scale-down-fleet-controller",
SaveOutput: true,
Args: []string{"retry", kubectl.Command(k8sVersion), "-n", "cattle-fleet-system", "scale", "--replicas", "0", "deploy/fleet-controller"},
Env: kubectl.Env(k8sVersion),
Command: cmd,
}, nil
}

func ToScaleUpFleetControllerInstruction(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: "scale-up-fleet-controller",
SaveOutput: true,
Args: []string{"retry", kubectl.Command(k8sVersion), "-n", "cattle-fleet-system", "scale", "--replicas", "1", "deploy/fleet-controller"},
Env: kubectl.Env(k8sVersion),
Command: cmd,
}, nil
}

0 comments on commit f70e187

Please sign in to comment.