@@ -310,42 +310,62 @@ fetch the image pull secrets attached to the service account and use them for au
310
310
**Note:** that for a publicly accessible image repository, you don't need to provide a `secretRef`
311
311
nor `serviceAccountName`.
312
312
313
- # ## TLS Certificates
313
+ # ## Cert secret reference
314
314
315
- ` .spec.certSecretRef` field names a secret with TLS certificate data. This is for two separate
316
- purposes :
315
+ ` .spec.certSecretRef.name ` is an optional field to specify a secret containing
316
+ TLS certificate data. The secret can contain the following keys :
317
317
318
- - to provide a client certificate and private key, if you use a certificate to authenticate with
319
- the container registry; and,
320
- - to provide a CA certificate, if the registry uses a self-signed certificate.
318
+ * `tls.crt` and `tls.key`, to specify the client certificate and private key used
319
+ for TLS client authentication. These must be used in conjunction, i.e.
320
+ specifying one without the other will lead to an error.
321
+ * `ca.crt`, to specify the CA certificate used to verify the server, which is
322
+ required if the server is using a self-signed certificate.
321
323
322
- These will often go together, if you are hosting a container registry yourself. All the files in the
323
- secret are expected to be [PEM-encoded][pem-encoding]. This is an ASCII format for certificates and
324
- keys; `openssl` and such tools will typically give you an option of PEM output.
324
+ If the server is using a self-signed certificate and has TLS client
325
+ authentication enabled, all three values are required.
325
326
326
- Assuming you have obtained a certificate file and private key and put them in the files `client.crt`
327
- and `client.key` respectively, you can create a secret with `kubectl` like this :
327
+ The Secret should be of type `Opaque` or `kubernetes.io/tls`. All the files in
328
+ the Secret are expected to be [PEM-encoded][pem-encoding]. Assuming you have
329
+ three files; `client.key`, `client.crt` and `ca.crt` for the client private key,
330
+ client certificate and the CA certificate respectively, you can generate the
331
+ required Secret using the `flux create secret tls` command :
328
332
329
- ` ` ` bash
330
- kubectl create secret generic tls-certs \
331
- --from-file=certFile=client.crt \
332
- --from-file=keyFile=client.key
333
+ ` ` ` sh
334
+ flux create secret tls --tls-key-file=client.key --tls-crt-file=client.crt --ca-crt-file=ca.crt
333
335
` ` `
334
336
335
- You could also [prepare a secret and encrypt it][sops-guide]; the important bit is that the data
336
- keys in the secret are `certFile` and `keyFile`.
337
-
338
- If you have a CA certificate for the client to use, the data key for that is `caFile`. Adapting the
339
- previous example, if you have the certificate in the file `ca.crt`, and the client certificate and
340
- key as before, the whole command would be :
337
+ Example usage :
341
338
342
- ` ` ` bash
343
- kubectl create secret generic tls-certs \
344
- --from-file=certFile=client.crt \
345
- --from-file=keyFile=client.key \
346
- --from-file=caFile=ca.crt
339
+ ` ` ` yaml
340
+ ---
341
+ apiVersion: source.toolkit.fluxcd.io/v1beta2
342
+ kind: OCIRepository
343
+ metadata:
344
+ name: example
345
+ namespace: default
346
+ spec:
347
+ interval: 5m0s
348
+ url: oci://example.com
349
+ certSecretRef:
350
+ name: example-tls
351
+ ---
352
+ apiVersion: v1
353
+ kind: Secret
354
+ metadata:
355
+ name: example-tls
356
+ namespace: default
357
+ type: kubernetes.io/tls # or Opaque
358
+ data:
359
+ tls.crt: <BASE64>
360
+ tls.key: <BASE64>
361
+ # NOTE: Can be supplied without the above values
362
+ ca.crt: <BASE64>
347
363
` ` `
348
364
365
+ **Warning:** Support for the `caFile`, `certFile` and `keyFile` keys have been
366
+ deprecated. If you have any Secrets using these keys and specified in an
367
+ OCIRepository, the controller will log a deprecation warning.
368
+
349
369
# ## Insecure
350
370
351
371
` .spec.insecure` is an optional field to allow connecting to an insecure (HTTP)
0 commit comments