Skip to content

Commit 2cab8f9

Browse files
committed
Fix complicated and insecure adot installation docs
1 parent a6f7473 commit 2cab8f9

File tree

3 files changed

+441
-130
lines changed

3 files changed

+441
-130
lines changed

docs/content/en/docs/getting-started/optional/irsa.md

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ IAM Roles for Service Account (IRSA) enables applications running in clusters to
1414

1515
The steps below are based on the [guide for configuring IRSA for DIY Kubernetes,](https://github.com/aws/amazon-eks-pod-identity-webhook/blob/master/SELF_HOSTED_SETUP.md) with modifications specific to EKS Anywhere's cluster provisioning workflow. The main modification is the process of generating the keys.json document. As per the original guide, the user has to create the service account signing keys, and then use that to create the keys.json document prior to cluster creation. This order is reversed for EKS Anywhere clusters, so you will create the cluster first, and then retrieve the service account signing key generated by the cluster, and use it to create the keys.json document. The sections below show how to do this in detail.
1616

17-
### Create an OIDC provider and make its discovery document publicly accessible
17+
### Set up cluster-wide IRSA infrastructure
18+
19+
This section covers the one-time setup required for IRSA on your EKS Anywhere cluster. Complete these steps once per cluster.
20+
21+
#### Create an OIDC provider and make its discovery document publicly accessible
1822

1923
You must use a single OIDC provider per EKS Anywhere cluster, which is the best practice to prevent a token from one cluster being used with another cluster. These steps describe the process of using a S3 bucket to host the OIDC `discovery.json` and `keys.json` documents.
2024

@@ -54,11 +58,15 @@ You must use a single OIDC provider per EKS Anywhere cluster, which is the best
5458
5559
1. Make a note of the `Provider` field of OIDC provider after it is created.
5660
57-
1. Assign an IAM role to the OIDC provider.
61+
### Create IAM role for your workload
62+
63+
Each workload (such as ADOT, cert-manager, or custom applications) should have its own dedicated IAM role with only the permissions it needs. Repeat this section for each workload that requires AWS access.
64+
65+
1. Create an IAM role for your workload:
5866
5967
1. Navigate to the AWS IAM Console.
6068
61-
1. Click on the OIDC provider.
69+
1. Click on the OIDC provider created in the previous section.
6270
6371
1. Click _Assign role_.
6472
@@ -73,10 +81,10 @@ You must use a single OIDC provider per EKS Anywhere cluster, which is the best
7381
7482
1. Click _Next_.
7583
76-
1. Configure your desired _Permissions poilicies_.
84+
1. Configure _Permissions policies_ specific to this workload's requirements.
7785
78-
1. Below is a sample trust policy of IAM role for your pods. Replace `ACCOUNT_ID`, `ISSUER_HOSTPATH`, `NAMESPACE` and `SERVICE_ACCOUNT`.
79-
_Example: Scoped to a service account_
86+
1. Below is a sample trust policy for a single workload. Replace `ACCOUNT_ID`, `ISSUER_HOSTPATH`, `NAMESPACE` and `SERVICE_ACCOUNT` with values specific to this workload.
87+
_Example: Scoped to a single service account_
8088
```json
8189
{
8290
"Version": "2012-10-17",
@@ -90,7 +98,7 @@ You must use a single OIDC provider per EKS Anywhere cluster, which is the best
9098
"Condition": {
9199
"StringEquals": {
92100
"ISSUER_HOSTPATH:sub": "system:serviceaccount:NAMESPACE:SERVICE_ACCOUNT"
93-
},
101+
}
94102
}
95103
}
96104
]
@@ -99,7 +107,7 @@ You must use a single OIDC provider per EKS Anywhere cluster, which is the best
99107
100108
1. Create the IAM Role and make a note of the _Role name_.
101109
102-
1. After the cluster is created you can grant service accounts access to the role by modifying the trust relationship. See the [How to use trust policies with IAM Roles](https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/) for more information on trust policies. Refer to [Configure the trust relationship for the OIDC provider's IAM Role](#configure-the-trust-relationship-for-the-oidc-providers-iam-role) for a working example.
110+
1. See the [How to use trust policies with IAM Roles](https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/) for more information on trust policies. For advanced trust relationship configurations, refer to [Configure the trust relationship for the IAM role](#configure-the-trust-relationship-for-the-iam-role).
103111
104112
### Create (or upgrade) the EKS Anywhere cluster
105113
@@ -197,24 +205,39 @@ The [Amazon Pod Identity Webhook](https://github.com/aws/amazon-eks-pod-identity
197205
1. You can validate IRSA by following [IRSA setup and test]({{< relref "../../packages/adot/adot_amp_amg/#irsa-set-up-test" >}}). Ensure the awscli pod is deployed in the same namespace of ServiceAccount `pod-identity-webhook`.
198206
199207
200-
### Configure the trust relationship for the OIDC provider's IAM Role
208+
### Configure the trust relationship for the IAM role
201209
202-
In order to grant certain service accounts access to the desired AWS resources, edit the trust relationship for the OIDC provider's IAM Role (`OIDC_IAM_ROLE`) created in the first section, and add in the desired service accounts.
210+
This section provides advanced examples for configuring trust relationships. The basic single-ServiceAccount pattern shown above is recommended for most use cases.
203211
204212
1. Choose the role in the console to open it for editing.
205213
206214
1. Choose the **Trust relationships** tab, and then choose **Edit trust relationship**.
207215
208-
1. Find the line that looks similar to the following:
209-
```
210-
"$ISSUER_HOSTPATH:aud": "sts.amazonaws.com"
211-
```
216+
1. Find the existing trust policy condition.
212217
213-
1. Add another condition after that line which looks like the following line. Replace `KUBERNETES_SERVICE_ACCOUNT_NAMESPACE` and `KUBERNETES_SERVICE_ACCOUNT_NAME` with the name of your Kubernetes service account and the Kubernetes namespace that the account exists in.
214-
```
215-
"$ISSUER_HOSTPATH:sub": "system:serviceaccount:KUBERNETES_SERVICE_ACCOUNT_NAMESPACE:KUBERNETES_SERVICE_ACCOUNT_NAME"
218+
1. **Single ServiceAccount pattern (recommended):** For most workloads, use a single ServiceAccount:
219+
```json
220+
{
221+
"Version": "2012-10-17",
222+
"Statement": [
223+
{
224+
"Effect": "Allow",
225+
"Principal": {
226+
"Federated": "arn:aws:iam::$Account_ID:oidc-provider/s3.us-west-2.amazonaws.com/$S3_BUCKET"
227+
},
228+
"Action": "sts:AssumeRoleWithWebIdentity",
229+
"Condition": {
230+
"StringEquals": {
231+
"s3.us-west-2.amazonaws.com/$S3_BUCKET:aud": "sts.amazonaws.com",
232+
"s3.us-west-2.amazonaws.com/$S3_BUCKET:sub": "system:serviceaccount:default:my-serviceaccount"
233+
}
234+
}
235+
}
236+
]
237+
}
216238
```
217-
The allow list example below applies `my-serviceaccount` service account to the `default` namespace and all service accounts to the `observability` namespace for the `us-west-2` region. Remember to replace `Account_ID` and `S3_BUCKET` with the required values.
239+
240+
1. **Multiple ServiceAccounts pattern (use sparingly):** Only use arrays when the same workload runs in multiple namespaces (e.g., dev/staging/prod environments):
218241
```json
219242
{
220243
"Version": "2012-10-17",
@@ -226,19 +249,22 @@ In order to grant certain service accounts access to the desired AWS resources,
226249
},
227250
"Action": "sts:AssumeRoleWithWebIdentity",
228251
"Condition": {
229-
"StringLike": {
252+
"StringEquals": {
230253
"s3.us-west-2.amazonaws.com/$S3_BUCKET:aud": "sts.amazonaws.com",
231254
"s3.us-west-2.amazonaws.com/$S3_BUCKET:sub": [
232-
"system:serviceaccount:default:my-serviceaccount",
233-
"system:serviceaccount:amazon-cloudwatch:*"
234-
]
235-
}
255+
"system:serviceaccount:dev:my-app",
256+
"system:serviceaccount:staging:my-app",
257+
"system:serviceaccount:prod:my-app"
258+
]
236259
}
237260
}
238-
]
239-
}
261+
}
262+
]
263+
}
240264
```
241265
266+
**Important:** Do not share IAM roles across unrelated workloads. Each workload should have its own IAM role with only the permissions it needs.
267+
242268
243269
244270
1. Refer [this](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html) doc for different ways of configuring one or multiple service accounts through the condition operators in the trust relationship.

0 commit comments

Comments
 (0)