Skip to content

Commit c0b0906

Browse files
Separate operator-managed fields into .status
1 parent ac3caef commit c0b0906

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

docs/modules/SDDs/pages/0032-compile-pipeline.adoc renamed to docs/modules/SDDs/pages/0032-compile-pipeline-gitlab.adoc

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ include::partial$meta-info-table.adoc[]
1414
This describes how we want to implement GitLab CI/CD for Project Syn using a Commodore compile pipeline, which enables automatic compilation of cluster catalogs whenever the corresponding tenant repository is modified.
1515
1616
Furthermore, it explains how want to extend the functionality of Lieutenant to enable it to automatically configure the compile pipeline on tenant repositories.
17+
18+
While we only aim to support GitLab at the moment, the architecture should be sufficiently generic so it can be used for other Git hosts in the future.
1719
====
1820

1921
== Motivation
@@ -105,20 +107,25 @@ spec:
105107

106108
=== Tenant CRD
107109

108-
We add a new field to the `Tenant` CRD, under the `.spec` key, called `compilePipeline`.
110+
We add new fields to the `Tenant` CRD: `spec.compilePipeline` and `status.compilePipeline`
109111

110-
The `compilePipeline` field contains configuration pertaining to the automatic setup of the compile pipeline on the tenant repository.
112+
The `spec.compilePipeline` field contains configuration pertaining to the automatic setup of the compile pipeline on the tenant repository.
111113
It is optional.
112-
Absence of the field disables automatic setup and management of the compile pipeline.
113114

114-
The `compilePipeline` field contains a dict with the following fields:
115+
The `spec.compilePipeline` field contains a dict with the following fields:
115116

116-
* `clusters`: List of cluster IDs of clusters for which the compile pipeline should be executed.
117-
This field is managed by the operator.
117+
* `enabled`: Boolean field which enables or disables automatic setup of compile pipelines for this tenant (regardless of whether it is enabled on the tenant's clusters).
118118
* `pipelineFiles`: Dictionary containing file paths as keys, and file contents as values.
119119
These files will be added to the tenant's `gitRepoTemplate.templateFiles` by the Lieutenant operator.
120120
This field is optional; if absent, no new template files are added to the `gitRepoTemplate`.
121121

122+
`spec.compilePipeline` is optional. Its absence disables automatic setup of compile pipelines for the tenant, as does setting `spec.compilePipeline.enabled` to `false`.
123+
124+
The `status.compilePipeline` field contains a dict with one field:
125+
126+
* `clusters`: List of cluster IDs of clusters for which the compile pipeline should be executed.
127+
This field is managed by the operator.
128+
122129
[source,yaml]
123130
----
124131
apiVersion: syn.tools/v1alpha1
@@ -127,14 +134,16 @@ metadata:
127134
name: t-my-tenant
128135
spec:
129136
compilePipeline:
130-
clusters:
131-
- c-my-cluster
132137
pipelineFiles:
133138
.gitlab-ci.yml: |
134139
include:
135140
- project: syn/commodore-compile-pipeline
136141
ref: master
137142
file: /.gitlab/commodore-common.yml
143+
status:
144+
compilePipeline:
145+
clusters:
146+
- c-my-cluster
138147
----
139148

140149
=== Operator
@@ -151,6 +160,8 @@ The operator will reconcile *GitRepos* as follows:
151160
The operator also runs a scheduled job which refreshes these tokens when they are close to expiring, or when they no longer exist on the repository host.
152161
* The content of `.spec.ciVariables` is written to the repository's configuration on the Git host.
153162
In the case of GitLab, it is written as CI/CD variables.
163+
If the content of `.spec.ciVariables` changes, the corresponding configuration on the Git host should be updated.
164+
A scheduled job in the ooperator regularly checks for drift between `.spec.ciVariables` and the configuration on the Git host, and updates the latter if necessary.
154165

155166
NOTE: If the GitRepo is of type `unmanaged`, none of these steps will be executed.
156167

@@ -159,13 +170,13 @@ The operator will reconcile *Clusters* as follows:
159170
* When `.spec.enableCompilePipeline` is set to `true`, the tenant's `spec.compilePipeline.clusters` is updated to contain the cluster ID.
160171
* Similarly, when the field is set to `false` or missing, the tenant's `spec.compilePipeline.clusters` is updated to not contain the cluster ID.
161172

162-
The operator will reconcile *Tenants* as follows:
173+
The operator will reconcile *Tenants* as follows, if and only if `spec.compilePipeline.enabled` is set to `true`:
163174

164-
* When `.spec.compilePipeline` exists and isn't empty, the following entries are added to the tenant repository GitRepo's `.spec.ciVariables`:
175+
* The following entries are added to the tenant repository GitRepo's `.spec.ciVariables`:
165176
** `COMMODORE_API_URL`, containing the URL at which the Lieutenant API can be accessed.
166177
** `COMMODORE_API_TOKEN`, containing a reference to the secret which contains the tenant's access token for the Lieutenant API.
167-
** `CLUSTERS`, containing a space-separated list of cluster IDs taken directly from `.spec.compilePipeline.clusters`.
168-
* For each entry in `.spec.compilePipeline.clusters`, another entry is added to the tenant repository GitRepo's `spec.ciVariabes`.
178+
** `CLUSTERS`, containing a space-separated list of cluster IDs taken directly from `.status.compilePipeline.clusters`.
179+
* For each entry in `.status.compilePipeline.clusters`, another entry is added to the tenant repository GitRepo's `spec.ciVariabes`.
169180
The key is `ACCESS_TOKEN_CLUSTERNAME`, where `CLUSTERNAME` is the ID of a specific cluster, with `-` replaced by `_`.
170181
The value is a reference to the secret containing the access token to access that cluster's catalog repository, taken from the secret specified in the catalog GitRepo configuration under `.spec.accessTokenSecretName`.
171182
* For each entry in `.spec.compilePipeline.pipelineFiles`, a new corresponding entry is added to the tenant's `.spec.gitRepoTemplate.templateFiles`.
@@ -178,12 +189,12 @@ The implementation takes care to gracefully skip the CI steps if not on GitLab.
178189
We leave the implementation extensible enough to add further Git management tools and CI systems without needing breaking changes.
179190

180191
Existing compile pipeline configuration::
181-
If a setup already includes a bunch of tenant repositories with manually configured CI/CD, some care has to be taken to ensure the new implementation can "adopt" this configuration.
192+
If a setup already includes a bunch of tenant repositories with manually configured CI/CD, in the general case, the new implementation can "adopt" this configuration.
182193
+
183-
In particular, these repositories would already have a working `.gitlab-ci.yml` that probably can be left as-is.
194+
In particular, these repositories would already have a working `.gitlab-ci.yml` that probably could be left as-is, but can also be replaced by a lieutenant-managed one.
184195
+
185196
Any existing manually created Project Access Tokens will be superseded by new auto-generated ones.
186-
This will lead to a bunch of now-unused tokens needing to be cleaned up.
197+
This will lead to a bunch of now-unused tokens needing to be cleaned up, but should otherwise work without requiring extra effort.
187198

188199
External Catalog Repositories::
189200
There may be cases where the catalog repositories are not hosted on the same repository host as the tenant repository, in which case API access for the purpose of creating Project Access Tokens is unavailable.

docs/modules/SDDs/pages/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ The all are using the xref:sdd-template.adoc[SDD Template].
2626
* xref:0028-reusable-config-packages.adoc[0028 - Reusable Commodore Component Configuration Packages]
2727
* xref:0030-argocd-multitenancy.adoc[0030 - Project Syn ArgoCD Multi-Tenant Support]
2828
* xref:0031-component-version-tracking.adoc[0031 - Central Component Version tracking]
29-
* xref:0032-compile-pipeline.adoc[0032 - Commodore Compile Pipeline for GitLab]
29+
* xref:0032-compile-pipeline-gitlab.adoc[0032 - Commodore Compile Pipeline for GitLab]

0 commit comments

Comments
 (0)