Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

Commit

Permalink
Ability for user to specify the expected public hostname for the cont…
Browse files Browse the repository at this point in the history
…roller
  • Loading branch information
rlisagor committed Apr 16, 2018
1 parent 2ae7229 commit a03372c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
9 changes: 9 additions & 0 deletions components/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ func LogPanic() {
logrus.Fatalf("%s: %s", r, debug.Stack())
}
}

func ArrayContains(haystack []string, needle string) bool {
for _, item := range haystack {
if item == needle {
return true
}
}
return false
}
1 change: 1 addition & 0 deletions components/installer/pkg/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type InstallerResponses struct {
PodSubnet string
ServiceSubnet string
PrivateGateway string
PublicHostname string
DNSDomain string
StorageSystemPercentage int
ControllerDisk string
Expand Down
24 changes: 16 additions & 8 deletions components/installer/pkg/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/cloudflare/cfssl/signer/local"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"

"github.com/paxautoma/operos/components/common"
)

func CreateControllerCerts(ctx *InstallerContext) error {
Expand Down Expand Up @@ -127,19 +129,25 @@ func createAPISigner(caCertBytes, caKeyBytes []byte) (signer.Signer, error) {
}

func createAPIServerCSR(ctx *InstallerContext) (csrBytes, keyBytes []byte, errOut error) {
hosts := []string{
ctx.Responses.ControllerIP,
ctx.Responses.KubeAPIServiceIP,
"127.0.0.1",
"localhost",
"kubernetes.default.svc",
}

if ctx.Responses.PublicHostname != "" && !common.ArrayContains(hosts, ctx.Responses.PublicHostname) {
hosts = append(hosts, ctx.Responses.PublicHostname)
}

req := &csr.CertificateRequest{
KeyRequest: &csr.BasicKeyRequest{
A: "rsa",
S: 2048,
},
Hosts: []string{
ctx.Responses.ControllerIP,
ctx.Responses.KubeAPIServiceIP,
"127.0.0.1",
"localhost",
"kubernetes.default.svc",
},
CN: fmt.Sprintf("%s (Controller Server)", ctx.Responses.OrgInfo.Cluster),
Hosts: hosts,
CN: fmt.Sprintf("%s (Controller Server)", ctx.Responses.OrgInfo.Cluster),
Names: []csr.Name{
{
C: ctx.Responses.OrgInfo.Country,
Expand Down
1 change: 1 addition & 0 deletions components/installer/pkg/screens/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func InstallScreen(screenSet *widgets.ScreenSet, context interface{}) *widgets.S
fmt.Sprintf("OPEROS_SERVICE_CIDR=%s", ctx.Responses.ServiceSubnet),
fmt.Sprintf("OPEROS_PRIVATE_GW=%s", ctx.Responses.PrivateGateway),
fmt.Sprintf("OPEROS_DNS_SERVICE_IP=%s", ctx.Responses.DNSIP),
fmt.Sprintf("OPEROS_PUBLIC_HOSTNAME=%s", ctx.Responses.PublicHostname),
fmt.Sprintf("OPEROS_DNS_DOMAIN=%s", ctx.Responses.DNSDomain),
fmt.Sprintf("OPEROS_WORKER_STORAGE_PERCENTAGE=%d", ctx.Responses.StorageSystemPercentage),
fmt.Sprintf("OPEROS_CLUSTER_NAME=%s", ctx.Responses.OrgInfo.Cluster),
Expand Down
5 changes: 4 additions & 1 deletion components/installer/pkg/screens/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ edit the values below.`
widgets.NewEditableListItem("Pod subnet", "pod-subnet", ctx.Responses.PodSubnet, widgets.ValidateIPNet),
widgets.NewEditableListItem("Service subnet", "service-subnet", ctx.Responses.ServiceSubnet, widgets.ValidateIPNet),
widgets.NewEditableListItem(gatewayLabel, "private-gateway", ctx.Responses.PrivateGateway, widgets.ValidateIP),
widgets.NewEditableListItem("Public hostname", "public-hostname", "", nil),
widgets.NewEditableListItem("DNS domain", "dns-domain", ctx.Responses.DNSDomain, widgets.ValidateNotEmpty),
}, 80, 7)
}, 80, 8)

errorList := widgets.NewPar("par-errors", "")
errorList.Bounds = image.Rect(1, 0, 79, 3)
Expand Down Expand Up @@ -411,6 +412,8 @@ edit the values below.`
ctx.Responses.DNSDomain = item.Value
case "private-gateway":
ctx.Responses.PrivateGateway = item.Value
case "public-hostname":
ctx.Responses.PublicHostname = item.Value
}

validate()
Expand Down

0 comments on commit a03372c

Please sign in to comment.