From 8f9550adbb15ece7d05c2dea6295dc12ec655cff Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 8 Oct 2018 11:07:42 -0700 Subject: [PATCH] Allow override of "kubernetes" endpoint port --- staging/src/k8s.io/apiserver/pkg/server/config.go | 5 +++++ staging/src/k8s.io/apiserver/pkg/server/options/serving.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/staging/src/k8s.io/apiserver/pkg/server/config.go b/staging/src/k8s.io/apiserver/pkg/server/config.go index ee037aefed2..1e3b5792797 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/config.go +++ b/staging/src/k8s.io/apiserver/pkg/server/config.go @@ -358,6 +358,8 @@ type SecureServingInfo struct { // A value of zero means to use the default provided by golang's HTTP/2 support. HTTP2MaxStreamsPerConnection int + AdvertisePort int + // DisableHTTP2 indicates that http2 should not be enabled. DisableHTTP2 bool } @@ -1150,6 +1152,9 @@ func (s *SecureServingInfo) HostPort() (string, int, error) { if err != nil { return "", 0, fmt.Errorf("invalid non-numeric port %q", portStr) } + if s.AdvertisePort != 0 { + port = s.AdvertisePort + } return host, port, nil } diff --git a/staging/src/k8s.io/apiserver/pkg/server/options/serving.go b/staging/src/k8s.io/apiserver/pkg/server/options/serving.go index 21a2736e107..e4287ae13a8 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/options/serving.go +++ b/staging/src/k8s.io/apiserver/pkg/server/options/serving.go @@ -78,6 +78,9 @@ type SecureServingOptions struct { // PermitAddressSharing controls if SO_REUSEADDR is used when binding the port. PermitAddressSharing bool + + // AdvertisePort allows overriding the default port used by the ap iserver + AdvertisePort int } type CertKey struct { @@ -167,6 +170,7 @@ func (s *SecureServingOptions) AddFlags(fs *pflag.FlagSet) { fs.BoolVar(&s.DisableHTTP2Serving, "disable-http2-serving", s.DisableHTTP2Serving, "If true, HTTP2 serving will be disabled [default=false]") + fs.IntVar(&s.AdvertisePort, "advertise-port", s.AdvertisePort, "The port that will be advertised as kubernetes endpoints") fs.StringVar(&s.ServerCert.CertDirectory, "cert-dir", s.ServerCert.CertDirectory, ""+ "The directory where the TLS certs are located. "+ @@ -334,6 +338,8 @@ func (s *SecureServingOptions) ApplyTo(config **server.SecureServingInfo) error } c.SNICerts = namedTLSCerts + c.AdvertisePort = s.AdvertisePort + return nil }