Skip to content

Commit d28569d

Browse files
authored
Merge pull request #87 from nablaflow/main
Add ability to authenticate against AWS via STS
2 parents a516b06 + a369cec commit d28569d

File tree

7 files changed

+41
-4
lines changed

7 files changed

+41
-4
lines changed

charts/core-dump-handler/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ helm install core-dump-handler . --create-namespace --namespace observe \
3636
<tr>
3737
<td>AWS</td><td>EKS</td><td><a href="values.aws.yaml">values.aws.yaml</a></td>
3838
</tr>
39+
<tr>
40+
<td>AWS</td><td>EKS with IAM roles for service accounts</td><td><a href="values.aws.sts.yaml">values.aws.yaml</a></td>
41+
</tr>
3942
<tr>
4043
<td>AWS</td><td>ROSA</td><td><a href="values.openshift.yaml">values.openshift.yaml</a></td>
4144
</tr>
@@ -140,6 +143,14 @@ Example S3 policy:
140143
}
141144
```
142145

146+
### EKS setup with IAM roles for service accounts
147+
148+
This allows core-dump-handler to automatically assume the correct role with permissions on the S3 bucket without providing fixed credentials in the secret.
149+
150+
See [this guide](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).
151+
152+
[Example of `values.yaml`](values.aws.sts.yaml)
153+
143154
### Environment Variables
144155

145156
The agent pod has the following environment variables and these are all set by the chart but included here for informational purposes:

charts/core-dump-handler/templates/secrets.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ metadata:
55
name: s3config
66
type: Opaque
77
stringData:
8+
{{- if .Values.daemonset.s3Secret }}
89
s3Secret: {{ .Values.daemonset.s3Secret }}
10+
{{- end }}
11+
{{- if .Values.daemonset.s3AccessKey }}
912
s3AccessKey: {{ .Values.daemonset.s3AccessKey }}
13+
{{- end }}
1014
s3BucketName: {{ .Values.daemonset.s3BucketName }}
1115
s3Region: {{ .Values.daemonset.s3Region }}
1216
{{- end }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
{{- if .Values.serviceAccount.create }}
12
apiVersion: v1
23
kind: ServiceAccount
34
metadata:
45
name: {{ include "core-dump-handler.serviceAccountName" . }}
56
labels:
67
{{ include "core-dump-handler.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{ toYaml . | indent 4 }}
11+
{{- end }}
12+
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# AWS requires a crio client to be copied to the server
2+
daemonset:
3+
includeCrioExe: true
4+
vendor: rhel7 # EKS EC2 images have an old libc=2.26
5+
6+
serviceAccount:
7+
annotations:
8+
# See https://docs.aws.amazon.com/eks/latest/userguide/specify-service-account-role.html
9+
eks.amazonaws.com/role-arn: arn:aws:iam::123456789000:role/iam-role-name-here

charts/core-dump-handler/values.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@
280280
},
281281
"name": {
282282
"type": "string"
283+
},
284+
"annotations": {
285+
"type": "object"
283286
}
284287
},
285288
"required": [
@@ -289,4 +292,4 @@
289292
"title": "ServiceAccount"
290293
}
291294
}
292-
}
295+
}

charts/core-dump-handler/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ daemonset:
5050
serviceAccount:
5151
create: true
5252
name: "core-dump-admin"
53+
# annotations:
54+
# eks.amazonaws.com/role-arn: arn:aws:iam::123456789000:role/iam-role-name-here
5355

5456
# OpenShift specific for SecurityContextConstraints
5557
scc:

core-dump-agent/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ fn get_bucket() -> Result<Bucket, anyhow::Error> {
359359
}
360360
};
361361

362-
let credentials = if s3_access_key.is_empty() || s3_secret.is_empty() {
362+
let credentials = if env::var("AWS_WEB_IDENTITY_TOKEN_FILE").is_ok() {
363+
Credentials::from_sts_env(std::env!("CARGO_PKG_NAME"))
364+
} else if s3_access_key.is_empty() || s3_secret.is_empty() {
363365
Credentials::new(None, None, None, None, None)
364366
} else {
365367
Credentials::new(
@@ -369,12 +371,12 @@ fn get_bucket() -> Result<Bucket, anyhow::Error> {
369371
None,
370372
None,
371373
)
372-
};
374+
}?;
373375

374376
let s3 = Storage {
375377
name: "aws".into(),
376378
region,
377-
credentials: credentials.unwrap(),
379+
credentials,
378380
bucket: s3_bucket_name,
379381
location_supported: false,
380382
};

0 commit comments

Comments
 (0)