Skip to content

Commit f062faa

Browse files
committed
S3CSI-5: Add sample YAML and docs for volume creds
1 parent 615c647 commit f062faa

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

examples/kubernetes/static_provisioning/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This example shows how to make a static provisioned Mountpoint for S3 persistent
1010
- `caching.yaml` - shows how to configure mountpoint to use a cache directory. See the [Mountpoint documentation](https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md#caching-configuration) for more details on caching options. Please thumbs up [#11](https://github.com/awslabs/mountpoint-s3-csi-driver/issues/141) or add details about your use case if you want improvements in this area.
1111
- `kms_sse.yaml` - demonstrates using SSE-KMS encryption with a customer supplied key id. See the [Mountpoint documentation](https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md#data-encryption) for more details.
1212
- `aws_max_attempts.yaml` - configure the number of retries for requests to S3. This option is passed to Mountpoint as the `AWS_MAX_ATTEMPTS` environment variable. See the [Mountpoint configuration documentation](https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md#other-s3-bucket-configuration) for more details.
13+
- `secret_authentication.yaml` - demonstrates using a Kubernetes Secret to provide access credentials (access key and secret key) at Volume level for authenticating with S3. This is particularly useful when the user wants to set their own credentials which are different than the driver level credentials.
1314

1415
## AWS Endpoint URL Configuration
1516
For security and consistency reasons, if `--endpoint-url` is specified in the `mountOptions` of a PersistentVolume, it will be **ignored** by the driver. This is enforced in both systemd and pod mounters to prevent potential security risks like endpoint redirection attacks.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Secret Authentication Example
2+
# This example demonstrates using a Kubernetes Secret to provide S3 credentials for the Mountpoint S3 CSI Driver.
3+
# This authentication method is particularly useful for:
4+
# 1. The user wants to set their own credentials which are different than the driver level credentials
5+
# 2. Using different credentials for different persistent volumes
6+
7+
# First, create a Secret containing the S3 credentials
8+
apiVersion: v1
9+
kind: Secret
10+
metadata:
11+
name: s3-credentials
12+
namespace: default
13+
type: Opaque
14+
data:
15+
# Using base64 encoded values. Example:
16+
# echo -n "ACCESS_KEY_ID" | base64
17+
key_id: QUtJQVhYWFhYWFhYWFhYWFhY
18+
# echo -n "SECRET_ACCESS_KEY" | base64
19+
access_key: U0VDUkVUWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWA==
20+
21+
# You can also create the secret using kubectl:
22+
# kubectl create secret generic s3-credentials \
23+
# --from-literal=key_id="ACCESS_KEY_ID" \
24+
# --from-literal=access_key="SECRET_ACCESS_KEY"
25+
26+
# SECURITY CONSIDERATIONS:
27+
# - Kubernetes Secrets are stored unencrypted in etcd by default
28+
# - Consider enabling encryption at rest: https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/
29+
# - Limit access to the Secret using appropriate RBAC rules
30+
# - Consider using Secret rotation for production deployments
31+
---
32+
# Next, create a PersistentVolume that references the Secret
33+
apiVersion: v1
34+
kind: PersistentVolume
35+
metadata:
36+
name: s3-pv
37+
spec:
38+
capacity:
39+
storage: 1000Gi # ignored, required
40+
accessModes:
41+
- ReadWriteMany
42+
persistentVolumeReclaimPolicy: Retain
43+
storageClassName: "" # Required for static provisioning
44+
mountOptions:
45+
- allow-delete
46+
- force-path-style
47+
csi:
48+
driver: s3.csi.aws.com
49+
volumeHandle: s3-csi-driver-volume
50+
volumeAttributes:
51+
bucketName: my-bucket
52+
authenticationSource: secret # Set auth source to use the Secret
53+
nodePublishSecretRef:
54+
name: s3-credentials # Reference to the Secret containing credentials
55+
namespace: default
56+
---
57+
# Create a PersistentVolumeClaim that references the PV
58+
apiVersion: v1
59+
kind: PersistentVolumeClaim
60+
metadata:
61+
name: s3-pvc
62+
namespace: default
63+
spec:
64+
accessModes:
65+
- ReadWriteMany
66+
storageClassName: ""
67+
resources:
68+
requests:
69+
storage: 1000Gi # Ignored, required
70+
volumeName: s3-pv
71+
---
72+
# Finally, create a Pod that uses the volume
73+
apiVersion: v1
74+
kind: Pod
75+
metadata:
76+
name: s3-app
77+
namespace: default
78+
spec:
79+
containers:
80+
- name: app
81+
image: busybox
82+
command: ["tail", "-f", "/dev/null"]
83+
volumeMounts:
84+
- name: s3-storage
85+
mountPath: /data
86+
volumes:
87+
- name: s3-storage
88+
persistentVolumeClaim:
89+
claimName: s3-pvc

0 commit comments

Comments
 (0)