Sources
How convoy verifies source endpoints and fetches the content that a Release renders.
A source is an endpoint and its credentials. convoy has three source kinds: GitRepository,
HelmRegistry and OCIRegistry. A source does not select a version. Each Release selects the
version, so many Releases can use one source with different versions.
| Kind | Endpoint | The Release selects | Fetched content |
|---|---|---|---|
| GitRepository | A Git URL | A branch, a tag or a commit | All files of the commit |
| HelmRegistry | An HTTP Helm repository with index.yaml | A chart name and an exact version | The files of the chart |
| OCIRegistry | An OCI registry | An artifact name and an exact tag | The files of the Helm chart |
apiVersion: source.convoy.kumodo.io/v1alpha1
kind: GitRepository
metadata:
name: podinfo
namespace: default
spec:
auth:
type: none
interval: 1m0s
minSyncInterval: 30s
tls:
insecureSkipVerify: true
url: https://github.com/stefanprodan/podinfo.git
Verification and fetch#
Two different parts of convoy connect to a source:
- The source controller verifies the endpoint. It writes the
Readycondition of the source. It does not download content. - The fetch coordinator downloads content when a Release needs it. The Release controller and the observer use the fetch coordinator.
Each source controller verifies its endpoint with the credentials of the source:
| Kind | Verification | Ready=True means |
|---|---|---|
GitRepository | Lists the remote refs, like git ls-remote. | The repository is reachable, and it accepts the credentials. |
HelmRegistry | Downloads and parses index.yaml. | The repository is reachable, and it accepts the credentials. |
OCIRegistry | Sends a request to /v2/ on the registry host. A 200 or a 401 answer is a success. | The registry is reachable. The credentials are not checked. |
A source controller verifies again at each periodic informer resync. It does not use
spec.interval.
How a Release fetches content#
At each reconcile, the Release controller asks the fetch coordinator for the content of
spec.source:
- The coordinator reads the source object from the namespace of the Release.
- The coordinator searches the artifact store for the content. convoy reads only commits, chart versions and OCI tags from the store. A branch or a tag can move, so convoy fetches it again at each reconcile.
- If the content is not in the store, the coordinator downloads it.
- The coordinator writes the content to the artifact store, and gives it to the renderer.
The download is different for each kind:
- Git branch or tag. A shallow clone of one branch or tag, without other tags. The revision is the commit at the head.
- Git commit. A full clone, then a checkout of the commit.
- Helm chart. convoy reads
index.yaml, downloads the chart archive and unpacks it. - OCI chart. convoy pulls the chart with the Helm registry client and unpacks it. With credentials, it authenticates first.
convoy unpacks a chart so that Chart.yaml is at the root of the files. For a HelmRegistry or
an OCIRegistry source, do not set spec.content.helm.path.
A fetch failure stops the reconcile before rendering:
| Cause | Applied reason | Retry |
|---|---|---|
| The source object does not exist. | SourceNotReady | Yes |
| The download fails, for example because of the network or bad credentials. | SourceNotReady | Yes |
The configuration is not supported, for example a semver ref or an auth type that is not built. | Unsupported | At the next periodic reconcile only |
convoy has no webhook receiver. A new commit on a branch reaches the cluster at the next reconcile of the Release. See Sync policy.
The artifact store#
The artifact store keeps fetched content in memory.
- The key is the source URL and the revision. convoy removes spaces, a trailing
/and a trailing.gitfrom the URL, and changes it to lowercase. - The revision is the commit SHA for Git. For Helm and OCI charts, it is
<chart name>-<version>. - Two sources with the same URL share the stored content.
- The controller-manager and the observer have different stores. Each process fetches its own copy.
- A restart clears the store. The next reconcile fetches the content again.
- convoy does not remove content from the store. Memory use increases with each new revision until the process restarts.
The coordinator does not merge requests. When two Releases need the same branch at the same time, convoy clones it two times.
Source and content types#
Validation does not check that spec.content.type fits spec.source.type. These pairs work:
| Source | Content types |
|---|---|
gitRepository | helm, kustomize, manifests |
helmRegistry | helm |
ociRegistry | helm |
Other pairs fail at render time, or render objects that you do not expect. See Rendering.
In convoy v0.9.0, an OCIRegistry gives only Helm charts. An artifact without a chart layer fails
with no chart layer. spec.defaultContentType of an OCIRegistry is required, but convoy does
not use it to fetch or render. Pulls of other OCI artifact types are planned. Not built
Other uses of a GitRepository#
A Release can read a GitRepository in two more places. Each place has its own ref, and uses the
same fetch coordinator and artifact store:
- A Helm values layer of type
gitRepository. See Rendering. - A mutation with
from.kind: GitRepository. See Mutations.
All source references of a Release must be in the namespace of the Release. See Release and Credentials.
In the code
convoy v0.9.0
internal/fetch.(*coordinator).Ensureinternal/fetch/coordinator.go:107internal/artifact.Keyinternal/artifact/store.go:48internal/controller/gitrepository.(*gitFetcher).Verifyinternal/controller/gitrepository/fetcher.go:113internal/controller/helmregistry.(*helmFetcher).Verifyinternal/controller/helmregistry/fetcher.go:150internal/controller/ociregistry.(*ociFetcher).Verifyinternal/controller/ociregistry/fetcher.go:160internal/controller/ociregistry.(*ociFetcher).Fetchinternal/controller/ociregistry/fetcher.go:140internal/controller/release.(*Controller).stageRenderinternal/controller/release/controller.go:901