Skip to content

Commit 02ff549

Browse files
authored
Merge pull request #860 from souleb/docs-using-auto-login
[OCI] Document Auto-Login usage in SC
2 parents f25287f + 0a390a0 commit 02ff549

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

docs/spec/v1beta2/ocirepositories.md

+91
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,107 @@ static credentials are used for authentication, either with
118118
`spec.secretRef` or `spec.serviceAccountName`.
119119
If you do not specify `.spec.provider`, it defaults to `generic`.
120120

121+
#### AWS
122+
121123
The `aws` provider can be used when the source-controller service account
122124
is associated with an AWS IAM Role using IRSA that grants read-only access to ECR.
123125

126+
To enable access to ECR, add the following patch to your bootstrap repository,
127+
in the `flux-system/kustomization.yaml` file:
128+
129+
```yaml
130+
apiVersion: kustomize.config.k8s.io/v1beta1
131+
kind: Kustomization
132+
resources:
133+
- gotk-components.yaml
134+
- gotk-sync.yaml
135+
patches:
136+
- patch: |
137+
apiVersion: v1
138+
kind: ServiceAccount
139+
metadata:
140+
name: source-controller
141+
annotations:
142+
eks.amazonaws.com/role-arn: <role arn>
143+
target:
144+
kind: ServiceAccount
145+
name: source-controller
146+
```
147+
148+
Note that you can attach the AWS managed policy `arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly`
149+
to the IAM role when using IRSA.
150+
151+
#### Azure
152+
124153
The `azure` provider can be used when the source-controller pods are associated
125154
with an Azure AAD Pod Identity that grants read-only access to ACR.
126155

156+
To enable access to ACR, add the following patch to your bootstrap repository,
157+
in the `flux-system/kustomization.yaml` file:
158+
159+
```yaml
160+
apiVersion: kustomize.config.k8s.io/v1beta1
161+
kind: Kustomization
162+
resources:
163+
- gotk-components.yaml
164+
- gotk-sync.yaml
165+
patches:
166+
- patch: |
167+
- op: add
168+
path: /spec/template/metadata/labels/aadpodidbinding
169+
value: <identity-name>
170+
target:
171+
kind: Deployment
172+
name: source-controller
173+
```
174+
175+
When using managed identity on an AKS cluster, AAD Pod Identity
176+
has to be used to give the `source-controller` pod access to the ACR.
177+
To do this, you have to install `aad-pod-identity` on your cluster, create a managed identity
178+
that has access to the container registry (this can also be the Kubelet identity
179+
if it has `AcrPull` role assignment on the ACR), create an `AzureIdentity` and `AzureIdentityBinding`
180+
that describe the managed identity and then label the `source-controller` pods
181+
with the name of the AzureIdentity as shown in the patch above. Please take a look
182+
at [this guide](https://azure.github.io/aad-pod-identity/docs/) or
183+
[this one](https://docs.microsoft.com/en-us/azure/aks/use-azure-ad-pod-identity)
184+
if you want to use AKS pod-managed identities add-on that is in preview.
185+
186+
#### GCP
187+
127188
The `gcp` provider can be used when the source-controller service account
128189
is associated with a GCP IAM Role using Workload Identity that grants
129190
read-only access to Artifact Registry.
130191

192+
To enable access to Google Artifact Registry or GCR,
193+
add the following patch to your bootstrap repository,
194+
in the `flux-system/kustomization.yaml` file:
195+
196+
```yaml
197+
apiVersion: kustomize.config.k8s.io/v1beta1
198+
kind: Kustomization
199+
resources:
200+
- gotk-components.yaml
201+
- gotk-sync.yaml
202+
patches:
203+
- patch: |
204+
apiVersion: v1
205+
kind: ServiceAccount
206+
metadata:
207+
name: source-controller
208+
annotations:
209+
iam.gke.io/gcp-service-account: <identity-name>
210+
target:
211+
kind: ServiceAccount
212+
name: source-controller
213+
```
214+
215+
The Artifact Registry service uses the permission `artifactregistry.repositories.downloadArtifacts`
216+
that is located under the Artifact Registry Reader role. If you are using
217+
Google Container Registry service, the needed permission is instead `storage.objects.list`
218+
which can be bound as part of the Container Registry Service Agent role.
219+
Take a look at [this guide](https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity)
220+
for more information about setting up GKE Workload Identity.
221+
131222
### Secret reference
132223

133224
`.spec.secretRef.name` is an optional field to specify a name reference to a

0 commit comments

Comments
 (0)