Skip to content

Commit 887e5d5

Browse files
committed
[RFC-0010] Introduce KMS provider decryption with service account
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
1 parent 60afb73 commit 887e5d5

14 files changed

Lines changed: 308 additions & 235 deletions

File tree

api/v1/kustomization_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,18 @@ type Decryption struct {
205205
// +required
206206
Provider string `json:"provider"`
207207

208+
// ServiceAccountName is the name of the service account used to
209+
// authenticate with KMS services from cloud providers. If a
210+
// static credential for a given cloud provider is defined
211+
// inside the Secret referenced by SecretRef, that static
212+
// credential takes priority.
213+
// +optional
214+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
215+
208216
// The secret name containing the private OpenPGP keys used for decryption.
217+
// A static credential for a cloud provider defined inside the Secret
218+
// takes priority to secret-less authentication with the ServiceAccountName
219+
// field.
209220
// +optional
210221
SecretRef *meta.LocalObjectReference `json:"secretRef,omitempty"`
211222
}

config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,26 @@ spec:
8686
- sops
8787
type: string
8888
secretRef:
89-
description: The secret name containing the private OpenPGP keys
90-
used for decryption.
89+
description: |-
90+
The secret name containing the private OpenPGP keys used for decryption.
91+
A static credential for a cloud provider defined inside the Secret
92+
takes priority to secret-less authentication with the ServiceAccountName
93+
field.
9194
properties:
9295
name:
9396
description: Name of the referent.
9497
type: string
9598
required:
9699
- name
97100
type: object
101+
serviceAccountName:
102+
description: |-
103+
ServiceAccountName is the name of the service account used to
104+
authenticate with KMS services from cloud providers. If a
105+
static credential for a given cloud provider is defined
106+
inside the Secret referenced by SecretRef, that static
107+
credential takes priority.
108+
type: string
98109
required:
99110
- provider
100111
type: object

docs/api/v1/kustomize.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,22 @@ string
574574
</tr>
575575
<tr>
576576
<td>
577+
<code>serviceAccountName</code><br>
578+
<em>
579+
string
580+
</em>
581+
</td>
582+
<td>
583+
<em>(Optional)</em>
584+
<p>ServiceAccountName is the name of the service account used to
585+
authenticate with KMS services from cloud providers. If a
586+
static credential for a given cloud provider is defined
587+
inside the Secret referenced by SecretRef, that static
588+
credential takes priority.</p>
589+
</td>
590+
</tr>
591+
<tr>
592+
<td>
577593
<code>secretRef</code><br>
578594
<em>
579595
<a href="https://godoc.org/github.com/fluxcd/pkg/apis/meta#LocalObjectReference">
@@ -583,7 +599,10 @@ github.com/fluxcd/pkg/apis/meta.LocalObjectReference
583599
</td>
584600
<td>
585601
<em>(Optional)</em>
586-
<p>The secret name containing the private OpenPGP keys used for decryption.</p>
602+
<p>The secret name containing the private OpenPGP keys used for decryption.
603+
A static credential for a cloud provider defined inside the Secret
604+
takes priority to secret-less authentication with the ServiceAccountName
605+
field.</p>
587606
</td>
588607
</tr>
589608
</tbody>

docs/spec/v1/kustomizations.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,15 @@ It has two fields:
847847
- `.secretRef.name`: The name of the secret that contains the keys to be used for
848848
decryption. This field can be omitted when using the
849849
[global decryption](#controller-global-decryption) option.
850+
- `.serviceAccountName`: The name of the service account used for
851+
secret-less authentication with KMS services from cloud providers.
852+
If a static credential for a given cloud provider is defined
853+
inside the secret referenced by `.secretRef`, that static
854+
credential takes priority.
855+
The configuration of this service account follows the same structure defined in the
856+
[workload identity](/flux/installation/configuration/workload-identity/) documentation.
857+
This field allows users to define individual cloud identities for each Kustomization
858+
object. It's an alternative to using the cloud identity associated with the controller.
850859

851860
```yaml
852861
---

go.mod

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ replace github.com/fluxcd/kustomize-controller/api => ./api
1111
replace github.com/opencontainers/go-digest => github.com/opencontainers/go-digest v1.0.1-0.20220411205349-bde1400a84be
1212

1313
require (
14+
cloud.google.com/go/kms v1.21.1
1415
filippo.io/age v1.2.1
1516
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6
1617
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1
1718
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2
18-
github.com/aws/aws-sdk-go-v2/credentials v1.17.65
19+
github.com/aws/aws-sdk-go-v2 v1.36.3
20+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67
1921
github.com/cyphar/filepath-securejoin v0.4.1
2022
github.com/dimchansky/utfbom v1.1.1
2123
github.com/fluxcd/cli-utils v0.36.0-flux.12
@@ -24,6 +26,8 @@ require (
2426
github.com/fluxcd/pkg/apis/event v0.16.0
2527
github.com/fluxcd/pkg/apis/kustomize v1.9.0
2628
github.com/fluxcd/pkg/apis/meta v1.10.0
29+
github.com/fluxcd/pkg/auth v0.9.1-0.20250417205012-6cd2fbf01a6e
30+
github.com/fluxcd/pkg/cache v0.7.0
2731
github.com/fluxcd/pkg/http/fetch v0.15.0
2832
github.com/fluxcd/pkg/kustomize v1.16.0
2933
github.com/fluxcd/pkg/runtime v0.58.0
@@ -38,8 +42,9 @@ require (
3842
github.com/ory/dockertest/v3 v3.11.0
3943
github.com/spf13/pflag v1.0.6
4044
golang.org/x/net v0.38.0
41-
k8s.io/api v0.32.2
42-
k8s.io/apimachinery v0.32.2
45+
golang.org/x/oauth2 v0.28.0
46+
k8s.io/api v0.32.3
47+
k8s.io/apimachinery v0.32.3
4348
k8s.io/client-go v0.32.2
4449
k8s.io/utils v0.0.0-20241210054802-24370beab758
4550
sigs.k8s.io/controller-runtime v0.20.4
@@ -63,7 +68,6 @@ require (
6368
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
6469
cloud.google.com/go/compute/metadata v0.6.0 // indirect
6570
cloud.google.com/go/iam v1.4.2 // indirect
66-
cloud.google.com/go/kms v1.21.1 // indirect
6771
cloud.google.com/go/longrunning v0.6.6 // indirect
6872
cloud.google.com/go/monitoring v1.24.1 // indirect
6973
cloud.google.com/go/storage v1.51.0 // indirect
@@ -82,24 +86,24 @@ require (
8286
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
8387
github.com/ProtonMail/go-crypto v1.1.6 // indirect
8488
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
85-
github.com/aws/aws-sdk-go-v2 v1.36.3 // indirect
8689
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect
87-
github.com/aws/aws-sdk-go-v2/config v1.29.12 // indirect
90+
github.com/aws/aws-sdk-go-v2/config v1.29.14 // indirect
8891
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
8992
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.69 // indirect
9093
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
9194
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
9295
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
9396
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 // indirect
97+
github.com/aws/aws-sdk-go-v2/service/ecr v1.43.3 // indirect
9498
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
9599
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.0 // indirect
96100
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
97101
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 // indirect
98102
github.com/aws/aws-sdk-go-v2/service/kms v1.38.1 // indirect
99103
github.com/aws/aws-sdk-go-v2/service/s3 v1.78.2 // indirect
100-
github.com/aws/aws-sdk-go-v2/service/sso v1.25.2 // indirect
101-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0 // indirect
102-
github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 // indirect
104+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
105+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
106+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
103107
github.com/aws/smithy-go v1.22.3 // indirect
104108
github.com/beorn7/perks v1.0.1 // indirect
105109
github.com/blang/semver v3.5.1+incompatible // indirect
@@ -225,7 +229,6 @@ require (
225229
go.uber.org/zap v1.27.0 // indirect
226230
golang.org/x/crypto v0.36.0 // indirect
227231
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
228-
golang.org/x/oauth2 v0.28.0 // indirect
229232
golang.org/x/sync v0.12.0 // indirect
230233
golang.org/x/sys v0.31.0 // indirect
231234
golang.org/x/term v0.30.0 // indirect

go.sum

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38y
7575
github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg=
7676
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 h1:zAybnyUQXIZ5mok5Jqwlf58/TFE7uvd3IAsa1aF9cXs=
7777
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10/go.mod h1:qqvMj6gHLR/EXWZw4ZbqlPbQUyenf4h82UQUlKc+l14=
78-
github.com/aws/aws-sdk-go-v2/config v1.29.12 h1:Y/2a+jLPrPbHpFkpAAYkVEtJmxORlXoo5k2g1fa2sUo=
79-
github.com/aws/aws-sdk-go-v2/config v1.29.12/go.mod h1:xse1YTjmORlb/6fhkWi8qJh3cvZi4JoVNhc+NbJt4kI=
80-
github.com/aws/aws-sdk-go-v2/credentials v1.17.65 h1:q+nV2yYegofO/SUXruT+pn4KxkxmaQ++1B/QedcKBFM=
81-
github.com/aws/aws-sdk-go-v2/credentials v1.17.65/go.mod h1:4zyjAuGOdikpNYiSGpsGz8hLGmUzlY8pc8r9QQ/RXYQ=
78+
github.com/aws/aws-sdk-go-v2/config v1.29.14 h1:f+eEi/2cKCg9pqKBoAIwRGzVb70MRKqWX4dg1BDcSJM=
79+
github.com/aws/aws-sdk-go-v2/config v1.29.14/go.mod h1:wVPHWcIFv3WO89w0rE10gzf17ZYy+UVS1Geq8Iei34g=
80+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 h1:9KxtdcIA/5xPNQyZRgUSpYOE6j9Bc4+D7nZua0KGYOM=
81+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67/go.mod h1:p3C44m+cfnbv763s52gCqrjaqyPikj9Sg47kUVaNZQQ=
8282
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 h1:x793wxmUWVDhshP8WW2mlnXuFrO4cOd3HLBroh1paFw=
8383
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30/go.mod h1:Jpne2tDnYiFascUEs2AWHJL9Yp7A5ZVy3TNyxaAjD6M=
8484
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.69 h1:6VFPH/Zi9xYFMJKPQOX5URYkQoXRWeJ7V/7Y6ZDYoms=
@@ -91,6 +91,8 @@ github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d
9191
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo=
9292
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 h1:ZNTqv4nIdE/DiBfUUfXcLZ/Spcuz+RjeziUtNJackkM=
9393
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34/go.mod h1:zf7Vcd1ViW7cPqYWEHLHJkS50X0JS2IKz9Cgaj6ugrs=
94+
github.com/aws/aws-sdk-go-v2/service/ecr v1.43.3 h1:YyH8Hk73bYzdbvf6S8NF5z/fb/1stpiMnFSfL6jSfRA=
95+
github.com/aws/aws-sdk-go-v2/service/ecr v1.43.3/go.mod h1:iQ1skgw1XRK+6Lgkb0I9ODatAP72WoTILh0zXQ5DtbU=
9496
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b5IzM/lum78bZ590jy36+d/aFLgKF/4Vd1xPE=
9597
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA=
9698
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.0 h1:lguz0bmOoGzozP9XfRJR1QIayEYo+2vP/No3OfLF0pU=
@@ -103,12 +105,12 @@ github.com/aws/aws-sdk-go-v2/service/kms v1.38.1 h1:tecq7+mAav5byF+Mr+iONJnCBf4B
103105
github.com/aws/aws-sdk-go-v2/service/kms v1.38.1/go.mod h1:cQn6tAF77Di6m4huxovNM7NVAozWTZLsDRp9t8Z/WYk=
104106
github.com/aws/aws-sdk-go-v2/service/s3 v1.78.2 h1:jIiopHEV22b4yQP2q36Y0OmwLbsxNWdWwfZRR5QRRO4=
105107
github.com/aws/aws-sdk-go-v2/service/s3 v1.78.2/go.mod h1:U5SNqwhXB3Xe6F47kXvWihPl/ilGaEDe8HD/50Z9wxc=
106-
github.com/aws/aws-sdk-go-v2/service/sso v1.25.2 h1:pdgODsAhGo4dvzC3JAG5Ce0PX8kWXrTZGx+jxADD+5E=
107-
github.com/aws/aws-sdk-go-v2/service/sso v1.25.2/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI=
108-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0 h1:90uX0veLKcdHVfvxhkWUQSCi5VabtwMLFutYiRke4oo=
109-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.0/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs=
110-
github.com/aws/aws-sdk-go-v2/service/sts v1.33.17 h1:PZV5W8yk4OtH1JAuhV2PXwwO9v5G5Aoj+eMCn4T+1Kc=
111-
github.com/aws/aws-sdk-go-v2/service/sts v1.33.17/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4=
108+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 h1:1Gw+9ajCV1jogloEv1RRnvfRFia2cL6c9cuKV2Ps+G8=
109+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3/go.mod h1:qs4a9T5EMLl/Cajiw2TcbNt2UNo/Hqlyp+GiuG4CFDI=
110+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 h1:hXmVKytPfTy5axZ+fYbR5d0cFmC3JvwLm5kM83luako=
111+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1/go.mod h1:MlYRNmYu/fGPoxBQVvBYr9nyr948aY/WLUvwBMBJubs=
112+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 h1:1XuUZ8mYJw9B6lzAkXhqHlJd/XvaX32evhproijJEZY=
113+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19/go.mod h1:cQnB8CUnxbMU82JvlqjKR2HBOm3fe9pWorWBza6MBJ4=
112114
github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k=
113115
github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI=
114116
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
@@ -129,6 +131,8 @@ github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f h1:C5bqEmzEPLsHm9Mv73l
129131
github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
130132
github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4=
131133
github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE=
134+
github.com/coreos/go-oidc/v3 v3.14.1 h1:9ePWwfdwC4QKRlCXsJGou56adA/owXczOzwKdOumLqk=
135+
github.com/coreos/go-oidc/v3 v3.14.1/go.mod h1:HaZ3szPaZ0e4r6ebqvsLWlk2Tn+aejfmrfah6hnSYEU=
132136
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
133137
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
134138
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
@@ -183,6 +187,10 @@ github.com/fluxcd/pkg/apis/kustomize v1.9.0 h1:SJpT1CK58AnTvCpDKeGfMNA0Xud/4VReZ
183187
github.com/fluxcd/pkg/apis/kustomize v1.9.0/go.mod h1:AZl2GU03oPVue6SUivdiIYd/3mvF94j7t1G2JO26d4s=
184188
github.com/fluxcd/pkg/apis/meta v1.10.0 h1:rqbAuyl5ug7A5jjRf/rNwBXmNl6tJ9wG2iIsriwnQUk=
185189
github.com/fluxcd/pkg/apis/meta v1.10.0/go.mod h1:n7NstXHDaleAUMajcXTVkhz0MYkvEXy1C/eLI/t1xoI=
190+
github.com/fluxcd/pkg/auth v0.9.1-0.20250417205012-6cd2fbf01a6e h1:sEg38mTa4+G5LEfE8AvrnQHiFcC7BjUifs1Knv/H/+U=
191+
github.com/fluxcd/pkg/auth v0.9.1-0.20250417205012-6cd2fbf01a6e/go.mod h1:Z+k3+eoqwCYjpIhmLPlhVrsaqPI2ngjSSAvWEc5nR2s=
192+
github.com/fluxcd/pkg/cache v0.7.0 h1:6TTWbxCyAxErIAT338KrLTy96ds+vSDw4sEyypSISfs=
193+
github.com/fluxcd/pkg/cache v0.7.0/go.mod h1:EHpyMSXf/ECKIoKEQmNCOesH2wfAdpmXR/ZXD6VwWRg=
186194
github.com/fluxcd/pkg/envsubst v1.3.0 h1:84Ain+8EBvyzu6y0FsKRwNsvaSiKuqhTqeh/4yoGFFU=
187195
github.com/fluxcd/pkg/envsubst v1.3.0/go.mod h1:lz6HvqDnxbX0sIqjr1fxw0oTGYACLVFcOE/srKS0VQQ=
188196
github.com/fluxcd/pkg/http/fetch v0.15.0 h1:AJ1JuE2asuK4QMfbHjxctFURke5FvZtyljjI1Qv4ArQ=
@@ -555,12 +563,12 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
555563
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
556564
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
557565
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
558-
k8s.io/api v0.32.2 h1:bZrMLEkgizC24G9eViHGOPbW+aRo9duEISRIJKfdJuw=
559-
k8s.io/api v0.32.2/go.mod h1:hKlhk4x1sJyYnHENsrdCWw31FEmCijNGPJO5WzHiJ6Y=
566+
k8s.io/api v0.32.3 h1:Hw7KqxRusq+6QSplE3NYG4MBxZw1BZnq4aP4cJVINls=
567+
k8s.io/api v0.32.3/go.mod h1:2wEDTXADtm/HA7CCMD8D8bK4yuBUptzaRhYcYEEYA3k=
560568
k8s.io/apiextensions-apiserver v0.32.2 h1:2YMk285jWMk2188V2AERy5yDwBYrjgWYggscghPCvV4=
561569
k8s.io/apiextensions-apiserver v0.32.2/go.mod h1:GPwf8sph7YlJT3H6aKUWtd0E+oyShk/YHWQHf/OOgCA=
562-
k8s.io/apimachinery v0.32.2 h1:yoQBR9ZGkA6Rgmhbp/yuT9/g+4lxtsGYwW6dR6BDPLQ=
563-
k8s.io/apimachinery v0.32.2/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
570+
k8s.io/apimachinery v0.32.3 h1:JmDuDarhDmA/Li7j3aPrwhpNBA94Nvk5zLeOge9HH1U=
571+
k8s.io/apimachinery v0.32.3/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
564572
k8s.io/cli-runtime v0.32.2 h1:aKQR4foh9qeyckKRkNXUccP9moxzffyndZAvr+IXMks=
565573
k8s.io/cli-runtime v0.32.2/go.mod h1:a/JpeMztz3xDa7GCyyShcwe55p8pbcCVQxvqZnIwXN8=
566574
k8s.io/client-go v0.32.2 h1:4dYCD4Nz+9RApM2b/3BtVvBHw54QjMFUl1OLcJG5yOA=

internal/controller/kustomization_controller.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import (
2727
"time"
2828

2929
securejoin "github.com/cyphar/filepath-securejoin"
30-
"github.com/fluxcd/pkg/ssa/normalize"
31-
ssautil "github.com/fluxcd/pkg/ssa/utils"
3230
corev1 "k8s.io/api/core/v1"
3331
apierrors "k8s.io/apimachinery/pkg/api/errors"
3432
apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -53,6 +51,7 @@ import (
5351
apiacl "github.com/fluxcd/pkg/apis/acl"
5452
eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1"
5553
"github.com/fluxcd/pkg/apis/meta"
54+
"github.com/fluxcd/pkg/cache"
5655
"github.com/fluxcd/pkg/http/fetch"
5756
generator "github.com/fluxcd/pkg/kustomize"
5857
"github.com/fluxcd/pkg/runtime/acl"
@@ -64,6 +63,8 @@ import (
6463
"github.com/fluxcd/pkg/runtime/patch"
6564
"github.com/fluxcd/pkg/runtime/predicates"
6665
"github.com/fluxcd/pkg/ssa"
66+
"github.com/fluxcd/pkg/ssa/normalize"
67+
ssautil "github.com/fluxcd/pkg/ssa/utils"
6768
"github.com/fluxcd/pkg/tar"
6869
sourcev1 "github.com/fluxcd/source-controller/api/v1"
6970
sourcev1b2 "github.com/fluxcd/source-controller/api/v1beta2"
@@ -104,6 +105,7 @@ type KustomizationReconciler struct {
104105
DisallowedFieldManagers []string
105106
StrictSubstitutions bool
106107
GroupChangeLog bool
108+
TokenCache *cache.TokenCache
107109
}
108110

109111
// KustomizationReconcilerOptions contains options for the KustomizationReconciler.
@@ -615,17 +617,23 @@ func (r *KustomizationReconciler) generate(obj unstructured.Unstructured,
615617
func (r *KustomizationReconciler) build(ctx context.Context,
616618
obj *kustomizev1.Kustomization, u unstructured.Unstructured,
617619
workDir, dirPath string) ([]byte, error) {
618-
dec, cleanup, err := decryptor.NewTempDecryptor(workDir, r.Client, obj)
620+
dec, cleanup, err := decryptor.NewTempDecryptor(workDir, r.Client, obj, r.TokenCache)
619621
if err != nil {
620622
return nil, err
621623
}
622624
defer cleanup()
623625

624-
// Import decryption keys
626+
// First, we import decryption keys or cloud provider static
627+
// credentials from the secret.
625628
if err := dec.ImportKeys(ctx); err != nil {
626629
return nil, err
627630
}
628631

632+
// Then we set the secret-less authentication options for the
633+
// cloud providers that do not have static credentials after
634+
// importing the keys.
635+
dec.SetAuthOptions(ctx)
636+
629637
// Decrypt Kustomize EnvSources files before build
630638
if err = dec.DecryptSources(dirPath); err != nil {
631639
return nil, fmt.Errorf("error decrypting sources: %w", err)

0 commit comments

Comments
 (0)