Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions phase/configure_k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,10 @@ func (p *ConfigureK0s) configFor(h *cluster.Host) (string, error) {
}
}

if cfg.Dig("spec", "storage", "etcd", "peerAddress") != nil || h.PrivateAddress != "" {
cfg.DigMapping("spec", "storage", "etcd")["peerAddress"] = addr
if p.Config.StorageType() == "etcd" {
if cfg.Dig("spec", "storage", "etcd", "peerAddress") != nil || h.PrivateAddress != "" {
cfg.DigMapping("spec", "storage", "etcd")["peerAddress"] = addr
}
}

if _, ok := cfg["apiVersion"]; !ok {
Expand Down
23 changes: 23 additions & 0 deletions pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,26 @@ func (c *Cluster) Validate() error {
validation.Field(&c.Spec),
)
}

// StorageType returns the k0s storage type.
func (c *Cluster) StorageType() string {
if c.Spec == nil {
// default to etcd when there's no hosts or k0s spec, this should never happen.
return "etcd"
}

if c.Spec.K0s != nil {
if t := c.Spec.K0s.Config.DigString("spec", "storage", "type"); t != "" {
// if storage type is set in k0s spec, return it
return t
}
}

if h := c.Spec.K0sLeader(); h != nil && h.Role == "single" {
// default to "kine" on single node clusters
return "kine"
}

// default to etcd otherwise
return "etcd"
}
Loading