Ongoing service disruptions
For the most recent update on ongoing service disruptions affecting the AWS Middle East (UAE) Region (ME-CENTRAL-1), refer to the AWS Health Dashboard. For information on AWS Service migration, see How do I migrate my services to another region?
如何将加密的 Amazon EFS 文件系统挂载到 Amazon EKS 中的容器组(pod)上?
我想将加密的 Amazon Elastic File System (Amazon EFS) 文件系统挂载到 Amazon Elastic Kubernetes Service (Amazon EKS) 中的一个容器组(pod)上。
简短描述
可以使用 TLS 加密传输中的数据,也可以加密静态数据。
**注意:**如果在运行 AWS 命令行界面(AWS CLI)命令时收到错误,请参阅排查 AWS CLI 错误。此外,请确保您使用的是最新的 AWS CLI 版本。
解决方法
使用 TLS 加密传输中的数据
要使用 TLS 加密传输中的数据,请完成以下步骤:
-
为 Amazon EKS 集群部署 Amazon EFS 容器存储接口 (CSI) 驱动程序。
-
为集群创建一个不加密的 Amazon EFS 文件系统。
**注意:**创建文件系统时,请在 EKS 节点所在的所有可用区中为 Amazon EFS 创建一个挂载目标。 -
将 GitHub 存储库克隆到本地系统:
git clone https://github.com/kubernetes-sigs/aws-efs-csi-driver.git -
转至 encryption_in_transit 示例目录:
cd aws-efs-csi-driver/examples/kubernetes/encryption_in_transit/ -
检索 Amazon EFS 文件系统 ID:
aws efs describe-file-systems --query "FileSystems[*].FileSystemId" --output text -
转至 /examples/kubernetes/encryption_in_transit/specs/ 目录中的 pv.yaml 文件。然后,将 VolumeHandle 的值替换为正在挂载的 Amazon EFS 文件系统的 FileSystemId。例如:
apiVersion: v1 kind: PersistentVolume metadata: name: efs-pv spec: capacity: storage: 5Gi volumeMode: Filesystem accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Retain storageClassName: efs-sc csi: driver: efs.csi.aws.com volumeHandle: [FileSystemId] volumeAttributes: encryptInTransit: "true"**注意:**volumeAttributes: encryptInTransit 挂载选项会激活传输中的加密。
-
从 /examples/kubernetes/encryption_in_transit/specs/ 目录部署存储类、持久性卷声明、持久性卷和容器组(pod):
kubectl apply -f specs/storageclass.yaml kubectl apply -f specs/pv.yaml kubectl apply -f specs/claim.yaml kubectl apply -f specs/pod.yaml -
验证容器组(pod)是否处于运行状态:
kubectl get pods -
列出默认命名空间中的持久性卷:
kubectl get pv -
描述持久性卷:
kubectl describe pv efs-pv
**注意:**Amazon EFS 文件系统 ID 会显示为 VolumeHandle。 验证数据是否写入 Amazon EFS 文件系统:
kubectl exec -ti efs-app -- tail -f /data/out.txt
加密静态数据
要加密静态数据,请完成以下步骤:
-
为 Amazon EKS 集群部署 Amazon EFS CSI 驱动程序。
-
为 Amazon EKS 集群开启静态加密,以创建 Amazon EFS 文件系统。
-
将以下 GitHub 存储库克隆到本地系统:
git clone https://github.com/kubernetes-sigs/aws-efs-csi-driver.git -
转至 multiple_pods 示例目录:
cd aws-efs-csi-driver/examples/kubernetes/multiple_pods/ -
检索 Amazon EFS 文件系统 ID:
aws efs describe-file-systems输出示例:
{ "FileSystems": [ { "SizeInBytes": { "Timestamp": , "Value": }, "ThroughputMode": "", "CreationToken": "", "Encrypted": true, "CreationTime": , "PerformanceMode": "", "FileSystemId": "[FileSystemId]", "NumberOfMountTargets": , "LifeCycleState": "available", "KmsKeyId": "arn:aws:kms:ap-southeast-1:<account_id>:key/854df848-fdd1-46e3-ab97-b4875c4190e6", "OwnerId": "" }, ] } -
转至 /examples/kubernetes/multiple_pods/specs/ 目录中的 pv.yaml 文件。然后,将 volumeHandle 的值替换为正在挂载的 Amazon EFS 文件系统的 FileSystemId。例如:
apiVersion: v1 kind: PersistentVolume metadata: name: efs-pv spec: capacity: storage: 5Gi volumeMode: Filesystem accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain storageClassName: efs-sc csi: driver: efs.csi.aws.com volumeHandle: [FileSystemId] -
从 /examples/kubernetes/multiple_pods/specs/ 目录部署存储类、持久性卷声明、持久性卷和容器组(pod):
kubectl apply -f specs/storageclass.yaml kubectl apply -f specs/pv.yaml kubectl apply -f specs/claim.yaml kubectl apply -f specs/pod1.yaml kubectl apply -f specs/pod2.yaml -
验证容器组(pod)是否处于运行状态:
kubectl get pods -
列出默认命名空间中的持久性卷:
kubectl get pv -
描述持久性卷:
kubectl describe pv efs-pv
- 验证数据是否写入 Amazon EFS 文件系统:
kubectl exec -ti app1 -- tail /data/out1.txt kubectl exec -ti app2 -- tail /data/out1.txt
- 语言
- 中文 (简体)
