Allow override of "kubernetes" endpoint port

This commit is contained in:
Darren Shepherd 2018-10-08 11:07:42 -07:00 committed by rafaelbreno[commit]
parent c7b20dbaeb
commit 275e8d8845
2 changed files with 12 additions and 0 deletions

View File

@ -346,6 +346,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
}
@ -1129,6 +1131,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

@ -76,6 +76,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 {
@ -163,6 +166,8 @@ func (s *SecureServingOptions) AddFlags(fs *pflag.FlagSet) {
}
fs.IntVar(&s.BindPort, "secure-port", s.BindPort, desc)
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. "+
"If --tls-cert-file and --tls-private-key-file are provided, this flag will be ignored.")
@ -328,6 +333,8 @@ func (s *SecureServingOptions) ApplyTo(config **server.SecureServingInfo) error
}
c.SNICerts = namedTLSCerts
c.AdvertisePort = s.AdvertisePort
return nil
}