Skip to content

Commit

Permalink
Enable Azure OIDC for Azure DevOps Repository in IAC
Browse files Browse the repository at this point in the history
- Controller changes to set the provider options in git authOptions to fetch provider credentials while building git config if `.spec.provider` field is set to `azure`.

- API docs for setting up Azure workload identity in IAC

- Unit tests for testing provider settings in git  config

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
  • Loading branch information
dipti-pai authored and darkowlzz committed Sep 25, 2024
1 parent 7203b19 commit b24fb41
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 47 deletions.
65 changes: 65 additions & 0 deletions docs/spec/v1beta2/imageupdateautomations.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,71 @@ tuned to adjust the Git operation timeout.
The proxy configurations are also derived from the referenced GitRepository
source. `GitRepository.spec.proxySecretRef` can be used to configure proxy use.

#### GitRepository Provider

`GitRepository` can be configured to specify an OIDC
[provider](https://fluxcd.io/flux/components/source/gitrepositories/#provider)
for authentication using `GitRepository.spec.provider` field. Image automation
controller can be configured to authenticate using the provider as described
below.

##### Azure

If the provider is set to `azure`, make sure the
[pre-requisites](https://fluxcd.io/flux/components/source/gitrepositories/#azure)
are satisfied. To configure image automation controller to use workload
identity,

- Create a managed identity to access Azure DevOps. Establish a federated
identity credential between the managed identity and the
image-automation-controller service account. In the default installation, the
image-automation-controller service account is located in the `flux-system`
namespace with name `image-automation-controller`. Ensure the federated
credential uses the correct namespace and name of the
image-automation-controller service account. For more details, please refer to
this
[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).

- Add the managed identity to the Azure DevOps organization as a user. Ensure
that the managed identity has the necessary permissions to access the Azure
DevOps repository as described
[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).

- Add the following patch to your bootstrap repository in
flux-system/kustomization.yaml file.

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gotk-components.yaml
- gotk-sync.yaml
patches:
- patch: |-
apiVersion: v1
kind: ServiceAccount
metadata:
name: image-automation-controller
namespace: flux-system
annotations:
azure.workload.identity/client-id: <AZURE_CLIENT_ID>
labels:
azure.workload.identity/use: "true"
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: image-automation-controller
namespace: flux-system
labels:
azure.workload.identity/use: "true"
spec:
template:
metadata:
labels:
azure.workload.identity/use: "true"
```

### Git specification

`.spec.git` is a required field to specify Git configurations related to source
Expand Down
39 changes: 24 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/fluxcd/image-automation-controller

go 1.22.0
go 1.22.5

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

Expand All @@ -14,17 +14,18 @@ require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6
github.com/Masterminds/sprig/v3 v3.3.0
github.com/ProtonMail/go-crypto v1.1.0-alpha.5-proton
github.com/cyphar/filepath-securejoin v0.3.1
github.com/cyphar/filepath-securejoin v0.3.2
github.com/fluxcd/image-automation-controller/api v0.38.0
github.com/fluxcd/image-reflector-controller/api v0.32.0
github.com/fluxcd/pkg/apis/acl v0.3.0
github.com/fluxcd/pkg/apis/event v0.10.0
github.com/fluxcd/pkg/apis/meta v1.6.0
github.com/fluxcd/pkg/git v0.20.0
github.com/fluxcd/pkg/git/gogit v0.20.0
github.com/fluxcd/pkg/gittestserver v0.13.0
github.com/fluxcd/pkg/auth v0.0.1
github.com/fluxcd/pkg/git v0.21.0
github.com/fluxcd/pkg/git/gogit v0.21.0
github.com/fluxcd/pkg/gittestserver v0.13.1
github.com/fluxcd/pkg/runtime v0.49.0
github.com/fluxcd/pkg/ssh v0.14.0
github.com/fluxcd/pkg/ssh v0.14.1
github.com/fluxcd/source-controller/api v1.3.0
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.12.0
Expand All @@ -44,7 +45,11 @@ require (

require (
dario.cat/mergo v1.0.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
Expand All @@ -53,15 +58,15 @@ require (
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.9 // indirect
github.com/cloudflare/circl v1.4.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
github.com/fluxcd/cli-utils v0.36.0-flux.9 // indirect
github.com/fluxcd/gitkit v0.6.0 // indirect
github.com/fluxcd/pkg/version v0.4.0 // indirect
github.com/fluxcd/pkg/version v0.4.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-errors/errors v1.5.1 // indirect
Expand All @@ -72,6 +77,7 @@ require (
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.1.2 // indirect
Expand Down Expand Up @@ -108,6 +114,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.20.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
Expand All @@ -125,17 +132,17 @@ require (
go.starlark.net v0.0.0-20231121155337-90ade8b19d09 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.24.0 // indirect
golang.org/x/tools v0.25.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
Expand All @@ -153,3 +160,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/fluxcd/source-controller/api => github.com/dipti-pai/source-controller/api v0.0.0-20240913204118-48417bdc8bd7
Loading

0 comments on commit b24fb41

Please sign in to comment.