Skip to content

Commit 5755a87

Browse files
authored
Merge pull request #747 from dipti-pai/iac-azure-oidc
[RFC-0007] Enable Azure OIDC for Azure DevOps Repository
2 parents 7203b19 + 87bff0e commit 5755a87

File tree

7 files changed

+246
-98
lines changed

7 files changed

+246
-98
lines changed

api/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module github.com/fluxcd/image-automation-controller/api
33
go 1.22.0
44

55
require (
6-
github.com/fluxcd/pkg/apis/meta v1.6.0
7-
github.com/fluxcd/source-controller/api v1.3.0
8-
k8s.io/apimachinery v0.31.0
6+
github.com/fluxcd/pkg/apis/meta v1.6.1
7+
github.com/fluxcd/source-controller/api v1.4.0
8+
k8s.io/apimachinery v0.31.1
99
sigs.k8s.io/controller-runtime v0.19.0
1010
)
1111

@@ -19,8 +19,8 @@ require (
1919
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2020
github.com/modern-go/reflect2 v1.0.2 // indirect
2121
github.com/x448/float16 v0.8.4 // indirect
22-
golang.org/x/net v0.28.0 // indirect
23-
golang.org/x/text v0.17.0 // indirect
22+
golang.org/x/net v0.29.0 // indirect
23+
golang.org/x/text v0.18.0 // indirect
2424
gopkg.in/inf.v0 v0.9.1 // indirect
2525
gopkg.in/yaml.v2 v2.4.0 // indirect
2626
k8s.io/klog/v2 v2.130.1 // indirect

api/go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
44
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/fluxcd/pkg/apis/acl v0.3.0 h1:UOrKkBTOJK+OlZX7n8rWt2rdBmDCoTK+f5TY2LcZi8A=
66
github.com/fluxcd/pkg/apis/acl v0.3.0/go.mod h1:WVF9XjSMVBZuU+HTTiSebGAWMgM7IYexFLyVWbK9bNY=
7-
github.com/fluxcd/pkg/apis/meta v1.6.0 h1:93TcRpiph0OCoQh+cI+PM7E35kBW9dScuas9tWc90Dw=
8-
github.com/fluxcd/pkg/apis/meta v1.6.0/go.mod h1:ZOeHcvyVdZDC5ZOGV7YuwplIvAx6LvmpeyhfTcNZCnc=
9-
github.com/fluxcd/source-controller/api v1.3.0 h1:Z5Lq0aJY87yg0cQDEuwGLKS60GhdErCHtsi546HUt10=
10-
github.com/fluxcd/source-controller/api v1.3.0/go.mod h1:+tfd0vltjcVs/bbnq9AlYR9AAHSVfM/Z4v4TpQmdJf4=
7+
github.com/fluxcd/pkg/apis/meta v1.6.1 h1:maLhcRJ3P/70ArLCY/LF/YovkxXbX+6sTWZwZQBeNq0=
8+
github.com/fluxcd/pkg/apis/meta v1.6.1/go.mod h1:YndB/gxgGZmKfqpAfFxyCDNFJFP0ikpeJzs66jwq280=
9+
github.com/fluxcd/source-controller/api v1.4.0 h1:PCCrD9aSIqaqfl3O/ug5ZLl5NSAFKTrNFFNFjNUt4yQ=
10+
github.com/fluxcd/source-controller/api v1.4.0/go.mod h1:gSjg57T+IG66SsBR0aquv+DFrm4YyBNpKIJVDnu3Ya8=
1111
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
1212
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
1313
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
@@ -65,20 +65,20 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
6565
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6666
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
6767
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
68-
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
69-
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
68+
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
69+
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
7070
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7171
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7272
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
7373
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
7474
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7575
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
76-
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
77-
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
76+
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
77+
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
7878
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
7979
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
80-
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
81-
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
80+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
81+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
8282
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
8383
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
8484
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
@@ -101,8 +101,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
101101
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
102102
k8s.io/api v0.31.0 h1:b9LiSjR2ym/SzTOlfMHm1tr7/21aD7fSkqgD/CVJBCo=
103103
k8s.io/api v0.31.0/go.mod h1:0YiFF+JfFxMM6+1hQei8FY8M7s1Mth+z/q7eF1aJkTE=
104-
k8s.io/apimachinery v0.31.0 h1:m9jOiSr3FoSSL5WO9bjm1n6B9KROYYgNZOb4tyZ1lBc=
105-
k8s.io/apimachinery v0.31.0/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo=
104+
k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U=
105+
k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo=
106106
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
107107
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
108108
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A=

docs/spec/v1beta2/imageupdateautomations.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,71 @@ tuned to adjust the Git operation timeout.
192192
The proxy configurations are also derived from the referenced GitRepository
193193
source. `GitRepository.spec.proxySecretRef` can be used to configure proxy use.
194194

195+
#### GitRepository Provider
196+
197+
`GitRepository` can be configured to specify an OIDC
198+
[provider](https://fluxcd.io/flux/components/source/gitrepositories/#provider)
199+
for authentication using `GitRepository.spec.provider` field. Image automation
200+
controller can be configured to authenticate using the provider as described
201+
below.
202+
203+
##### Azure
204+
205+
If the provider is set to `azure`, make sure the
206+
[pre-requisites](https://fluxcd.io/flux/components/source/gitrepositories/#azure)
207+
are satisfied. To configure image automation controller to use workload
208+
identity,
209+
210+
- Create a managed identity to access Azure DevOps. Establish a federated
211+
identity credential between the managed identity and the
212+
image-automation-controller service account. In the default installation, the
213+
image-automation-controller service account is located in the `flux-system`
214+
namespace with name `image-automation-controller`. Ensure the federated
215+
credential uses the correct namespace and name of the
216+
image-automation-controller service account. For more details, please refer to
217+
this
218+
[guide](https://azure.github.io/azure-workload-identity/docs/quick-start.html#6-establish-federated-identity-credential-between-the-identity-and-the-service-account-issuer--subject).
219+
220+
- Add the managed identity to the Azure DevOps organization as a user. Ensure
221+
that the managed identity has the necessary permissions to access the Azure
222+
DevOps repository as described
223+
[here](https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/service-principal-managed-identity?view=azure-devops#2-add-and-manage-service-principals-in-an-azure-devops-organization).
224+
225+
- Add the following patch to your bootstrap repository in
226+
flux-system/kustomization.yaml file.
227+
228+
```yaml
229+
apiVersion: kustomize.config.k8s.io/v1beta1
230+
kind: Kustomization
231+
resources:
232+
- gotk-components.yaml
233+
- gotk-sync.yaml
234+
patches:
235+
- patch: |-
236+
apiVersion: v1
237+
kind: ServiceAccount
238+
metadata:
239+
name: image-automation-controller
240+
namespace: flux-system
241+
annotations:
242+
azure.workload.identity/client-id: <AZURE_CLIENT_ID>
243+
labels:
244+
azure.workload.identity/use: "true"
245+
- patch: |-
246+
apiVersion: apps/v1
247+
kind: Deployment
248+
metadata:
249+
name: image-automation-controller
250+
namespace: flux-system
251+
labels:
252+
azure.workload.identity/use: "true"
253+
spec:
254+
template:
255+
metadata:
256+
labels:
257+
azure.workload.identity/use: "true"
258+
```
259+
195260
### Git specification
196261

197262
`.spec.git` is a required field to specify Git configurations related to source

go.mod

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/fluxcd/image-automation-controller
22

3-
go 1.22.0
3+
go 1.22.5
44

55
replace github.com/fluxcd/image-automation-controller/api => ./api
66

@@ -14,28 +14,29 @@ require (
1414
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6
1515
github.com/Masterminds/sprig/v3 v3.3.0
1616
github.com/ProtonMail/go-crypto v1.1.0-alpha.5-proton
17-
github.com/cyphar/filepath-securejoin v0.3.1
17+
github.com/cyphar/filepath-securejoin v0.3.2
1818
github.com/fluxcd/image-automation-controller/api v0.38.0
1919
github.com/fluxcd/image-reflector-controller/api v0.32.0
2020
github.com/fluxcd/pkg/apis/acl v0.3.0
21-
github.com/fluxcd/pkg/apis/event v0.10.0
22-
github.com/fluxcd/pkg/apis/meta v1.6.0
23-
github.com/fluxcd/pkg/git v0.20.0
24-
github.com/fluxcd/pkg/git/gogit v0.20.0
25-
github.com/fluxcd/pkg/gittestserver v0.13.0
26-
github.com/fluxcd/pkg/runtime v0.49.0
27-
github.com/fluxcd/pkg/ssh v0.14.0
28-
github.com/fluxcd/source-controller/api v1.3.0
21+
github.com/fluxcd/pkg/apis/event v0.10.1
22+
github.com/fluxcd/pkg/apis/meta v1.6.1
23+
github.com/fluxcd/pkg/auth v0.0.1
24+
github.com/fluxcd/pkg/git v0.21.0
25+
github.com/fluxcd/pkg/git/gogit v0.21.0
26+
github.com/fluxcd/pkg/gittestserver v0.13.1
27+
github.com/fluxcd/pkg/runtime v0.49.1
28+
github.com/fluxcd/pkg/ssh v0.14.1
29+
github.com/fluxcd/source-controller/api v1.4.0
2930
github.com/go-git/go-billy/v5 v5.5.0
3031
github.com/go-git/go-git/v5 v5.12.0
3132
github.com/go-logr/logr v1.4.2
3233
github.com/google/go-containerregistry v0.20.2
3334
github.com/onsi/gomega v1.34.2
3435
github.com/otiai10/copy v1.14.0
3536
github.com/spf13/pflag v1.0.5
36-
k8s.io/api v0.31.0
37-
k8s.io/apimachinery v0.31.0
38-
k8s.io/client-go v0.31.0
37+
k8s.io/api v0.31.1
38+
k8s.io/apimachinery v0.31.1
39+
k8s.io/client-go v0.31.1
3940
k8s.io/kube-openapi v0.0.0-20240411171206-dc4e619f62f3
4041
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
4142
sigs.k8s.io/controller-runtime v0.19.0
@@ -44,7 +45,11 @@ require (
4445

4546
require (
4647
dario.cat/mergo v1.0.1 // indirect
48+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 // indirect
49+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect
50+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
4751
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
52+
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
4853
github.com/MakeNowJust/heredoc v1.0.0 // indirect
4954
github.com/Masterminds/goutils v1.1.1 // indirect
5055
github.com/Masterminds/semver/v3 v3.3.0 // indirect
@@ -53,15 +58,15 @@ require (
5358
github.com/blang/semver/v4 v4.0.0 // indirect
5459
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5560
github.com/chai2010/gettext-go v1.0.2 // indirect
56-
github.com/cloudflare/circl v1.3.9 // indirect
61+
github.com/cloudflare/circl v1.4.0 // indirect
5762
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
5863
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
5964
github.com/emirpasic/gods v1.18.1 // indirect
6065
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
6166
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
6267
github.com/fluxcd/cli-utils v0.36.0-flux.9 // indirect
6368
github.com/fluxcd/gitkit v0.6.0 // indirect
64-
github.com/fluxcd/pkg/version v0.4.0 // indirect
69+
github.com/fluxcd/pkg/version v0.4.1 // indirect
6570
github.com/fsnotify/fsnotify v1.7.0 // indirect
6671
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
6772
github.com/go-errors/errors v1.5.1 // indirect
@@ -72,6 +77,7 @@ require (
7277
github.com/go-openapi/swag v0.23.0 // indirect
7378
github.com/gofrs/uuid v4.4.0+incompatible // indirect
7479
github.com/gogo/protobuf v1.3.2 // indirect
80+
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
7581
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
7682
github.com/golang/protobuf v1.5.4 // indirect
7783
github.com/google/btree v1.1.2 // indirect
@@ -108,8 +114,9 @@ require (
108114
github.com/opencontainers/go-digest v1.0.0 // indirect
109115
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
110116
github.com/pjbgf/sha1cd v0.3.0 // indirect
117+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
111118
github.com/pkg/errors v0.9.1 // indirect
112-
github.com/prometheus/client_golang v1.20.0 // indirect
119+
github.com/prometheus/client_golang v1.20.3 // indirect
113120
github.com/prometheus/client_model v0.6.1 // indirect
114121
github.com/prometheus/common v0.55.0 // indirect
115122
github.com/prometheus/procfs v0.15.1 // indirect
@@ -125,29 +132,29 @@ require (
125132
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect
126133
go.uber.org/multierr v1.11.0 // indirect
127134
go.uber.org/zap v1.27.0 // indirect
128-
golang.org/x/crypto v0.26.0 // indirect
135+
golang.org/x/crypto v0.27.0 // indirect
129136
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
130-
golang.org/x/mod v0.20.0 // indirect
131-
golang.org/x/net v0.28.0 // indirect
137+
golang.org/x/mod v0.21.0 // indirect
138+
golang.org/x/net v0.29.0 // indirect
132139
golang.org/x/oauth2 v0.22.0 // indirect
133140
golang.org/x/sync v0.8.0 // indirect
134-
golang.org/x/sys v0.24.0 // indirect
135-
golang.org/x/term v0.23.0 // indirect
136-
golang.org/x/text v0.17.0 // indirect
141+
golang.org/x/sys v0.25.0 // indirect
142+
golang.org/x/term v0.24.0 // indirect
143+
golang.org/x/text v0.18.0 // indirect
137144
golang.org/x/time v0.6.0 // indirect
138-
golang.org/x/tools v0.24.0 // indirect
145+
golang.org/x/tools v0.25.0 // indirect
139146
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
140147
google.golang.org/protobuf v1.34.2 // indirect
141148
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
142149
gopkg.in/inf.v0 v0.9.1 // indirect
143150
gopkg.in/warnings.v0 v0.1.2 // indirect
144151
gopkg.in/yaml.v2 v2.4.0 // indirect
145152
gopkg.in/yaml.v3 v3.0.1 // indirect
146-
k8s.io/apiextensions-apiserver v0.31.0 // indirect
147-
k8s.io/cli-runtime v0.31.0 // indirect
148-
k8s.io/component-base v0.31.0 // indirect
153+
k8s.io/apiextensions-apiserver v0.31.1 // indirect
154+
k8s.io/cli-runtime v0.31.1 // indirect
155+
k8s.io/component-base v0.31.1 // indirect
149156
k8s.io/klog/v2 v2.130.1 // indirect
150-
k8s.io/kubectl v0.31.0 // indirect
157+
k8s.io/kubectl v0.31.1 // indirect
151158
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
152159
sigs.k8s.io/kustomize/api v0.17.3 // indirect
153160
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect

0 commit comments

Comments
 (0)