Skip to content

Commit

Permalink
chore: increase replicas to 2 for capi controller manager services (k…
Browse files Browse the repository at this point in the history
…ubernetes-sigs#362)

* chore: increase replicas to 2 for capi controller manager services

* refactor

* review CHANGELOG

* refactor

---------

Co-authored-by: stg <[email protected]>
  • Loading branch information
esierra-stratio and stg-0 authored Nov 13, 2023
1 parent 231b085 commit 395441a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.17.0-0.3.4 (upcoming)

* [Core] Conditionally increase replicas for capi controller manager services

## 0.17.0-0.3.3 (2023-10-11)

* Add remote command execution retries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,9 @@ func (a *action) Execute(ctx *actions.ActionContext) error {
return err
}

// Scale CAPI to 2 replicas
c = "kubectl --kubeconfig " + kubeconfigPath + " -n capi-system scale --replicas 2 deploy capi-controller-manager"
_, err = commons.ExecuteCommand(n, c)
err = provider.configHACAPI(n, kubeconfigPath)
if err != nil {
return errors.Wrap(err, "failed to scale the CAPI Deployment")
return err
}

// Allow egress in CAPI's Namespaces
Expand Down
36 changes: 36 additions & 0 deletions pkg/cluster/internal/create/actions/createworker/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"embed"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"path/filepath"
"time"
Expand Down Expand Up @@ -504,6 +505,41 @@ func (p *Provider) installCAPXWorker(n nodes.Node, kubeconfigPath string, allowA
return nil
}

func (p *Provider) configHACAPI(n nodes.Node, kubeconfigPath string) error {
var c string
var err error
var capiKubeadmReplicas int

// Determine the number of replicas for capi-kubeadm deployments
if p.capxManaged {
capiKubeadmReplicas = 0
} else {
capiKubeadmReplicas = 2
}

// Scale capi-controller-manager to 2 replicas
c = fmt.Sprintf("kubectl --kubeconfig %s -n capi-system scale --replicas 2 deploy capi-controller-manager", kubeconfigPath)
_, err = commons.ExecuteCommand(n, c)
if err != nil {
return errors.Wrap(err, "failed to scale the CAPI Deployment")
}

// Scale capi-kubeadm-control-plane to 2 replicas
c = fmt.Sprintf("kubectl --kubeconfig %s -n capi-kubeadm-control-plane-system scale --replicas %d deploy capi-kubeadm-control-plane-controller-manager", kubeconfigPath, capiKubeadmReplicas)
_, err = commons.ExecuteCommand(n, c)
if err != nil {
return errors.Wrap(err, "failed to scale the capi-kubeadm-control-plane Deployment")
}

// Scale capi-kubeadm-bootstrap to 2 replicas
c = fmt.Sprintf("kubectl --kubeconfig %s -n capi-kubeadm-bootstrap-system scale --replicas %d deploy capi-kubeadm-bootstrap-controller-manager", kubeconfigPath, capiKubeadmReplicas)
_, err = commons.ExecuteCommand(n, c)
if err != nil {
return errors.Wrap(err, "failed to scale the capi-kubeadm-bootstrap Deployment")
}
return nil
}

// installCAPXLocal installs CAPX in the local cluster
func (p *Provider) installCAPXLocal(n nodes.Node) error {
var c string
Expand Down

0 comments on commit 395441a

Please sign in to comment.