Skip to content

Commit 555756d

Browse files
committed
docs: improve mTLS documentation structure and visibility
Reorganize Certificate secret reference section to prioritize mutual TLS authentication discovery and reduce user friction. The previous structure buried mTLS information within generic certificate documentation, causing users to miss this important security feature. Create dedicated sections for mTLS and CA-only authentication with complete examples and clear explanations of field requirements. Use stringData format in examples for better readability and align documentation structure with other FluxCD components. Signed-off-by: cappyzawa <[email protected]>
1 parent ab31efd commit 555756d

File tree

1 file changed

+67
-22
lines changed

1 file changed

+67
-22
lines changed

docs/spec/v1beta2/imagerepositories.md

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,53 +188,98 @@ see the integration [docs](/flux/integrations/).
188188
### Certificate secret reference
189189

190190
`.spec.certSecretRef.name` is an optional field to specify a secret containing
191-
TLS certificate data. The secret can contain the following keys:
191+
TLS certificate data for secure communication. The secret must be of type
192+
`Opaque` or `kubernetes.io/tls`.
192193

193-
* `tls.crt` and `tls.key`, to specify the client certificate and private key used
194-
for TLS client authentication. These must be used in conjunction, i.e.
195-
specifying one without the other will lead to an error.
196-
* `ca.crt`, to specify the CA certificate used to verify the server, which is
197-
required if the server is using a self-signed certificate.
194+
#### Supported configurations
198195

199-
If the server is using a self-signed certificate and has TLS client
200-
authentication enabled, all three values are required.
196+
- **Mutual TLS (mTLS)**: Client certificate authentication (provide `tls.crt` + `tls.key`, optionally with `ca.crt`)
197+
- **CA-only**: Server authentication (provide `ca.crt` only)
201198

202-
The Secret should be of type `Opaque` or `kubernetes.io/tls`. All the files in
203-
the Secret are expected to be [PEM-encoded][pem-encoding]. Assuming you have
204-
three files; `client.key`, `client.crt` and `ca.crt` for the client private key,
205-
client certificate and the CA certificate respectively, you can generate the
206-
required Secret using the `flux create secret tls` command:
199+
#### Mutual TLS Authentication
200+
201+
Mutual TLS authentication allows for secure client-server communication using
202+
client certificates stored in Kubernetes secrets. Both `tls.crt` and `tls.key`
203+
must be specified together for client certificate authentication. The `ca.crt`
204+
field is optional but required when connecting to servers with self-signed certificates.
205+
206+
All the files in the Secret are expected to be [PEM-encoded][pem-encoding].
207+
Assuming you have three files; `client.key`, `client.crt` and `ca.crt` for the
208+
client private key, client certificate and the CA certificate respectively, you
209+
can generate the required Secret using the `flux create secret tls` command:
207210

208211
```sh
209212
flux create secret tls --tls-key-file=client.key --tls-crt-file=client.crt --ca-crt-file=ca.crt
210213
```
211214

212-
Example usage:
215+
##### Example: mTLS Configuration
213216

214217
```yaml
215218
---
216219
apiVersion: image.toolkit.fluxcd.io/v1beta2
217220
kind: ImageRepository
218221
metadata:
219-
name: example
222+
name: example-mtls
220223
namespace: default
221224
spec:
222225
interval: 5m0s
223226
image: example.com
224227
certSecretRef:
225-
name: example-tls
228+
name: example-mtls-certs
226229
---
227230
apiVersion: v1
228231
kind: Secret
229232
metadata:
230-
name: example-tls
233+
name: example-mtls-certs
231234
namespace: default
232235
type: kubernetes.io/tls # or Opaque
233-
data:
234-
tls.crt: <BASE64>
235-
tls.key: <BASE64>
236-
# NOTE: Can be supplied without the above values
237-
ca.crt: <BASE64>
236+
stringData:
237+
tls.crt: |
238+
-----BEGIN CERTIFICATE-----
239+
<client certificate>
240+
-----END CERTIFICATE-----
241+
tls.key: |
242+
-----BEGIN PRIVATE KEY-----
243+
<client private key>
244+
-----END PRIVATE KEY-----
245+
ca.crt: |
246+
-----BEGIN CERTIFICATE-----
247+
<certificate authority certificate>
248+
-----END CERTIFICATE-----
249+
```
250+
251+
#### CA Certificate Authentication
252+
253+
CA certificate authentication provides server authentication when connecting to
254+
container registries with self-signed or custom CA certificates. Only the `ca.crt`
255+
field is required for this configuration.
256+
257+
##### Example: CA Certificate Configuration
258+
259+
```yaml
260+
---
261+
apiVersion: image.toolkit.fluxcd.io/v1beta2
262+
kind: ImageRepository
263+
metadata:
264+
name: example-ca
265+
namespace: default
266+
spec:
267+
interval: 5m0s
268+
image: example.com
269+
certSecretRef:
270+
name: example-ca-cert
271+
---
272+
apiVersion: v1
273+
kind: Secret
274+
metadata:
275+
name: example-ca-cert
276+
namespace: default
277+
type: kubernetes.io/tls # or Opaque
278+
stringData:
279+
ca.crt: |
280+
-----BEGIN CERTIFICATE-----
281+
<certificate authority certificate>
282+
-----END CERTIFICATE-----
238283
```
239284

240285
**Warning:** Support for the `caFile`, `certFile` and `keyFile` keys have been

0 commit comments

Comments
 (0)