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
Copy file name to clipboardExpand all lines: README.md
+146-6Lines changed: 146 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ __ _ __
14
14
CLI tool for performing GitOps operations
15
15
16
16
## Usage
17
+
17
18
```
18
19
NAME:
19
20
gitpos - GitOps CLI
@@ -36,16 +37,21 @@ GLOBAL OPTIONS:
36
37
```
37
38
38
39
### Planning secret application to a cluster
40
+
39
41
**NOTE:** It is expected, that the cluster's KUBECONFIG is already set up. Alternatively, the `--kubeconfig` flag can be used.
40
42
41
43
```bash
42
44
gitops secrets plan kubernetes
43
45
```
46
+
44
47
Or in short
48
+
45
49
```bash
46
50
gitops s p k8s
47
51
```
52
+
48
53
Example output:
54
+
49
55
```
50
56
__ _ __
51
57
\ \ ____ _(_) /_____ ____ _____
@@ -74,17 +80,22 @@ use gitops secrets apply kubernetes to apply these changes to your cluster
74
80
```
75
81
76
82
### Applying secrets to a cluster
83
+
77
84
**NOTE:** It is expected, that the cluster's KUBECONFIG is already set up. Alternatively, the `--kubeconfig` flag can be used.
78
85
79
86
```bash
80
87
gitops secrets apply kubernetes
81
88
```
89
+
82
90
Or in short
91
+
83
92
```bash
84
93
gitops s a k8s
85
94
```
95
+
86
96
The user will be prompted to confirm the changes before they are applied to the cluster. The prompt can be bypassed by using the `--auto-approve` flag.
87
97
Example output:
98
+
88
99
```
89
100
__ _ __
90
101
\ \ ____ _(_) /_____ ____ _____
@@ -168,7 +179,8 @@ The secrets files must follow the following format:
168
179
169
180
```yaml
170
181
# target of the secret
171
-
target: < k8s | vault >
182
+
targetType: < k8s | vault >
183
+
172
184
# name of the secret
173
185
name: <my-secret-name>
174
186
# optional namespace of the secret (default: default)
@@ -185,8 +197,8 @@ data:
185
197
##### Case 1: Secret for K8s
186
198
187
199
```yaml
188
-
#target of the secret
189
-
target: k8s
200
+
#targetType of the secret
201
+
targetType: k8s
190
202
# name of the secret
191
203
name: my-secret-name
192
204
# optional namespace of the secret (default: default)
@@ -208,27 +220,155 @@ name: my-secret-name
208
220
209
221
This implies, that the filename must be a valid K8s secret name.
210
222
211
-
212
223
##### Case 2: Secret for Vault
224
+
213
225
**NOTE:** Vault secrets are still WIP
214
226
215
227
```yaml
216
228
# target of the secret
217
-
target: vault
229
+
targetType: vault
218
230
# name of the secret - will be used as path in vault
219
231
name: /my/secret/name
220
232
# data of the secret as kv pairs
221
233
data:
222
234
key: value
223
235
```
224
236
225
-
226
237
#### Secrets Templating
227
238
228
239
It is possible to use Go templates in the secret files. The values will originate from sops-encrypted `values.gitops.secret.enc.y[a]ml` files.
229
240
Values files can be located anywhere in the repository. The GitOps CLI will pick up all files that are located on the direct path towards the respective secret file.
230
241
Values files closer to the secret file will have higher precedence. Any object structure is allowed to be used in a values file.
231
242
243
+
Example:
244
+
245
+
```yaml
246
+
# /foo/bar/dev/values.gitops.secret.enc.yaml
247
+
environment: dev
248
+
database:
249
+
host: localhost
250
+
port: 5432
251
+
user: postgres
252
+
password: postgres
253
+
```
254
+
255
+
```yaml
256
+
# /foo/bar/dev/values.gitops.secret.enc.yaml
257
+
targetType: k8s
258
+
# name of the secret - will be used as path in vault
**NOTE** that the template string (`{{ .Values.someValue }}`) must be enclosed in quotes for sops to work properly. In the above example, the entire `application.properties` data value is considered as a string and thus does not need further quoting.
269
+
270
+
#### Multi-cluster support
271
+
It is possible to address multiple clusters with a single GitOps repository.
The kubeconfig file can either be a plain text file or a sops-encrypted file. If the file is encrypted, it must adhere to the following naming convention to be decrypted properly:
To check connectivity with the configured clusters use
304
+
```
305
+
gitops clusters test
306
+
```
307
+
```
308
+
__ _ __
309
+
\ \ _____(_) /______________
310
+
\ \ / __ `/ / __/ __\/__\/___/
311
+
/ / / /_/ / / /_/ /_/ / /_/ (__ )
312
+
/_/ \__, /_/\__/\____/ .___/____/
313
+
/____/ /_/
314
+
315
+
Cluster: __default (v1.25.3) Connected: true
316
+
Cluster: dev (v1.24.8) Connected: true
317
+
Cluster: int (v1.24.8) Connected: true
318
+
Cluster: prod (v1.24.8) Connected: true
319
+
```
320
+
321
+
A secret can be configured to be applied to a specific cluster using the `target` attribute in the secret file. The default value is the `__default` cluster which is inferred from the `KUBECONFIG` environment variable or the default kubeconfig file. The `target` attribute can also be set using a templating variable so that all secrets under a certain directory will be applied to a specific cluster.
target: "{{ .Values.target }}"# will be replaced with "dev"
330
+
name: my-service
331
+
data:
332
+
key: value
333
+
```
334
+
335
+
By default, secrets will be applied to all configured clusters. This can be limited by giving the cluster as an argument:
336
+
```
337
+
gitops secrets plan kubernetes dev
338
+
__ _ __
339
+
\ \ ____ _(_) /_____ ____ _____
340
+
\ \ / __ `/ / __/ __ \/ __ \/ ___/
341
+
/ / / /_/ / / /_/ /_/ / /_/ (__ )
342
+
/_/ \__, /_/\__/\____/ .___/____/
343
+
/____/ /_/
344
+
345
+
Limiting to cluster dev
346
+
347
+
[Loading local secrets] 100% |██████████████████████████████████████████████████| (63/63)
348
+
349
+
350
+
No changes to apply.
351
+
```
352
+
353
+
#### Directory limiter
354
+
It is possible to restrict the secrets input to a specific directory to speed up loading and decryption of secrets. This can be done by providing the `--dir` flag:
355
+
```
356
+
gitops secrets --dir application/dev plan kubernetes
357
+
358
+
__ _ __
359
+
\ \ ____ _(_) /_____ ____ _____
360
+
\ \ / __ `/ / __/ __ \/ __ \/ ___/
361
+
/ / / /_/ / / /_/ /_/ / /_/ (__ )
362
+
/_/ \__, /_/\__/\____/ .___/____/
363
+
/____/ /_/
364
+
365
+
Limiting to directory applications/dev
366
+
367
+
[Loading local secrets] 100% |██████████████████████████████████████████████████| (1/1)
368
+
369
+
No changes to apply.
370
+
```
371
+
**NOTE** that the directory path must be relative to the repository root and that only forward slashes (`/`) are supported.
0 commit comments