Skip to content

Commit 64b5e18

Browse files
djnalluridekobon
authored andcommitted
Update documentation
1 parent 675cc1c commit 64b5e18

File tree

1 file changed

+76
-11
lines changed

1 file changed

+76
-11
lines changed

docs/getting_started.md

Lines changed: 76 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,11 @@ with the `--env-file` flag. When running as a Systemd service, the environment
4646
variables are specified in the `/etc/nginx/environment` file. An example of
4747
the format of the file can be found in the [settings.example](/settings.example)
4848
file.
49-
50-
If you are planning to use docker image on kubernetes cluster, you can use [service account]((https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html)) which can assume a role using [AWS Security Token Service](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html).
51-
52-
- Create a new [AWS IAM OIDC Provider](https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html). If you are using AWS EKS Cluster, then the IAM OIDC Provider should already be created as the part of cluster creation. So validate it before you create the new IAM OIDC Provider.
53-
- Configuring a [Kubernetes service account to assume an IAM role](https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html)
54-
- [Annotate the Service Account](https://docs.aws.amazon.com/eks/latest/userguide/cross-account-access.html) using IAM Role create in the above step.
55-
- [Configure your pods, Deployments, etc to use the Service Account](https://docs.aws.amazon.com/eks/latest/userguide/pod-configuration.html)
56-
- As soon as the pods/deployments are updated, you will see the couple of Env Variables listed below in the pods.
57-
`AWS_ROLE_ARN` - Contains IAM Role ARN
58-
`AWS_WEB_IDENTITY_TOKEN_FILE` - Contains the token which will be used to create temporary credentials using AWS Security Token Service.
5949

6050
There are few optional environment variables that can be used.
6151

6252
* `HOSTNAME` - (optional) The value will be used for Role Session Name. The default value is nginx-s3-gateway.
63-
* `STS_ENDPOINT` - (optional) Enter region specific STS Endpoint. The default value is https://sts.amazonaws.com.
53+
* `STS_ENDPOINT` - (optional) Overrides the STS endpoint to be used in applicable setups. This is not required when running on EKS. See the EKS portion of the guide below for more details.
6454

6555

6656
### Configuring Directory Listing
@@ -278,6 +268,81 @@ modified.
278268
aws cloudformation delete-stack \
279269
--stack-name nginx-s3-gateway
280270
```
271+
## Running on EKS with IAM roles for service accounts
272+
273+
If you are planning to use the container image on an EKS cluster, you can use a [service account]((https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html)) which can assume a role using [AWS Security Token Service](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html).
274+
275+
- Create a new [AWS IAM OIDC Provider](https://docs.aws.amazon.com/eks/latest/userguide/enable-iam-roles-for-service-accounts.html). If you are using AWS EKS Cluster, then the IAM OIDC Provider should already be created as the part of cluster creation. So validate it before you create the new IAM OIDC Provider.
276+
- Configuring a [Kubernetes service account to assume an IAM role](https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html)
277+
- [Annotate the Service Account](https://docs.aws.amazon.com/eks/latest/userguide/cross-account-access.html) using IAM Role create in the above step.
278+
- [Configure your pods, Deployments, etc to use the Service Account](https://docs.aws.amazon.com/eks/latest/userguide/pod-configuration.html)
279+
- As soon as the pods/deployments are updated, you will see the couple of Env Variables listed below in the pods.
280+
- `AWS_ROLE_ARN` - Contains IAM Role ARN
281+
- `AWS_WEB_IDENTITY_TOKEN_FILE` - Contains the token which will be used to create temporary credentials using AWS Security Token Service.
282+
283+
The following is a minimal set of resources to deploy:
284+
```yaml
285+
apiVersion: v1
286+
kind: ServiceAccount
287+
metadata:
288+
name: nginx-s3-gateway
289+
annotations:
290+
eks.amazonaws.com/role-arn: "<role-arn>"
291+
# See https://docs.aws.amazon.com/eks/latest/userguide/configure-sts-endpoint.html
292+
eks.amazonaws.com/sts-regional-endpoints: "true"
293+
---
294+
apiVersion: apps/v1
295+
kind: Deployment
296+
metadata:
297+
name: nginx-s3-gateway
298+
spec:
299+
replicas: 1
300+
selector:
301+
matchLabels:
302+
app: nginx-s3-gateway
303+
template:
304+
metadata:
305+
labels:
306+
app: nginx-s3-gateway
307+
spec:
308+
serviceAccountName: nginx-s3-gateway
309+
containers:
310+
- name: nginx-s3-gateway
311+
image: "ghcr.io/nginxinc/nginx-s3-gateway/nginx-oss-s3-gateway:latest-20220916"
312+
imagePullPolicy: IfNotPresent
313+
env:
314+
- name: S3_BUCKET_NAME
315+
value: "<bucket>"
316+
- name: S3_SERVER
317+
value: "s3.<aws region>.amazonaws.com"
318+
- name: S3_SERVER_PROTO
319+
value: "https"
320+
- name: S3_SERVER_PORT
321+
value: "443"
322+
- name: S3_STYLE
323+
value: "virtual"
324+
- name: S3_REGION
325+
value: "<aws region>"
326+
- name: AWS_SIGS_VERSION
327+
value: "4"
328+
- name: ALLOW_DIRECTORY_LIST
329+
value: "false"
330+
- name: PROVIDE_INDEX_PAGE
331+
value: "false"
332+
ports:
333+
- name: http
334+
containerPort: 80
335+
protocol: TCP
336+
livenessProbe:
337+
httpGet:
338+
path: /health
339+
port: http
340+
readinessProbe:
341+
httpGet:
342+
path: /health
343+
port: http
344+
```
345+
281346
## Troubleshooting
282347

283348
### Disable default `404` error message

0 commit comments

Comments
 (0)