Skip to content

Commit 5442c91

Browse files
Move --print-ip from openshift start to openshift start master
1 parent 9bd7f25 commit 5442c91

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

hack/lib/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ function os::start::internal::determine_hostnames() {
539539
local hostnames
540540
hostnames="${PUBLIC_MASTER_HOST},"
541541
hostnames+="localhost,172.30.0.1,"
542-
for address in $(openshift start --print-ip); do
542+
for address in $(openshift start master --print-ip); do
543543
hostnames+="${address},"
544544
done
545545
hostnames+="kubernetes.default.svc.cluster.local,"

hack/lib/util/environment.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ readonly -f os::util::environment::setup_tmpdir_vars
169169
function os::util::environment::setup_kubelet_vars() {
170170
KUBELET_SCHEME="${KUBELET_SCHEME:-https}"
171171
export KUBELET_SCHEME
172-
KUBELET_BIND_HOST="${KUBELET_BIND_HOST:-$(openshift start --print-ip || echo "127.0.0.1")}"
172+
KUBELET_BIND_HOST="${KUBELET_BIND_HOST:-$(openshift start master --print-ip || echo "127.0.0.1")}"
173173
export KUBELET_BIND_HOST
174174
KUBELET_HOST="${KUBELET_HOST:-${KUBELET_BIND_HOST}}"
175175
export KUBELET_HOST
@@ -232,7 +232,7 @@ function os::util::environment::setup_server_vars() {
232232
KUBE_CACHE_MUTATION_DETECTOR="${KUBE_CACHE_MUTATION_DETECTOR:-true}"
233233
export KUBE_CACHE_MUTATION_DETECTOR
234234

235-
API_BIND_HOST="${API_BIND_HOST:-$(openshift start --print-ip || echo "127.0.0.1")}"
235+
API_BIND_HOST="${API_BIND_HOST:-$(openshift start master --print-ip || echo "127.0.0.1")}"
236236
export API_BIND_HOST
237237
API_HOST="${API_HOST:-${API_BIND_HOST}}"
238238
export API_HOST

pkg/cmd/server/start/start_master.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
type MasterOptions struct {
4444
MasterArgs *MasterArgs
4545

46+
PrintIP bool
4647
CreateCertificates bool
4748
ExpireDays int
4849
SignerExpireDays int
@@ -84,6 +85,19 @@ func NewCommandStartMaster(basename string, out, errout io.Writer) (*cobra.Comma
8485
Long: fmt.Sprintf(masterLong, basename),
8586
Run: func(c *cobra.Command, args []string) {
8687
kcmdutil.CheckErr(options.Complete())
88+
89+
if options.PrintIP {
90+
u, err := options.MasterArgs.GetMasterAddress()
91+
if err != nil {
92+
glog.Fatal(err)
93+
}
94+
host, _, err := net.SplitHostPort(u.Host)
95+
if err != nil {
96+
glog.Fatal(err)
97+
}
98+
fmt.Fprintf(out, "%s\n", host)
99+
return
100+
}
87101
kcmdutil.CheckErr(options.Validate(args))
88102

89103
origin.StartProfiler()
@@ -123,6 +137,7 @@ func NewCommandStartMaster(basename string, out, errout io.Writer) (*cobra.Comma
123137
flags.BoolVar(&options.CreateCertificates, "create-certs", true, "Indicates whether missing certs should be created")
124138
flags.IntVar(&options.ExpireDays, "expire-days", options.ExpireDays, "Validity of the certificates in days (defaults to 2 years). WARNING: extending this above default value is highly discouraged.")
125139
flags.IntVar(&options.SignerExpireDays, "signer-expire-days", options.SignerExpireDays, "Validity of the CA certificate in days (defaults to 5 years). WARNING: extending this above default value is highly discouraged.")
140+
flags.BoolVar(&options.PrintIP, "print-ip", false, "Print the IP that would be used if no master IP is specified and exit.")
126141

127142
BindMasterArgs(options.MasterArgs, flags, "")
128143
BindListenArg(options.MasterArgs.ListenArg, flags, "")

0 commit comments

Comments
 (0)