Skip to content

Commit 0441ae8

Browse files
committed
Added prereq for management iam doc.
1 parent 3f0c926 commit 0441ae8

3 files changed

Lines changed: 85 additions & 101 deletions

File tree

docs/book/src/topics/rosa/creating-a-cluster.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
3. Create a management cluster using the [Quick Start Guide.](https://cluster-api-aws.sigs.k8s.io/quick-start)
1515

16+
## IAM Role Configuration
17+
18+
**Note:** This step is only required when using a ROSA HCP or OCP cluster as the management cluster.
19+
20+
Configure the IAM role authentication for the CAPA controller following the directions [here](specify-management-iam-role.md).
21+
1622
## Authentication
1723

1824
The CAPA controller requires service account credentials to provision ROSA HCP clusters.

docs/book/src/topics/rosa/specify-management-iam-role.md

Lines changed: 0 additions & 101 deletions
This file was deleted.

specify-management-iam-role.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Specifying the IAM Role for ROSA HCP Management Components
2+
3+
When using an OpenShift or ROSA-HCP cluster as the management cluster, you can configure the CAPA controller to use IAM roles instead of storing AWS credentials. This uses OIDC federation to allow the CAPA controller service account to assume an IAM role.
4+
5+
## Prerequisites
6+
7+
- A management cluster (OpenShift or ROSA-HCP) with CAPI and CAPA installed
8+
- The management cluster must have an OIDC provider configured
9+
10+
## Retrieve the OIDC Provider
11+
12+
Extract the OIDC provider from the management cluster and set your AWS account ID:
13+
14+
```shell
15+
export OIDC_PROVIDER=$(kubectl get authentication.config.openshift.io cluster -ojson | jq -r .spec.serviceAccountIssuer | sed 's/https:\/\///')
16+
export AWS_ACCOUNT_ID=<your-aws-account-id>
17+
```
18+
19+
## Create the Trust Policy
20+
21+
Create a trust policy that allows the `capa-controller-manager` service account to assume the IAM role:
22+
23+
```shell
24+
cat <<EOF > trust.json
25+
{
26+
"Version": "2012-10-17",
27+
"Statement": [
28+
{
29+
"Effect": "Allow",
30+
"Principal": {
31+
"Federated": "arn:aws:iam::${AWS_ACCOUNT_ID}:oidc-provider/${OIDC_PROVIDER}"
32+
},
33+
"Action": "sts:AssumeRoleWithWebIdentity",
34+
"Condition": {
35+
"StringEquals": {
36+
"${OIDC_PROVIDER}:sub": "system:serviceaccount:capa-system:capa-controller-manager"
37+
}
38+
}
39+
}
40+
]
41+
}
42+
EOF
43+
```
44+
45+
46+
## Create the IAM Role
47+
48+
Create the IAM role and attach the required AWS policies:
49+
50+
```shell
51+
aws iam create-role --role-name "capa-manager-role" \
52+
--assume-role-policy-document file://trust.json \
53+
--description "IAM role for CAPA to assume"
54+
55+
aws iam attach-role-policy --role-name capa-manager-role \
56+
--policy-arn arn:aws:iam::aws:policy/AWSCloudFormationFullAccess
57+
58+
aws iam attach-role-policy --role-name capa-manager-role \
59+
--policy-arn arn:aws:iam::aws:policy/AmazonVPCFullAccess
60+
```
61+
62+
## Annotate the Service Account
63+
64+
Retrieve the IAM role ARN and annotate the CAPA controller service account:
65+
66+
```shell
67+
export APP_IAM_ROLE_ARN=$(aws iam get-role --role-name=capa-manager-role --query Role.Arn --output text)
68+
69+
kubectl annotate serviceaccount -n capa-system capa-controller-manager \
70+
eks.amazonaws.com/role-arn=$APP_IAM_ROLE_ARN
71+
```
72+
73+
Restart the CAPA controller to pick up the new role:
74+
75+
```shell
76+
kubectl rollout restart deployment capa-controller-manager -n capa-system
77+
```
78+
79+
After this configuration, the CAPA controller will use the IAM role to manage AWS resources, and you can provision ROSA HCP clusters without storing AWS credentials in the management cluster.

0 commit comments

Comments
 (0)