Skip to content

Commit c0ffe84

Browse files
authored
manage clusters via proxy (#466)
Signed-off-by: ls0f <[email protected]>
1 parent e56739c commit c0ffe84

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/utils/kube/kube.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ func WriteKubeConfig(restConfig *rest.Config, namespace, filename string) error
224224

225225
// NewKubeConfig converts a clientcmdapi.Config (kubeconfig) from a rest.Config
226226
func NewKubeConfig(restConfig *rest.Config, namespace string) *clientcmdapi.Config {
227+
var proxyUrl string
228+
if restConfig.Proxy != nil {
229+
if u, err := restConfig.Proxy(nil); err == nil {
230+
proxyUrl = u.String()
231+
}
232+
}
227233
return &clientcmdapi.Config{
228234
CurrentContext: restConfig.Host,
229235
Contexts: map[string]*clientcmdapi.Context{
@@ -240,6 +246,7 @@ func NewKubeConfig(restConfig *rest.Config, namespace string) *clientcmdapi.Conf
240246
InsecureSkipTLSVerify: restConfig.TLSClientConfig.Insecure,
241247
CertificateAuthority: restConfig.TLSClientConfig.CAFile,
242248
CertificateAuthorityData: restConfig.TLSClientConfig.CAData,
249+
ProxyURL: proxyUrl,
243250
},
244251
},
245252
AuthInfos: map[string]*clientcmdapi.AuthInfo{

0 commit comments

Comments
 (0)