Skip to content

Commit fdf071c

Browse files
committed
add back role channing
1 parent 26bc581 commit fdf071c

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

docs/setup_installation/admin/roleChaining.md

+43-10
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,47 @@
22

33
## Introduction
44

5-
When running Hopsworks in the cloud you have several options to give the Hopsworks user access to AWS resources. The simplest is to setup the EC2 instances running Hopsworks with an [instance profile](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html) giving access to the resources. But, this will make these resources accessible by all the Hopsworks users. To manage access to the resource on a project base you need to use [Role chaining](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-role-chaining).
5+
When running Hopsworks in Amazon EKS you have several options to give the Hopsworks user access to AWS resources. The simplest is to assign [Amazon EKS node IAM role](https://docs.aws.amazon.com/eks/latest/userguide/create-node-role.html) access to the resources. But, this will make these resources accessible by all users. To manage access to resources on a project base you need to use [Role chaining](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-role-chaining).
66

77
In this document we will see how to configure AWS and Hopsworks to use Role chaining in your Hopsworks projects.
88

99
## Prerequisites
1010
Before you begin this guide you'll need the following:
1111

12-
- A Hopsworks cluster running on EC2.
13-
- Administrator account on a Hopsworks cluster.
12+
- A Hopsworks cluster running on EKS.
13+
- Enabled IAM OpenID Connect (OIDC) provider for your cluster.
14+
- Administrator account on the Hopsworks cluster.
1415

15-
### Step 1: Create an instance profile role
16-
To use role chaining the head node need to be able to impersonate the roles you want to be linked to your project. For this you need to create an instance profile with assume role permissions and attach it to your head node. For more details about the creation of instance profile see the [aws documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2.html).
16+
### Step 1: Create an IAM role and associate it with a Kubernetes service account
17+
To use role chaining the hopsworks instance pods need to be able to impersonate the roles you want to be linked to your project. For this you need to create an IAM role and associate it with your Kubernetes service accounts with assume role permissions and attach it to your hopsworks instance pods.
18+
For more details on how to create an IAM roles for Kubernetes service accounts see the [aws documentation](https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html).
1719

1820

1921
!!!note
20-
To ensure that the Hopsworks users can't use the head node instance profile and impersonate the roles by their own means, you need to ensure that they can't execute code on the head node. This means having all jobs running on worker nodes and using EKS to run jupyter notebooks.
22+
To ensure that users can't use the service account role and impersonate the roles by their own means, you need to ensure that the service account is only attached to the hopsworks instance pods.
23+
24+
25+
```json
26+
{
27+
"Version": "2012-10-17",
28+
"Statement": [
29+
{
30+
"Effect": "Allow",
31+
"Principal": {
32+
"Federated": "arn:aws:iam::$account_id:oidc-provider/$oidc_provider"
33+
},
34+
"Action": "sts:AssumeRoleWithWebIdentity",
35+
"Condition": {
36+
"StringEquals": {
37+
"$oidc_provider:aud": "sts.amazonaws.com",
38+
"$oidc_provider:sub": "system:serviceaccount:$namespace:$service_account"
39+
}
40+
}
41+
}
42+
]
43+
}
44+
```
45+
<figcaption>Example trust policy for a service account.</figcaption>
2146

2247
```json
2348
{
@@ -28,7 +53,7 @@ To use role chaining the head node need to be able to impersonate the roles you
2853
"Effect": "Allow",
2954
"Action": "sts:AssumeRole",
3055
"Resource": [
31-
"arn:aws:iam::123456789011:role/test-role",
56+
"arn:aws:iam::123456789011:role/my-role",
3257
"arn:aws:iam::xxxxxxxxxxxx:role/s3-role",
3358
"arn:aws:iam::xxxxxxxxxxxx:role/dev-s3-role",
3459
"arn:aws:iam::xxxxxxxxxxxx:role/redshift"
@@ -39,8 +64,16 @@ To use role chaining the head node need to be able to impersonate the roles you
3964
```
4065
<figcaption>Example policy for assuming four roles.</figcaption>
4166

67+
The IAM role will need to add a trust policy to allow the service account to assume the role, and permissions to assume the different roles that will be used to access resources.
68+
69+
To associate the IAM role with your Kubernetes service account you will need to annotate your service account with the Amazon Resource Name (ARN) of the IAM role that you want the service account to assume.
70+
71+
```sh
72+
kubectl annotate serviceaccount -n $namespace $service_account eks.amazonaws.com/role-arn=arn:aws:iam::$account_id:role/my-role
73+
```
74+
4275
### Step 2: Create the resource roles
43-
For the instance profile to be able to impersonate the roles you need to configure the roles themselves to allow it. This is done by adding the instance profile to the role's [Trust relationships](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/edit_trust.html).
76+
For the service account role to be able to impersonate the roles you also need to configure the roles themselves to allow it. This is done by adding the service account role to the role's [Trust relationships](https://docs.aws.amazon.com/directoryservice/latest/admin-guide/edit_trust.html).
4477

4578
```json
4679
{
@@ -49,7 +82,7 @@ For the instance profile to be able to impersonate the roles you need to configu
4982
{
5083
"Effect": "Allow",
5184
"Principal": {
52-
"AWS": "arn:aws:iam::xxxxxxxxxxxx:role/instance-profile"
85+
"AWS": "arn:aws:iam::xxxxxxxxxxxx:role/service-account-role"
5386
},
5487
"Action": "sts:AssumeRole"
5588
}
@@ -59,7 +92,7 @@ For the instance profile to be able to impersonate the roles you need to configu
5992
<figcaption>Example trust-policy document.</figcaption>
6093

6194
### Step 3: Create mappings
62-
Now that the head node can assume the roles we need to configure Hopsworks to delegate access to the roles on a project base.
95+
Now that the service account IAM role can assume the roles we need to configure Hopsworks to delegate access to the roles on a project base.
6396

6497
In Hopsworks, click on your name in the top right corner of the navigation bar and choose _Cluster Settings_ from the dropdown menu.
6598
In the Cluster Settings' _IAM Role Chaining_ tab you can configure the mappings between projects and IAM roles.

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ nav:
221221
- User Management: setup_installation/admin/user.md
222222
- Project Management: setup_installation/admin/project.md
223223
- Configure Alerts: setup_installation/admin/alert.md
224+
- IAM Role Chaining: setup_installation/admin/roleChaining.md
224225
- Monitoring:
225226
- Services Dashboards: setup_installation/admin/monitoring/grafana.md
226227
- Export metrics: setup_installation/admin/monitoring/export-metrics.md

0 commit comments

Comments
 (0)