@@ -43,6 +43,8 @@ const (
4343 SupervisorClusterAccessNamespaceFile = "namespace"
4444 // SupervisorAPIServerPortEnv reads supervisor service endpoint info from env
4545 SupervisorAPIServerPortEnv string = "SUPERVISOR_APISERVER_PORT"
46+ // SupervisorAPIServerHostnameEnv reads supervisor API server hostname from env
47+ SupervisorAPIServerHostnameEnv string = "SUPERVISOR_APISERVER_HOSTNAME"
4648 // SupervisorAPIServerEndpointIPEnv reads supervisor API server endpoint IP from env
4749 SupervisorAPIServerEndpointIPEnv string = "SUPERVISOR_APISERVER_ENDPOINT_IP"
4850 // SupervisorServiceAccountNameEnv reads supervisor service account name from env
@@ -57,6 +59,8 @@ type SupervisorEndpoint struct {
5759 Endpoint string
5860 // supervisor cluster proxy service port
5961 Port string
62+ // hostname for supervisor cluster, defaults to supervisor.default.svc
63+ Hostname string
6064}
6165
6266// ReadOwnerRef read the OwnerReference config file
@@ -88,10 +92,16 @@ func readSupervisorConfig() (*SupervisorEndpoint, error) {
8892
8993 }
9094
95+ supervisorHostname := os .Getenv (SupervisorAPIServerHostnameEnv )
96+ if supervisorHostname == "" {
97+ supervisorHostname = SupervisorAPIServerFQDN
98+ }
99+
91100 klog .V (6 ).Infof ("Configured with remote apiserver %s:%s" , remoteVip , remotePort )
92101 return & SupervisorEndpoint {
93102 Endpoint : remoteVip ,
94103 Port : remotePort ,
104+ Hostname : supervisorHostname ,
95105 }, nil
96106
97107}
@@ -132,7 +142,7 @@ func GetRestConfig(svConfigPath string) (*rest.Config, error) {
132142 }
133143
134144 return & rest.Config {
135- Host : "https://" + net .JoinHostPort (SupervisorAPIServerFQDN , svEndpoint .Port ),
145+ Host : "https://" + net .JoinHostPort (svEndpoint . Hostname , svEndpoint .Port ),
136146 TLSClientConfig : rest.TLSClientConfig {
137147 CAData : rootCA ,
138148 },
0 commit comments