[SURE-9881] CA in a secret referenced in spec.helmSecretName or spec.helmSecretNameForPaths not used when pulling Fleet bundle helm chart from a git repository
SURE-9881
Issue description:
The fleet documentation (https://fleet.rancher.io/ref-fleet-yaml) notes the ability to pull the chart in a bundle from a git repository:
# Git repositories can be downloaded via unauthenticated http, by using for
# example:
#
# `git::http://github.com/rancher/fleet-examples/single-cluster/helm`.
However, this git method does not use any CA configured in a secret referenced on the GitRepo spec.helmSecretName or spec.helmSecretNameForPaths. By comparison, such a CA is used when pulling the chart with simple GET of chart .tgz URL
Business impact:
Customer is unable to deploy charts via Fleet that are hosted in their internal gitea instance, which is deployed with a private CA
See PR mentioned above this comment.
This limitation is caused by hashicorp/go-getter's GitGetter not supporting custom client options, unlike the HttpGetter for which transport, and therefore authentication, can be configured with a custom CA bundle.
Possible fixes for this could include:
- enhancing the
GitGetterto enable custom CA bundle injection - bypassing
go-getterfor git-hosted Helm charts, for instance by relying ongo-gitas the gitcloner command does.
Is there a way to configure the GitRepo to ignore the custom CA certificates until this is patched? I have tried adding insecureSkipTLSVerify: true but with no effect.
This has the effect of rendering Fleet useless in Airgap or STIG environments.
QA Template
- Create a (self-hosted) git server that supports HTTPS.
- Provide it with a self-signed certificate.
- Create a git repository on that self-hosted git server which contains a simple helm chart. It can just contain a ConfigMap.
- Create a repository that contains a
fleet.yamlfile which points to the git server in itshelm.chartfield (e.g.git::http://gitserver/foo/bar). It can but does not have to be on the self-hosted git server. This URL instructs go-getter to (git) clone the repository behindhttp://gitserver/foo/bar. - Create a GitRepo resource which points to the repository that contains the
fleet.yamlfile. This GitRepo can have different settings, depending on what should be tested:CABundlefield in the GitRepo resource. If this field is set, it will use the certificate to connect to the first git repository that contains thefleet.yamlfile. It will also try to use this certificate to connect to the git server that thefleet.yaml'shelm.chartfield points to, unlesshelmSecretNamein the GitRepo resource points to an existing secret and has a configuredCABundleor hasInsecureSkipVerifyset to true, orhelmSecretForPathsin the GitRepo resource points to an existing secret and has a configuredCABundleor hasInsecureSkipVerifyset to true, orskipInsecureVerifyTLSin the GitRepo is set totrue.
- Test meaningful permutations of those settings
- On the positive testing side, we need to make sure that
CABundlein GitRepo works forfleet.yaml,CABundlein secret defined inhelmSecretNameworks forfleet.yamlandCABundlein secret defined inhelmSecretNameForPathsworks forfleet.yaml, as well asInsecureSkipTLSVerifyin GitRepo works forfleet.yaml,InsecureSkipVerifyinhelmSecretNameworks forfleet.yaml, andInsecureSkipVerifyinhelmSecretNameForPathsworks forfleet.yaml.
- On the positive testing side, we need to make sure that
flowchart TD
grr[GitRepo Resource]
subgraph Git Server
gr1[Git Repository with `fleet.yaml` file]
gr2["Git Repository with Chart (e.g. ConfigMap)"]
end
grr -->|points to| gr1
gr1 -->|fleet.yaml points to| gr2