<p>I am trying to write a helm operator using client-go and want to fetch the chart from my controller using the <em>RepoURL</em>, and <em>chartname</em>. I have written a sample piece of code which is working perfectly fine on my local machine. But the same code throws error when I run the same code inside the container. Please find the following piece of code:</p>

<pre><code>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
}
</code></pre>

<p>The above function is throwing following error while getting the chartURL:</p>

<pre><code>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

</code></pre>

<p>I get that it is asking for some ca certificate, but I am not sure which ca certificate as I have initialised helm without tls certificates. </p>

<p>I also tried to copy the helm binary inside the pod and tried to run:</p>

<pre><code>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.
</code></pre>

<p>I am facing the same issue there also. Has anyone faced similar issue?</p>

<p>No, I don't see this problem.</p>

<p><strong>Notice</strong>: the cert of domain <code>kubernetes-charts.storage.googleapis.com</code> is issued by known CA (Google trust services). So as that of <code>charts.bitnami.com</code> (issued by Amazon CA), So you just need to debug a little bit to see:</p>

<ol>
<li>which CA issues cert to this domain when accessing within the pod. E.g., run command <code>curl -vI https://charts.bitnami.com/</code> If the cert issuer is what it should be, you may need to update the base image of the pod to include updated known CA certs. If not (e.g., the cert of <code>charts.bitnami.com</code> is self-signed), this is typical DNS poisoning (names server for the pod resolves above domains to different ones)</li>
<li>Check names servers for your pod. if you don't trust k8s worker DNS, you can customize names servers for your pod. see <a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/</a></li>
</ol>
