Skip to content

Commit

Permalink
Merge pull request kubernetes#26 from jimmidyson/router-domain
Browse files Browse the repository at this point in the history
Set router subdomain to <ip>.xip.io by default
  • Loading branch information
jimmidyson authored Jul 18, 2016
2 parents 2165b4b + a94b5d7 commit 5cfd871
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
8 changes: 7 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ func runStart(cmd *cobra.Command, args []string) {
os.Exit(1)
}

if err := cluster.StartCluster(host); err != nil {
kubeIP, err := host.Driver.GetIP()
if err != nil {
glog.Errorln("Error connecting to cluster: ", err)
os.Exit(1)
}
if err := cluster.StartCluster(host, kubeIP); err != nil {
glog.Errorln("Error starting cluster: ", err)
os.Exit(1)
}

kubeHost, err := host.Driver.GetURL()
if err != nil {
glog.Errorln("Error connecting to cluster: ", err)
os.Exit(1)
}
kubeHost = strings.Replace(kubeHost, "tcp://", "https://", -1)
kubeHost = strings.Replace(kubeHost, ":2376", ":"+strconv.Itoa(constants.APIServerPort), -1)
Expand Down
4 changes: 2 additions & 2 deletions pkg/minikube/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ type MachineConfig struct {
}

// StartCluster starts a k8s cluster on the specified Host.
func StartCluster(h sshAble) error {
commands := []string{stopCommand, GetStartCommand()}
func StartCluster(h sshAble, ip string) error {
commands := []string{stopCommand, GetStartCommand(ip)}

for _, cmd := range commands {
glog.Infoln(cmd)
Expand Down
6 changes: 3 additions & 3 deletions pkg/minikube/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ func TestCreateHost(t *testing.T) {

func TestStartCluster(t *testing.T) {
h := tests.NewMockHost()
err := StartCluster(h)
err := StartCluster(h, "127.0.0.1")
if err != nil {
t.Fatalf("Error starting cluster: %s", err)
}

for _, cmd := range []string{stopCommand, GetStartCommand()} {
for _, cmd := range []string{stopCommand, GetStartCommand("127.0.0.1")} {
if _, ok := h.Commands[cmd]; !ok {
t.Fatalf("Expected command not run: %s. Commands run: %s", cmd, h.Commands)
}
Expand All @@ -91,7 +91,7 @@ func TestStartClusterError(t *testing.T) {
h := tests.NewMockHost()
h.Error = "error"

err := StartCluster(h)
err := StartCluster(h, "")
if err == nil {
t.Fatal("Error not thrown starting cluster.")
}
Expand Down
11 changes: 8 additions & 3 deletions pkg/minikube/cluster/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ var stopCommand = "sudo killall openshift | true"
var startCommandFmtStr = `
# Run with nohup so it stays up. Redirect logs to useful places.
cd /var/lib/minishift;
sudo sh -c 'PATH=/usr/local/sbin:$PATH nohup sudo /usr/local/bin/openshift start --listen=https://0.0.0.0:%d --cors-allowed-origins=.*> %s 2> %s < /dev/null &'
if [ ! -f openshift.local.config/master/master-config.yaml ]; then
sudo /usr/local/bin/openshift start --listen=https://0.0.0.0:%d --cors-allowed-origins=.* --write-config=openshift.local.config;
sudo /usr/local/bin/openshift ex config patch openshift.local.config/master/master-config.yaml --patch='{"routingConfig": {"subdomain": "%s.xip.io"}}' > /tmp/master-config.yaml;
sudo mv /tmp/master-config.yaml openshift.local.config/master/master-config.yaml
fi;
sudo sh -c 'PATH=/usr/local/sbin:$PATH nohup /usr/local/bin/openshift start --master-config=openshift.local.config/master/master-config.yaml --node-config=openshift.local.config/node-minishiftvm/node-config.yaml> %s 2> %s < /dev/null &'
until $(curl --output /dev/null --silent --fail -k https://localhost:%d/healthz/ready); do
printf '.'
sleep 1
Expand All @@ -38,6 +43,6 @@ sudo /usr/local/bin/openshift admin policy add-cluster-role-to-user cluster-admi

var logsCommand = fmt.Sprintf("tail -n +1 %s %s", constants.RemoteOpenShiftErrPath, constants.RemoteOpenShiftOutPath)

func GetStartCommand() string {
return fmt.Sprintf(startCommandFmtStr, constants.APIServerPort, constants.RemoteOpenShiftErrPath, constants.RemoteOpenShiftOutPath, constants.APIServerPort)
func GetStartCommand(ip string) string {
return fmt.Sprintf(startCommandFmtStr, constants.APIServerPort, ip, constants.RemoteOpenShiftErrPath, constants.RemoteOpenShiftOutPath, constants.APIServerPort)
}

0 comments on commit 5cfd871

Please sign in to comment.