Skip to content

Commit 2fb1482

Browse files
committed
[RFC-0010] Introduce workload identity auth for remote clusters
Signed-off-by: Matheus Pimenta <[email protected]>
1 parent 5217087 commit 2fb1482

29 files changed

+544
-314
lines changed

api/go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module github.com/fluxcd/kustomize-controller/api
33
go 1.24.0
44

55
require (
6-
github.com/fluxcd/pkg/apis/kustomize v1.10.0
7-
github.com/fluxcd/pkg/apis/meta v1.12.0
8-
k8s.io/apiextensions-apiserver v0.33.0
9-
k8s.io/apimachinery v0.33.0
6+
github.com/fluxcd/pkg/apis/kustomize v1.11.0
7+
github.com/fluxcd/pkg/apis/meta v1.17.0
8+
k8s.io/apiextensions-apiserver v0.33.2
9+
k8s.io/apimachinery v0.33.2
1010
sigs.k8s.io/controller-runtime v0.21.0
1111
)
1212

@@ -23,14 +23,14 @@ require (
2323
github.com/modern-go/reflect2 v1.0.2 // indirect
2424
github.com/spf13/pflag v1.0.6 // indirect
2525
github.com/x448/float16 v0.8.4 // indirect
26-
golang.org/x/net v0.40.0 // indirect
27-
golang.org/x/text v0.25.0 // indirect
28-
golang.org/x/tools v0.33.0 // indirect
26+
go.yaml.in/yaml/v2 v2.4.2 // indirect
27+
golang.org/x/net v0.41.0 // indirect
28+
golang.org/x/text v0.27.0 // indirect
2929
gopkg.in/inf.v0 v0.9.1 // indirect
3030
k8s.io/klog/v2 v2.130.1 // indirect
3131
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e // indirect
3232
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
3333
sigs.k8s.io/randfill v1.0.0 // indirect
3434
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 // indirect
35-
sigs.k8s.io/yaml v1.4.0 // indirect
35+
sigs.k8s.io/yaml v1.5.0 // indirect
3636
)

api/go.sum

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
22
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5-
github.com/fluxcd/pkg/apis/kustomize v1.10.0 h1:47EeSzkQvlQZdH92vHMe2lK2iR8aOSEJq95avw5idts=
6-
github.com/fluxcd/pkg/apis/kustomize v1.10.0/go.mod h1:UsqMV4sqNa1Yg0pmTsdkHRJr7bafBOENIJoAN+3ezaQ=
7-
github.com/fluxcd/pkg/apis/meta v1.12.0 h1:XW15TKZieC2b7MN8VS85stqZJOx+/b8jATQ/xTUhVYg=
8-
github.com/fluxcd/pkg/apis/meta v1.12.0/go.mod h1:+son1Va60x2eiDcTwd7lcctbI6C+K3gM7R+ULmEq1SI=
5+
github.com/fluxcd/pkg/apis/kustomize v1.11.0 h1:0IzDgxZkc4v+5SDNCvgZhfwfkdkQLPXCner7TNaJFWE=
6+
github.com/fluxcd/pkg/apis/kustomize v1.11.0/go.mod h1:j302mJGDww8cn9qvMsRQ0LJ1HPAPs/IlX7CSsoJV7BI=
7+
github.com/fluxcd/pkg/apis/meta v1.17.0 h1:KVMDyJQj1NYCsppsFUkbJGMnKxsqJVpnKBFolHf/q8E=
8+
github.com/fluxcd/pkg/apis/meta v1.17.0/go.mod h1:97l3hTwBpJbXBY+wetNbqrUsvES8B1jGioKcBUxmqd8=
99
github.com/fxamacker/cbor/v2 v2.8.0 h1:fFtUGXUzXPHTIUdne5+zzMPTfffl3RD5qYnkY40vtxU=
1010
github.com/fxamacker/cbor/v2 v2.8.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
1111
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
@@ -53,6 +53,10 @@ github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
5353
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
5454
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
5555
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
56+
go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI=
57+
go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU=
58+
go.yaml.in/yaml/v3 v3.0.3 h1:bXOww4E/J3f66rav3pX3m8w6jDE4knZjGOw8b5Y6iNE=
59+
go.yaml.in/yaml/v3 v3.0.3/go.mod h1:tBHosrYAkRZjRAOREWbDnBXUf08JOwYq++0QNwQiWzI=
5660
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
5761
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
5862
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
@@ -62,8 +66,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
6266
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6367
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6468
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
65-
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
66-
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
69+
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
70+
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
6771
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6872
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
6973
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -74,14 +78,14 @@ golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
7478
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
7579
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
7680
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
77-
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
78-
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
81+
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
82+
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
7983
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
8084
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
8185
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
8286
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
83-
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
84-
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
87+
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
88+
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
8589
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
8690
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
8791
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -93,12 +97,12 @@ gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
9397
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
9498
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
9599
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
96-
k8s.io/api v0.33.0 h1:yTgZVn1XEe6opVpP1FylmNrIFWuDqe2H0V8CT5gxfIU=
97-
k8s.io/api v0.33.0/go.mod h1:CTO61ECK/KU7haa3qq8sarQ0biLq2ju405IZAd9zsiM=
98-
k8s.io/apiextensions-apiserver v0.33.0 h1:d2qpYL7Mngbsc1taA4IjJPRJ9ilnsXIrndH+r9IimOs=
99-
k8s.io/apiextensions-apiserver v0.33.0/go.mod h1:VeJ8u9dEEN+tbETo+lFkwaaZPg6uFKLGj5vyNEwwSzc=
100-
k8s.io/apimachinery v0.33.0 h1:1a6kHrJxb2hs4t8EE5wuR/WxKDwGN1FKH3JvDtA0CIQ=
101-
k8s.io/apimachinery v0.33.0/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
100+
k8s.io/api v0.33.2 h1:YgwIS5jKfA+BZg//OQhkJNIfie/kmRsO0BmNaVSimvY=
101+
k8s.io/api v0.33.2/go.mod h1:fhrbphQJSM2cXzCWgqU29xLDuks4mu7ti9vveEnpSXs=
102+
k8s.io/apiextensions-apiserver v0.33.2 h1:6gnkIbngnaUflR3XwE1mCefN3YS8yTD631JXQhsU6M8=
103+
k8s.io/apiextensions-apiserver v0.33.2/go.mod h1:IvVanieYsEHJImTKXGP6XCOjTwv2LUMos0YWc9O+QP8=
104+
k8s.io/apimachinery v0.33.2 h1:IHFVhqg59mb8PJWTLi8m1mAoepkUNYmptHsV+Z1m5jY=
105+
k8s.io/apimachinery v0.33.2/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM=
102106
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
103107
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
104108
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e h1:KqK5c/ghOm8xkHYhlodbp6i6+r+ChV2vuAuVRdFbLro=
@@ -112,5 +116,6 @@ sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=
112116
sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY=
113117
sigs.k8s.io/structured-merge-diff/v4 v4.7.0 h1:qPeWmscJcXP0snki5IYF79Z8xrl8ETFxgMd7wez1XkI=
114118
sigs.k8s.io/structured-merge-diff/v4 v4.7.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps=
115-
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
116119
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
120+
sigs.k8s.io/yaml v1.5.0 h1:M10b2U7aEUY6hRtU870n2VTPgR5RZiL/I6Lcc2F4NUQ=
121+
sigs.k8s.io/yaml v1.5.0/go.mod h1:wZs27Rbxoai4C0f8/9urLZtZtF3avA3gKvGyPdDqTO4=

api/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,54 @@ spec:
256256
a controller level fallback for when KustomizationSpec.ServiceAccountName
257257
is empty.
258258
properties:
259+
configMapRef:
260+
description: |-
261+
ConfigMapRef holds an optional name of a ConfigMap that contains
262+
the following keys:
263+
264+
- `provider`: the provider to use. One of `aws`, `azure`, `gcp`, or
265+
`generic`. Required.
266+
- `cluster`: the fully qualified resource name of the Kubernetes
267+
cluster in the cloud provider API. Not used by the `generic`
268+
provider. Required when one of `address` or `ca.crt` is not set.
269+
- `address`: the address of the Kubernetes API server. Required
270+
for `generic`. For the other providers, if not specified, the
271+
first address in the cluster resource will be used, and if
272+
specified, it must match one of the addresses in the cluster
273+
resource.
274+
If audiences is not set, will be used as the audience for the
275+
`generic` provider.
276+
- `ca.crt`: the optional PEM-encoded CA certificate for the
277+
Kubernetes API server. If not set, the controller will use the
278+
CA certificate from the cluster resource.
279+
- `audiences`: the optional audiences as a list of
280+
line-break-separated strings for the Kubernetes ServiceAccount
281+
token. Defaults to the `address` for the `generic` provider, or
282+
to specific values for the other providers depending on the
283+
provider.
284+
- `serviceAccountName`: the optional name of the Kubernetes
285+
ServiceAccount in the same namespace that should be used
286+
for authentication. If not specified, the controller
287+
ServiceAccount will be used.
288+
289+
Mutually exclusive with SecretRef.
290+
properties:
291+
name:
292+
description: Name of the referent.
293+
type: string
294+
required:
295+
- name
296+
type: object
259297
secretRef:
260298
description: |-
261-
SecretRef holds the name of a secret that contains a key with
299+
SecretRef holds an optional name of a secret that contains a key with
262300
the kubeconfig file as the value. If no key is set, the key will default
263-
to 'value'.
301+
to 'value'. Mutually exclusive with ConfigMapRef.
264302
It is recommended that the kubeconfig is self-contained, and the secret
265303
is regularly updated if credentials such as a cloud-access-token expire.
266304
Cloud specific `cmd-path` auth helpers will not function without adding
267305
binaries and credentials to the Pod that is responsible for reconciling
268-
Kubernetes resources.
306+
Kubernetes resources. Supported only for the generic provider.
269307
properties:
270308
key:
271309
description: Key in the Secret, when not specified an implementation-specific
@@ -277,9 +315,14 @@ spec:
277315
required:
278316
- name
279317
type: object
280-
required:
281-
- secretRef
282318
type: object
319+
x-kubernetes-validations:
320+
- message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef
321+
must be specified
322+
rule: has(self.configMapRef) || has(self.secretRef)
323+
- message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef
324+
must be specified
325+
rule: '!has(self.configMapRef) || !has(self.secretRef)'
283326
namePrefix:
284327
description: NamePrefix will prefix the names of all managed resources.
285328
maxLength: 200
@@ -1347,16 +1390,54 @@ spec:
13471390
a controller level fallback for when KustomizationSpec.ServiceAccountName
13481391
is empty.
13491392
properties:
1393+
configMapRef:
1394+
description: |-
1395+
ConfigMapRef holds an optional name of a ConfigMap that contains
1396+
the following keys:
1397+
1398+
- `provider`: the provider to use. One of `aws`, `azure`, `gcp`, or
1399+
`generic`. Required.
1400+
- `cluster`: the fully qualified resource name of the Kubernetes
1401+
cluster in the cloud provider API. Not used by the `generic`
1402+
provider. Required when one of `address` or `ca.crt` is not set.
1403+
- `address`: the address of the Kubernetes API server. Required
1404+
for `generic`. For the other providers, if not specified, the
1405+
first address in the cluster resource will be used, and if
1406+
specified, it must match one of the addresses in the cluster
1407+
resource.
1408+
If audiences is not set, will be used as the audience for the
1409+
`generic` provider.
1410+
- `ca.crt`: the optional PEM-encoded CA certificate for the
1411+
Kubernetes API server. If not set, the controller will use the
1412+
CA certificate from the cluster resource.
1413+
- `audiences`: the optional audiences as a list of
1414+
line-break-separated strings for the Kubernetes ServiceAccount
1415+
token. Defaults to the `address` for the `generic` provider, or
1416+
to specific values for the other providers depending on the
1417+
provider.
1418+
- `serviceAccountName`: the optional name of the Kubernetes
1419+
ServiceAccount in the same namespace that should be used
1420+
for authentication. If not specified, the controller
1421+
ServiceAccount will be used.
1422+
1423+
Mutually exclusive with SecretRef.
1424+
properties:
1425+
name:
1426+
description: Name of the referent.
1427+
type: string
1428+
required:
1429+
- name
1430+
type: object
13501431
secretRef:
13511432
description: |-
1352-
SecretRef holds the name of a secret that contains a key with
1433+
SecretRef holds an optional name of a secret that contains a key with
13531434
the kubeconfig file as the value. If no key is set, the key will default
1354-
to 'value'.
1435+
to 'value'. Mutually exclusive with ConfigMapRef.
13551436
It is recommended that the kubeconfig is self-contained, and the secret
13561437
is regularly updated if credentials such as a cloud-access-token expire.
13571438
Cloud specific `cmd-path` auth helpers will not function without adding
13581439
binaries and credentials to the Pod that is responsible for reconciling
1359-
Kubernetes resources.
1440+
Kubernetes resources. Supported only for the generic provider.
13601441
properties:
13611442
key:
13621443
description: Key in the Secret, when not specified an implementation-specific
@@ -1368,9 +1449,14 @@ spec:
13681449
required:
13691450
- name
13701451
type: object
1371-
required:
1372-
- secretRef
13731452
type: object
1453+
x-kubernetes-validations:
1454+
- message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef
1455+
must be specified
1456+
rule: has(self.configMapRef) || has(self.secretRef)
1457+
- message: exactly one of spec.kubeConfig.configMapRef or spec.kubeConfig.secretRef
1458+
must be specified
1459+
rule: '!has(self.configMapRef) || !has(self.secretRef)'
13741460
patches:
13751461
description: |-
13761462
Strategic merge and JSON patches, defined as inline YAML objects,

0 commit comments

Comments
 (0)