You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
15
15
16
16
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.
17
19
====
18
20
19
21
== Motivation
@@ -105,20 +107,25 @@ spec:
105
107
106
108
=== Tenant CRD
107
109
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`
109
111
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.
111
113
It is optional.
112
-
Absence of the field disables automatic setup and management of the compile pipeline.
113
114
114
-
The `compilePipeline` field contains a dict with the following fields:
115
+
The `spec.compilePipeline` field contains a dict with the following fields:
115
116
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).
118
118
* `pipelineFiles`: Dictionary containing file paths as keys, and file contents as values.
119
119
These files will be added to the tenant's `gitRepoTemplate.templateFiles` by the Lieutenant operator.
120
120
This field is optional; if absent, no new template files are added to the `gitRepoTemplate`.
121
121
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
+
122
129
[source,yaml]
123
130
----
124
131
apiVersion: syn.tools/v1alpha1
@@ -127,14 +134,16 @@ metadata:
127
134
name: t-my-tenant
128
135
spec:
129
136
compilePipeline:
130
-
clusters:
131
-
- c-my-cluster
132
137
pipelineFiles:
133
138
.gitlab-ci.yml: |
134
139
include:
135
140
- project: syn/commodore-compile-pipeline
136
141
ref: master
137
142
file: /.gitlab/commodore-common.yml
143
+
status:
144
+
compilePipeline:
145
+
clusters:
146
+
- c-my-cluster
138
147
----
139
148
140
149
=== Operator
@@ -151,6 +160,8 @@ The operator will reconcile *GitRepos* as follows:
151
160
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.
152
161
* The content of `.spec.ciVariables` is written to the repository's configuration on the Git host.
153
162
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.
154
165
155
166
NOTE: If the GitRepo is of type `unmanaged`, none of these steps will be executed.
156
167
@@ -159,13 +170,13 @@ The operator will reconcile *Clusters* as follows:
159
170
* When `.spec.enableCompilePipeline` is set to `true`, the tenant's `spec.compilePipeline.clusters` is updated to contain the cluster ID.
160
171
* Similarly, when the field is set to `false` or missing, the tenant's `spec.compilePipeline.clusters` is updated to not contain the cluster ID.
161
172
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`:
163
174
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`:
165
176
** `COMMODORE_API_URL`, containing the URL at which the Lieutenant API can be accessed.
166
177
** `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`.
169
180
The key is `ACCESS_TOKEN_CLUSTERNAME`, where `CLUSTERNAME` is the ID of a specific cluster, with `-` replaced by `_`.
170
181
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`.
171
182
* 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.
178
189
We leave the implementation extensible enough to add further Git management tools and CI systems without needing breaking changes.
179
190
180
191
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.
182
193
+
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.
184
195
+
185
196
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.
187
198
188
199
External Catalog Repositories::
189
200
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.
0 commit comments