Skip to content

Commit

Permalink
Add machine names as etcd name
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Pedriza <adripedriza@gmail.com>
  • Loading branch information
AdrianPedriza committed Oct 16, 2024
1 parent 8119f5b commit d2bdb80
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions internal/controller/bootstrap/controlplane_bootstrap_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ func (c *ControlPlaneController) Reconcile(ctx context.Context, req ctrl.Request
)

if config.Spec.K0s != nil {
storage, found, err := unstructured.NestedMap(config.Spec.K0s.Object, "spec", "storage", "etcd")
if err != nil {
return ctrl.Result{}, fmt.Errorf("error retrieving storage.etcd: %w", err)

}
if found && storage != nil {
err = unstructured.SetNestedField(config.Spec.K0s.Object, machine.Name, "spec", "storage", "etcd", "extraArgs", "name")
if err != nil {
return ctrl.Result{}, fmt.Errorf("error setting storage.etcd.extraArgs.name: %w", err)
}
}

nllbEnabled, found, err := unstructured.NestedBool(config.Spec.K0s.Object, "spec", "network", "nodeLocalLoadBalancing", "enabled")
if err != nil {
return ctrl.Result{}, fmt.Errorf("error getting nodeLocalLoadBalancing: %v", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/Masterminds/semver"
"github.com/google/uuid"
autopilot "github.com/k0sproject/k0s/pkg/apis/autopilot/v1beta2"
Expand All @@ -43,7 +45,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"strings"

bootstrapv1 "github.com/k0sproject/k0smotron/api/bootstrap/v1beta1"
cpv1beta1 "github.com/k0sproject/k0smotron/api/controlplane/v1beta1"
Expand Down
1 change: 1 addition & 0 deletions internal/controller/controlplane/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controlplane
import (
"context"
"fmt"

"github.com/imdario/mergo"

apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down

0 comments on commit d2bdb80

Please sign in to comment.