-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: allow insecure clusters Signed-off-by: Francesco Ilario <[email protected]> * Override ca.crt in kubeconfigs Signed-off-by: Francesco Ilario <[email protected]> * Add feature flag to disable TLS Signed-off-by: Francesco Ilario <[email protected]> * Update README Signed-off-by: Francesco Ilario <[email protected]> * Rename util.BuildKubernetesClient to BuildKubernetesRESTConfig Signed-off-by: Francesco Ilario <[email protected]> * Update README.adoc Co-authored-by: Baiju Muthukadan <[email protected]> --------- Signed-off-by: Francesco Ilario <[email protected]> Co-authored-by: Baiju Muthukadan <[email protected]>
- Loading branch information
Showing
5 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package util | ||
|
||
import ( | ||
"os" | ||
|
||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"k8s.io/client-go/tools/clientcmd/api" | ||
) | ||
|
||
const EnvDisableKubeClientTLSVerify string = "DISABLE_KUBE_CLIENT_TLS_VERIFY" | ||
|
||
func BuildKubernetesRESTConfig(apiConfig api.Config) (*rest.Config, error) { | ||
if os.Getenv(EnvDisableKubeClientTLSVerify) == "true" { | ||
apiConfig = setInsecureSkipTLSVerify(apiConfig) | ||
} | ||
|
||
configOverrides := clientcmd.ConfigOverrides{} | ||
return clientcmd.NewDefaultClientConfig(apiConfig, &configOverrides).ClientConfig() | ||
} | ||
|
||
func setInsecureSkipTLSVerify(apiConfig api.Config) api.Config { | ||
for _, c := range apiConfig.Clusters { | ||
if c != nil { | ||
c.CertificateAuthorityData = nil | ||
c.InsecureSkipTLSVerify = true | ||
} | ||
} | ||
return apiConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters