Skip to content

Commit 3840940

Browse files
authored
Merge pull request #1160 from fluxcd/helm-cert-secret
helmrepo: add `.spec.certSecretRef` for specifying TLS auth data
2 parents a4b0a88 + 4a55ce2 commit 3840940

17 files changed

+669
-527
lines changed

api/v1beta2/helmrepository_types.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,18 @@ type HelmRepositorySpec struct {
5151
// for the HelmRepository.
5252
// For HTTP/S basic auth the secret must contain 'username' and 'password'
5353
// fields.
54-
// For TLS the secret must contain a 'certFile' and 'keyFile', and/or
55-
// 'caFile' fields.
54+
// Support for TLS auth using the 'certFile' and 'keyFile', and/or 'caFile'
55+
// keys is deprecated. Please use `.spec.certSecretRef` instead.
5656
// +optional
5757
SecretRef *meta.LocalObjectReference `json:"secretRef,omitempty"`
5858

59+
// CertSecretRef specifies the Secret containing the TLS authentication
60+
// data. The secret must contain a 'certFile' and 'keyFile', and/or 'caFile'
61+
// fields. It takes precedence over the values specified in the Secret
62+
// referred to by `.spec.secretRef`.
63+
// +optional
64+
CertSecretRef *meta.LocalObjectReference `json:"certSecretRef,omitempty"`
65+
5966
// PassCredentials allows the credentials from the SecretRef to be passed
6067
// on to a host that does not match the host as defined in URL.
6168
// This may be required if the host of the advertised chart URLs in the

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/source.toolkit.fluxcd.io_helmrepositories.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,18 @@ spec:
296296
required:
297297
- namespaceSelectors
298298
type: object
299+
certSecretRef:
300+
description: CertSecretRef specifies the Secret containing the TLS
301+
authentication data. The secret must contain a 'certFile' and 'keyFile',
302+
and/or 'caFile' fields. It takes precedence over the values specified
303+
in the Secret referred to by `.spec.secretRef`.
304+
properties:
305+
name:
306+
description: Name of the referent.
307+
type: string
308+
required:
309+
- name
310+
type: object
299311
interval:
300312
description: Interval at which to check the URL for updates.
301313
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
@@ -323,8 +335,9 @@ spec:
323335
secretRef:
324336
description: SecretRef specifies the Secret containing authentication
325337
credentials for the HelmRepository. For HTTP/S basic auth the secret
326-
must contain 'username' and 'password' fields. For TLS the secret
327-
must contain a 'certFile' and 'keyFile', and/or 'caFile' fields.
338+
must contain 'username' and 'password' fields. Support for TLS auth
339+
using the 'certFile' and 'keyFile', and/or 'caFile' keys is deprecated.
340+
Please use `.spec.certSecretRef` instead.
328341
properties:
329342
name:
330343
description: Name of the referent.

docs/api/v1beta2/source.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,25 @@ github.com/fluxcd/pkg/apis/meta.LocalObjectReference
792792
for the HelmRepository.
793793
For HTTP/S basic auth the secret must contain ‘username’ and ‘password’
794794
fields.
795-
For TLS the secret must contain a ‘certFile’ and ‘keyFile’, and/or
796-
&lsquo;caFile&rsquo; fields.</p>
795+
Support for TLS auth using the &lsquo;certFile&rsquo; and &lsquo;keyFile&rsquo;, and/or &lsquo;caFile&rsquo;
796+
keys is deprecated. Please use <code>.spec.certSecretRef</code> instead.</p>
797+
</td>
798+
</tr>
799+
<tr>
800+
<td>
801+
<code>certSecretRef</code><br>
802+
<em>
803+
<a href="https://pkg.go.dev/github.com/fluxcd/pkg/apis/meta#LocalObjectReference">
804+
github.com/fluxcd/pkg/apis/meta.LocalObjectReference
805+
</a>
806+
</em>
807+
</td>
808+
<td>
809+
<em>(Optional)</em>
810+
<p>CertSecretRef specifies the Secret containing the TLS authentication
811+
data. The secret must contain a &lsquo;certFile&rsquo; and &lsquo;keyFile&rsquo;, and/or &lsquo;caFile&rsquo;
812+
fields. It takes precedence over the values specified in the Secret
813+
referred to by <code>.spec.secretRef</code>.</p>
797814
</td>
798815
</tr>
799816
<tr>
@@ -2459,8 +2476,25 @@ github.com/fluxcd/pkg/apis/meta.LocalObjectReference
24592476
for the HelmRepository.
24602477
For HTTP/S basic auth the secret must contain &lsquo;username&rsquo; and &lsquo;password&rsquo;
24612478
fields.
2462-
For TLS the secret must contain a &lsquo;certFile&rsquo; and &lsquo;keyFile&rsquo;, and/or
2463-
&lsquo;caFile&rsquo; fields.</p>
2479+
Support for TLS auth using the &lsquo;certFile&rsquo; and &lsquo;keyFile&rsquo;, and/or &lsquo;caFile&rsquo;
2480+
keys is deprecated. Please use <code>.spec.certSecretRef</code> instead.</p>
2481+
</td>
2482+
</tr>
2483+
<tr>
2484+
<td>
2485+
<code>certSecretRef</code><br>
2486+
<em>
2487+
<a href="https://pkg.go.dev/github.com/fluxcd/pkg/apis/meta#LocalObjectReference">
2488+
github.com/fluxcd/pkg/apis/meta.LocalObjectReference
2489+
</a>
2490+
</em>
2491+
</td>
2492+
<td>
2493+
<em>(Optional)</em>
2494+
<p>CertSecretRef specifies the Secret containing the TLS authentication
2495+
data. The secret must contain a &lsquo;certFile&rsquo; and &lsquo;keyFile&rsquo;, and/or &lsquo;caFile&rsquo;
2496+
fields. It takes precedence over the values specified in the Secret
2497+
referred to by <code>.spec.secretRef</code>.</p>
24642498
</td>
24652499
</tr>
24662500
<tr>

docs/spec/v1beta2/helmrepositories.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,37 @@ flux create secret oci ghcr-auth \
452452
--password=${GITHUB_PAT}
453453
```
454454

455-
#### TLS authentication
455+
**Note:** Support for specifying TLS authentication data using this API has been
456+
deprecated. Please use [`.spec.certSecretRef`](#cert-secret-reference) instead.
457+
If the controller uses the secret specfied by this field to configure TLS, then
458+
a deprecation warning will be logged.
459+
460+
### Cert secret reference
456461

457462
**Note:** TLS authentication is not yet supported by OCI Helm repositories.
458463

459-
To provide TLS credentials to use while connecting with the Helm repository,
460-
the referenced Secret is expected to contain `.data.certFile` and
461-
`.data.keyFile`, and/or `.data.caFile` values.
464+
`.spec.certSecretRef.name` is an optional field to specify a secret containing TLS
465+
certificate data. The secret can contain the following keys:
462466

463-
For example:
467+
* `certFile` and `keyFile`, to specify the client certificate and private key used for
468+
TLS client authentication. These must be used in conjunction, i.e. specifying one without
469+
the other will lead to an error.
470+
* `caFile`, to specify the CA certificate used to verify the server, which is required
471+
if the server is using a self-signed certificate.
472+
473+
If the server is using a self-signed certificate and has TLS client authentication enabled,
474+
all three values are required.
475+
476+
All the files in the secret are expected to be [PEM-encoded][pem-encoding]. Assuming you have
477+
three files; `client.key`, `client.crt` and `ca.crt` for the client private key, client
478+
certificate and the CA certificate respectively, you can generate the required secret using
479+
the `flux creat secret helm` command:
480+
481+
```sh
482+
flux create secret helm tls --key-file=client.key --cert-file=client.crt --ca-file=ca.crt
483+
```
484+
485+
Example usage:
464486

465487
```yaml
466488
---
@@ -472,7 +494,7 @@ metadata:
472494
spec:
473495
interval: 5m0s
474496
url: https://example.com
475-
secretRef:
497+
certSecretRef:
476498
name: example-tls
477499
---
478500
apiVersion: v1

0 commit comments

Comments
 (0)