Allow override of "kubernetes" endpoint port

This commit is contained in:
Darren Shepherd 2018-10-08 11:07:42 -07:00 committed by Rafael Breno
parent 1fa8f8d7cb
commit 29259d5dff
2 changed files with 11 additions and 0 deletions

View File

@ -368,6 +368,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
}
@ -1158,6 +1160,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
}

View File

@ -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
}