|
1 | 1 | # Source Controller Proposal |
2 | 2 |
|
3 | | -## Context |
4 | | - |
5 | | -The desired state of a cluster is made out of Kubernetes objects, these objects are expressed in `.yaml` format and |
6 | | -are applied on the cluster by operators running inside the cluster. An operator's role is to fetch the Kubernetes |
7 | | -objects, run transformations on them and reconcile the cluster state with the resulting manifest. |
8 | | - |
9 | | -For an operator to acquire the resources that make up the desired state it needs to understand the communication |
10 | | -protocol and the authentication scheme, verify the authenticity of a source and deal with rate limits and retries. |
11 | | -In the FluxCD organization there are currently two operators that perform such operations. Both Flux and |
12 | | -Helm Operator connect to Git repositories to fetch Kubernetes objects, they need to maintain an up-to-date mirror |
13 | | -of one or several repos. Besides Git, Helm Operator needs to connect to Helm repositories hosted on public or |
14 | | -private HTTPS servers. |
| 3 | +The main goal is to define a set of Kubernetes objects that cluster |
| 4 | +admins and various automated operators can interact with to offload |
| 5 | +the sources (e.g. Git and Helm repositories) registration, authentication, |
| 6 | +verification and resource fetching to a dedicated controller. |
15 | 7 |
|
16 | 8 | ## Motivation |
17 | 9 |
|
18 | | -Each Flux or Helm Operator instance maintains its own Git repository mirror even if all of them |
19 | | -point to the same source. If the Git repository host becomes unavailable, the cluster state will diverge from the last |
20 | | -known desired state since the operators will stop the reconciliation due to pull errors. |
21 | | - |
22 | | -Decoupling the Kubernetes objects acquisition from the reconciliation process with an in-cluster |
23 | | -source manager would make Flux and Helm Operator resilient to outbound connectivity issues and would |
24 | | -simplify the state machine(s) that these controllers operate. |
| 10 | +Each Flux and each Helm operator mirrors the Git repositories they are |
| 11 | +using, in the same way, using the same code. But other components |
| 12 | +might benefit from access to the source mirrors, and Flux and the Helm |
| 13 | +operator could work more in sympathy with Kubernetes by factoring it out. |
25 | 14 |
|
26 | | -Managing the source operations in a dedicated controller could enable Flux to compose the desire state of a cluster |
27 | | -from multiple source. Furthermore, the manifests transformation process could be performed by 3rd party tools |
28 | | -(e.g. kustomize, jk, tanka, cue run by Tekton pipelines or Kubernetes Jobs) |
29 | | -that subscribe to source changes events. |
| 15 | +If "sources" (usually git repos, but also Helm charts and potentially |
| 16 | +other things) existed in their own right as Kubernetes resources, |
| 17 | +components like Flux and Helm operator could use standard Kubernetes |
| 18 | +mechanisms to build on them; and, they could be managed independently |
| 19 | +of the components using them. |
30 | 20 |
|
31 | | -The source controller could enable pinning the cluster desired state to a specific Git commit or Git tag. |
32 | | - |
33 | | -For teams that are using semantic versioning, the source controller could monitor the Git repository tags |
34 | | -and set the cluster desired state to the latest release or to a tag that matches a semver pattern. |
35 | | -In a similar fashion, a semver pattern could trigger Helm chart upgrades without manual intervention from users. |
| 21 | +## API Specification |
36 | 22 |
|
37 | | -## Goals |
| 23 | +* [v1alpha1](v1alpha1/README.md) |
38 | 24 |
|
39 | | -The main goal is to define a set of Kubernetes objects that cluster admins and various automated operators |
40 | | -can interact with to offload the sources (e.g. Git and Helm repositories) |
41 | | -registration, authentication and resource fetching to a dedicated controller. |
| 25 | +## Implementation |
42 | 26 |
|
43 | 27 | The controller implementation will watch for source objects in a cluster and act on them. |
44 | 28 | The actions performed by the source controller could be: |
45 | 29 | * validate source definitions |
46 | 30 | * authenticate to sources and validate authenticity |
47 | 31 | * detect source changes based on update policies (semver) |
48 | 32 | * fetch resources on-demand and on-a-schedule |
49 | | -* package the fetched resources into a well known format (tar.gz) |
| 33 | +* package the fetched resources into a well known format (tar.gz, yaml) |
50 | 34 | * store the artifacts locally |
51 | 35 | * make the artifacts addressable by their source identifier (sha, version, ts) |
52 | 36 | * make the artifacts available in-cluster to interested 3rd parties |
53 | 37 | * notify interested 3rd parties of source changes and availability (status conditions, events, hooks) |
54 | 38 |
|
55 | | -## API Specification |
| 39 | +## Impact to Flux |
56 | 40 |
|
57 | | -* [v1alpha1](v1alpha1/README.md) |
| 41 | +Having a dedicated controller that manages Git repositories defined with Kubernetes custom resources would: |
| 42 | +* simplify Flux configuration as fluxd could subscribe to Git sources in-cluster and pull the artifacts |
| 43 | +automatically without manual intervention from users to reconfigure and redeploy FLux |
| 44 | +* improve the installation experience as users will not have to patch fluxd's deployment to inject |
| 45 | +the HTTPS basic auth credentials, change the source URL or other Git and PGP related settings |
| 46 | +* enable fluxd to compose the desired state of a cluster from multiple sources by applying all artifacts present in flux namespace |
| 47 | +* enable fluxd to apply manifests coming from other sources than Git, e.g. S3 buckets |
| 48 | +* allow fluxd to run under a non-root user as it wouldn't need to shell out to ssh-keygen, git or pgp |
| 49 | +* enable fluxd to apply manifests coming from the most recent semver tag of a Git repository |
| 50 | +* allow user to pin the cluster desired state to a specific Git commit or Git tag |
| 51 | + |
| 52 | +## Impact to Helm Operator |
| 53 | + |
| 54 | +TODO |
0 commit comments