Skip to content

Commit 8d6677e

Browse files
Merge pull request #43 from devtron-labs/insecure-tls-fix
fix: use certificates data when InsecureSkipTLSVerify is false for a cluster in case of external run CI
2 parents d314d22 + a95d61b commit 8d6677e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

kubewatch/pkg/cluster/ClusterRepository.go

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type Cluster struct {
3838
AgentInstallationStage int `sql:"agent_installation_stage"`
3939
K8sVersion string `sql:"k8s_version"`
4040
ErrorInConnecting string `sql:"error_in_connecting"`
41+
InsecureSkipTlsVerify bool `sql:"insecure_skip_tls_verify"`
4142
sql.AuditLog
4243
}
4344

kubewatch/pkg/informer/K8sInformer.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/argoproj/argo-workflows/v3/workflow/common"
2626
pubsub "github.com/devtron-labs/common-lib/pubsub-lib"
2727
k8s1 "github.com/devtron-labs/common-lib/utils/k8s"
28+
"github.com/devtron-labs/common-lib/utils/k8s/commonBean"
2829
repository "github.com/devtron-labs/kubewatch/pkg/cluster"
2930
"github.com/devtron-labs/kubewatch/pkg/middleware"
3031
"github.com/devtron-labs/kubewatch/pkg/utils"
@@ -439,10 +440,16 @@ func (impl *K8sInformerImpl) getK8sClientForCluster(clusterInfo *repository.Clus
439440
} else {
440441
restConfig = &rest.Config{
441442
Host: clusterInfo.ServerUrl,
442-
BearerToken: clusterInfo.Config["bearer_token"],
443-
TLSClientConfig: rest.TLSClientConfig{Insecure: true},
443+
BearerToken: clusterInfo.Config[commonBean.BearerToken],
444+
TLSClientConfig: rest.TLSClientConfig{Insecure: clusterInfo.InsecureSkipTlsVerify},
445+
}
446+
if !restConfig.TLSClientConfig.Insecure {
447+
restConfig.TLSClientConfig.KeyData = []byte(clusterInfo.Config[commonBean.TlsKey])
448+
restConfig.TLSClientConfig.CertData = []byte(clusterInfo.Config[commonBean.CertData])
449+
restConfig.TLSClientConfig.CAData = []byte(clusterInfo.Config[commonBean.CertificateAuthorityData])
444450
}
445451
}
452+
446453
return impl.getK8sClientForConfig(restConfig)
447454
}
448455

0 commit comments

Comments
 (0)