Skip to content

Commit 5cfd871

Browse files
authored
Merge pull request kubernetes#26 from jimmidyson/router-domain
Set router subdomain to <ip>.xip.io by default
2 parents 2165b4b + a94b5d7 commit 5cfd871

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

cmd/minikube/cmd/start.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,20 @@ func runStart(cmd *cobra.Command, args []string) {
8585
os.Exit(1)
8686
}
8787

88-
if err := cluster.StartCluster(host); err != nil {
88+
kubeIP, err := host.Driver.GetIP()
89+
if err != nil {
90+
glog.Errorln("Error connecting to cluster: ", err)
91+
os.Exit(1)
92+
}
93+
if err := cluster.StartCluster(host, kubeIP); err != nil {
8994
glog.Errorln("Error starting cluster: ", err)
9095
os.Exit(1)
9196
}
9297

9398
kubeHost, err := host.Driver.GetURL()
9499
if err != nil {
95100
glog.Errorln("Error connecting to cluster: ", err)
101+
os.Exit(1)
96102
}
97103
kubeHost = strings.Replace(kubeHost, "tcp://", "https://", -1)
98104
kubeHost = strings.Replace(kubeHost, ":2376", ":"+strconv.Itoa(constants.APIServerPort), -1)

pkg/minikube/cluster/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ type MachineConfig struct {
166166
}
167167

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

172172
for _, cmd := range commands {
173173
glog.Infoln(cmd)

pkg/minikube/cluster/cluster_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ func TestCreateHost(t *testing.T) {
7575

7676
func TestStartCluster(t *testing.T) {
7777
h := tests.NewMockHost()
78-
err := StartCluster(h)
78+
err := StartCluster(h, "127.0.0.1")
7979
if err != nil {
8080
t.Fatalf("Error starting cluster: %s", err)
8181
}
8282

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

94-
err := StartCluster(h)
94+
err := StartCluster(h, "")
9595
if err == nil {
9696
t.Fatal("Error not thrown starting cluster.")
9797
}

pkg/minikube/cluster/commands.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ var stopCommand = "sudo killall openshift | true"
2828
var startCommandFmtStr = `
2929
# Run with nohup so it stays up. Redirect logs to useful places.
3030
cd /var/lib/minishift;
31-
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 &'
31+
if [ ! -f openshift.local.config/master/master-config.yaml ]; then
32+
sudo /usr/local/bin/openshift start --listen=https://0.0.0.0:%d --cors-allowed-origins=.* --write-config=openshift.local.config;
33+
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;
34+
sudo mv /tmp/master-config.yaml openshift.local.config/master/master-config.yaml
35+
fi;
36+
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 &'
3237
until $(curl --output /dev/null --silent --fail -k https://localhost:%d/healthz/ready); do
3338
printf '.'
3439
sleep 1
@@ -38,6 +43,6 @@ sudo /usr/local/bin/openshift admin policy add-cluster-role-to-user cluster-admi
3843

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

41-
func GetStartCommand() string {
42-
return fmt.Sprintf(startCommandFmtStr, constants.APIServerPort, constants.RemoteOpenShiftErrPath, constants.RemoteOpenShiftOutPath, constants.APIServerPort)
46+
func GetStartCommand(ip string) string {
47+
return fmt.Sprintf(startCommandFmtStr, constants.APIServerPort, ip, constants.RemoteOpenShiftErrPath, constants.RemoteOpenShiftOutPath, constants.APIServerPort)
4348
}

0 commit comments

Comments
 (0)