Skip to content

Commit

Permalink
ignoret(platform): ca when set env
Browse files Browse the repository at this point in the history
  • Loading branch information
xdonggao committed Feb 8, 2022
1 parent ee46a9e commit c598868
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/platform/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"math/rand"
"net"
"os"
"path"
"strings"

Expand Down Expand Up @@ -391,7 +392,8 @@ func (cc ClusterCredential) RESTConfig(cls *Cluster) *rest.Config {
config.Host = fmt.Sprintf("https://%s", host)
}
}
if cc.CACert != nil {
// k8s的api-server如果没有签address里的ip,设置ca再请求会报x509证书错误,需要忽略证书
if os.Getenv("TKE_IGNORE_CA") != "true" && cc.CACert != nil {
config.TLSClientConfig.CAData = cc.CACert
} else {
config.TLSClientConfig.Insecure = true
Expand Down
4 changes: 3 additions & 1 deletion api/platform/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"math/rand"
"net"
"os"
"path"
strings "strings"

Expand Down Expand Up @@ -401,7 +402,8 @@ func (cc ClusterCredential) RESTConfig(cls *Cluster) *rest.Config {
config.Host = fmt.Sprintf("https://%s", host)
}
}
if cc.CACert != nil {
// k8s的api-server如果没有签address里的ip,设置ca再请求会报x509证书错误,需要忽略证书
if os.Getenv("TKE_IGNORE_CA") != "true" && cc.CACert != nil {
config.TLSClientConfig.CAData = cc.CACert
} else {
config.TLSClientConfig.Insecure = true
Expand Down

0 comments on commit c598868

Please sign in to comment.