Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add controller public address to spec.api.sans #83

Merged
merged 1 commit into from
Feb 9, 2021
Merged
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
17 changes: 8 additions & 9 deletions phase/configure_k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,19 @@ func addUnlessExist(slice *[]string, s string) {
}

func (p *ConfigureK0s) configFor(h *cluster.Host) (string, error) {
cfg := p.Config.Spec.K0s.Config

var sans []string

var addr string
if h.PrivateAddress != "" {
addr = h.PrivateAddress
} else {
addr = h.Address()
}

cfg := p.Config.Spec.K0s.Config

cfg.DigMapping("spec", "api")["address"] = addr
var sans []string
addUnlessExist(&sans, addr)

oldsans, ok := cfg.Dig("spec", "api", "sans").([]interface{})
if ok {
for _, v := range oldsans {
Expand All @@ -162,13 +164,10 @@ func (p *ConfigureK0s) configFor(h *cluster.Host) (string, error) {

var controllers cluster.Hosts = p.Config.Spec.Hosts.Controllers()
for _, c := range controllers {
var caddr string
addUnlessExist(&sans, c.Address())
if c.PrivateAddress != "" {
caddr = c.PrivateAddress
} else {
caddr = c.Address()
addUnlessExist(&sans, c.PrivateAddress)
}
addUnlessExist(&sans, caddr)
}
addUnlessExist(&sans, "127.0.0.1")
cfg.DigMapping("spec", "api")["sans"] = sans
Expand Down