Skip to content

Commit fe9f02f

Browse files
Apply suggestions from code review
Co-authored-by: Simon Gerber <simon.gerber@vshn.ch>
1 parent d337890 commit fe9f02f

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

docs/modules/SDDs/pages/0032-compile-pipeline.adoc

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ This will go hand-in-hand with the existing repository management features in Li
4444
=== Requirements for Pipeline Configuration
4545

4646
Lieutenant imposes certain assumptions on the configuration of the pipeline:
47-
Namely, the pipeline has to be set up on the tenant repository by way of adding (arbitrary) files to the repository,
48-
and it is configured through setting CI/CD variables on the repository.
47+
Namely, the pipeline has to be set up on the tenant repository by way of adding (arbitrary) files to the repository, and it is configured through setting CI/CD variables on the repository.
4948

5049
In particular, Lieutenant configures the following CI/CD variables:
5150

@@ -57,10 +56,10 @@ In particular, Lieutenant configures the following CI/CD variables:
5756

5857
=== GitRepo CRD
5958

60-
We add two new fields to the `GitRepoTemplate` (and, by extension, the `GitRepo`) CRD, under the `.spec` key, called `accessTokenSecretRef` and `ciVariables`.
59+
We add two new fields to the `GitRepoTemplate` (and, by extension, the `GitRepo`) CRD, under the `.spec` key, called `accessTokenSecretName` and `ciVariables`.
6160

62-
The `accessTokenSecretRef` field contains a reference to a secret.
63-
If it is set, the Lieutenant operator will store an access token into this secret, which can be used to access the git repository.
61+
The `accessTokenSecretName` field contains a reference to a secret.
62+
If it is set, the Lieutenant operator will store an access token into this secret, which can be used to access the Git repository.
6463
In the case of GitLab, this would be a Project Access Token with read-write access to the repository.
6564

6665
The `ciVariables` field contains a dictionary describing variable names and corresponding values.
@@ -73,10 +72,15 @@ kind: GitRepo
7372
metadata:
7473
name: my-repo
7574
spec:
76-
accessTokenSecretRef: my-repo-access-token
75+
accessTokenSecretName: my-repo-access-token
7776
ciVariables:
78-
COMMODORE_API_URL: ...
79-
COMMODORE_API_TOKEN: ...
77+
- name: COMMODORE_API_URL
78+
value: ...
79+
- name: COMMODORE_API_TOKEN
80+
valueFrom:
81+
secretKeyRef:
82+
name: api-token-secret
83+
key: token
8084
----
8185

8286
=== Cluster CRD
@@ -109,9 +113,6 @@ The `compilePipeline` field contains a dict with the following fields:
109113

110114
* `clusters`: List of cluster IDs of clusters for which the compile pipeline should be executed.
111115
This field is managed by the operator.
112-
* `pipelineFiles`: Dictionary containing file paths as keys, and file contents as values.
113-
These files will be added to the tenant's `gitRepoTemplate.templateFiles` by the Lieutenant operator.
114-
This field is optional; if absent, no new template files are added to the `gitRepoTemplate`.
115116

116117
[source,yaml]
117118
----
@@ -123,7 +124,23 @@ spec:
123124
compilePipeline:
124125
clusters:
125126
- c-my-cluster
126-
pipelineFiles:
127+
----
128+
129+
=== In-Repo CI/CD pipeline configuration
130+
131+
Configuring the CI pipeline usually happens through files committed to the corresponding repository.
132+
For a Lieutenant-managed pipeline configuration, these files should be managed by Lieutenant.
133+
To achieve this, we can leverage the existing mechanism to commit template files to git repositories:
134+
135+
[source,yaml]
136+
----
137+
apiVersion: syn.tools/v1alpha1
138+
kind: Tenant
139+
metadata:
140+
name: t-my-tenant
141+
spec:
142+
gitRepoTemplate:
143+
templateFiles:
127144
.gitlab-ci.yml: |
128145
include:
129146
- project: syn/commodore-compile-pipeline
@@ -132,6 +149,7 @@ spec:
132149
133150
----
134151

152+
135153
=== Operator
136154

137155
The Lieutenant Operator will be extended to automatically manage the compile pipeline for repositories where this is enabled (by way of configuring the `compilePipeline` field on the tenant and the `enableCompilePipeline` field on the cluster).
@@ -141,7 +159,7 @@ This way, it is possible to enable auto-compilation for some, but not all cluste
141159

142160
The operator will reconcile *GitRepos* as follows:
143161

144-
* When `spec.accessTokenSecretRef` is set, the operator generates an access token for the corresponding repository (via the repository host's API, using the API secret in `.spec.apiSecretRef`), and writes this token into a secret with the given name.
162+
* When `spec.accessTokenSecretName` is set, the operator generates an access token for the corresponding repository (via the repository host's API, using the API secret in `.spec.apiSecretRef`), and writes this token into a secret with the given name.
145163
In the case of GitLab, this is a Project Access Token.
146164
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.
147165
* The content of `.spec.ciVariables` is written to the repository's configuration on the git host.
@@ -158,13 +176,11 @@ The operator will reconcile *Tenants* as follows:
158176

159177
* When `.spec.compilePipeline` exists and isn't empty, the following entries are added to the tenant repository GitRepo's `.spec.ciVariables`:
160178
** `COMMODORE_API_URL`, containing the URL at which the Lieutenant API can be accessed.
161-
** `COMMODORE_API_TOKEN`, containing the tenant's access token for the Lieutenant API.
179+
** `COMMODORE_API_TOKEN`, containing a reference to the secret which contains the tenant's access token for the Lieutenant API.
162180
** `CLUSTERS`, containing a space-separated list of cluster IDs taken directly from `.spec.compilePipeline.clusters`.
163-
* For each entry in `.spec.compilePipeline.pipelineFiles` whose value isn't `{remove}`, a new corresponding entry is added to the tenant's `.spec.gitRepoTemplate.templateFiles`.
164-
* For each entry in `.spec.compilePipeline.pipelineFiles` whose value is `{remove}`, the corresponding entry is removed from the tenant's `.spec.gitRepoTemplate.templateFiles`.
165181
* For each entry in `.spec.compilePipeline.clusters`, another entry is added to the tenant repository GitRepo's `spec.ciVariabes`.
166182
The key is `ACCESS_TOKEN_CLUSTERNAME`, where `CLUSTERNAME` is the ID of a specific cluster, with `-` replaced by `_`.
167-
The value is the access token to access that cluster's catalog repository, taken from the secret specified in the catalog GitRepo configuration under `.spec.accessTokenSecretRef`.
183+
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`.
168184

169185
=== Implementation Details/Notes/Constraints
170186

0 commit comments

Comments
 (0)