我正在尝试使用 client-go 编写一个 helm 操作符,并希望使用RepoURL和chartname从我的控制器中获取图表。我编写了一段示例代码,在我的本地机器上运行良好。但是当我在容器内运行相同的代码时,相同的代码会引发错误。请找到以下代码:
func FetchURL() error {
repoURL := "https://kubernetes-charts.storage.googleapis.com"
username := ""
password := ""
var settings environment.EnvSettings
flags := pflag.NewFlagSet("helm-env", pflag.ContinueOnError)
settings.AddFlags(flags)
settings.Init(flags)
getters := getter.All(settings)
getters := getter.All(settings)
var err error
destDir, err := ioutil.TempDir("", "helm-")
if err != nil {
return fmt.Errorf("Failed to untar: %s", err)
}
defer os.RemoveAll(destDir)
chartURL, err := repo.FindChartInAuthRepoURL(repoURL, username, password, chartRef, "", "", "", "", getter.All(settings))
if err != nil {
return fmt.Errorf("Error finding the Chart URL: %s", err)
}
fmt.Println(chartURL)
return nil
}
上述函数在获取 chartURL 时抛出以下错误:
Fetching Chart
Error finding the Chart URL: Looks like "https://kubernetes-charts.storage.googleapis.com" is not a valid chart repository or cannot be reached: Get https://kubernetes-charts.storage.googleapis.com/index.yaml: x509: certificate signed by unknown authority
我知道它要求一些 ca 证书,但我不确定哪个 ca 证书,因为我已经初始化了没有 tls 证书的 helm。
我还尝试在 pod 中复制 helm 二进制文件并尝试运行:
helm init --client-only
helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Unable to get an update from the "stable" chart repository (https://kubernetes-charts.storage.googleapis.com):
Get https://kubernetes-charts.storage.googleapis.com/index.yaml: x509: certificate signed by unknown authority
...Unable to get an update from the "bitnami" chart repository (https://charts.bitnami.com/bitnami):
Get https://charts.bitnami.com/bitnami/index.yaml: x509: certificate signed by unknown authority
Update Complete.
我在那里也面临同样的问题。有没有人遇到过类似的问题?