Skip to content

Commit 5b4e229

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

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

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

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,25 @@ spec:
105105

106106
=== Tenant CRD
107107

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

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

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

116-
* `clusters`: List of cluster IDs of clusters for which the compile pipeline should be executed.
117-
This field is managed by the operator.
115+
* `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).
118116
* `pipelineFiles`: Dictionary containing file paths as keys, and file contents as values.
119117
These files will be added to the tenant's `gitRepoTemplate.templateFiles` by the Lieutenant operator.
120118
This field is optional; if absent, no new template files are added to the `gitRepoTemplate`.
121119

120+
`spec.compilePipeline` is optional. Its absence disables automatic setup of compile pipelines for the tenant, as does setting `spec.compilePipeline.enabled` to `false`.
121+
122+
The `status.compilePipeline` field contains a dict with one field:
123+
124+
* `clusters`: List of cluster IDs of clusters for which the compile pipeline should be executed.
125+
This field is managed by the operator.
126+
122127
[source,yaml]
123128
----
124129
apiVersion: syn.tools/v1alpha1
@@ -127,14 +132,16 @@ metadata:
127132
name: t-my-tenant
128133
spec:
129134
compilePipeline:
130-
clusters:
131-
- c-my-cluster
132135
pipelineFiles:
133136
.gitlab-ci.yml: |
134137
include:
135138
- project: syn/commodore-compile-pipeline
136139
ref: master
137140
file: /.gitlab/commodore-common.yml
141+
status:
142+
compilePipeline:
143+
clusters:
144+
- c-my-cluster
138145
----
139146

140147
=== Operator
@@ -151,6 +158,8 @@ The operator will reconcile *GitRepos* as follows:
151158
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.
152159
* The content of `.spec.ciVariables` is written to the repository's configuration on the Git host.
153160
In the case of GitLab, it is written as CI/CD variables.
161+
If the content of `.spec.ciVariables` changes, the corresponding configuration on the Git host should be updated.
162+
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.
154163

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

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

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

164-
* When `.spec.compilePipeline` exists and isn't empty, the following entries are added to the tenant repository GitRepo's `.spec.ciVariables`:
173+
* The following entries are added to the tenant repository GitRepo's `.spec.ciVariables`:
165174
** `COMMODORE_API_URL`, containing the URL at which the Lieutenant API can be accessed.
166175
** `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`.
176+
** `CLUSTERS`, containing a space-separated list of cluster IDs taken directly from `.status.compilePipeline.clusters`.
177+
* For each entry in `.status.compilePipeline.clusters`, another entry is added to the tenant repository GitRepo's `spec.ciVariabes`.
169178
The key is `ACCESS_TOKEN_CLUSTERNAME`, where `CLUSTERNAME` is the ID of a specific cluster, with `-` replaced by `_`.
170179
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`.
171180
* For each entry in `.spec.compilePipeline.pipelineFiles`, a new corresponding entry is added to the tenant's `.spec.gitRepoTemplate.templateFiles`.
@@ -178,12 +187,12 @@ The implementation takes care to gracefully skip the CI steps if not on GitLab.
178187
We leave the implementation extensible enough to add further Git management tools and CI systems without needing breaking changes.
179188

180189
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.
190+
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.
182191
+
183-
In particular, these repositories would already have a working `.gitlab-ci.yml` that probably can be left as-is.
192+
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.
184193
+
185194
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.
195+
This will lead to a bunch of now-unused tokens needing to be cleaned up, but should otherwise work without requiring extra effort.
187196

188197
External Catalog Repositories::
189198
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)