Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that clusters' apiServiceURL is honored for kubeapps cluster. #6016

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/kube/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ func NewClusterConfig(inClusterConfig *rest.Config, userToken string, cluster st
return config, nil
}

if cluster == clustersConfig.KubeappsClusterName {
// We cannot assume that if the cluster is the kubeapps cluster that we simply return
// the incluster config, because some users set proxies in front of their clusters in
// which case the incluster kubernetes.default will skip the proxy.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good comment.

if cluster == clustersConfig.KubeappsClusterName && clusterConfig.APIServiceURL == "" {
return config, nil
}

Expand Down
33 changes: 33 additions & 0 deletions pkg/kube/cluster_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,39 @@ func TestNewClusterConfig(t *testing.T) {
BearerTokenFile: "",
},
},
{
name: "returns a cluster config with explicit apiServiceURL and cert even for the kubeapps default cluster, when specified",
userToken: "token-1",
cluster: "default",
clustersConfig: ClustersConfig{
KubeappsClusterName: "default",
Clusters: map[string]ClusterConfig{
"default": {
APIServiceURL: "https://proxy.example.com:7890",
CertificateAuthorityData: "Y2EtZmlsZS1kYXRhCg==",
CertificateAuthorityDataDecoded: "ca-file-data",
CAFile: "/tmp/ca-file-data",
},
},
},
inClusterConfig: &rest.Config{
Host: "https://something-else.example.com:6443",
BearerToken: "something-else",
BearerTokenFile: "/foo/bar",
TLSClientConfig: rest.TLSClientConfig{
CAFile: "/var/run/whatever/ca.crt",
},
},
expectedConfig: &rest.Config{
Host: "https://proxy.example.com:7890",
BearerToken: "token-1",
BearerTokenFile: "",
TLSClientConfig: rest.TLSClientConfig{
CAData: []byte("ca-file-data"),
CAFile: "/tmp/ca-file-data",
},
},
},
{
name: "returns an in-cluster config when the global packaging cluster token is specified",
userToken: "token-1",
Expand Down