【发布时间】:2020-07-14 03:45:14
【问题描述】:
我正在尝试使用 EKS 设置 EFS,但是当我部署我的 pod 时,我收到了类似 MountVolume.SetUp failed for volume "efs-pv3" : rpc error: code = DeadlineExceeded desc = context deadline exceeded 的错误
在我的活动中。
这是什么原因?
【问题讨论】:
标签: amazon-eks amazon-efs
我正在尝试使用 EKS 设置 EFS,但是当我部署我的 pod 时,我收到了类似 MountVolume.SetUp failed for volume "efs-pv3" : rpc error: code = DeadlineExceeded desc = context deadline exceeded 的错误
在我的活动中。
这是什么原因?
【问题讨论】:
标签: amazon-eks amazon-efs
这原来是分配给 EFS 挂载点的安全组的问题。我已经创建了挂载点,但安全组不允许来自持有我的 EKS 节点的 VPC 的流量。
一旦我将正确配置的安全组添加到 EFS 挂载点,该错误就消失了。
【讨论】:
这是使用Phyxx's answer 的自动化方式。
起初,我使用集群的 private 子网,这导致了这个线程提到的错误。看到上面提到的答案后,我注意到我的所有节点都在 public 子网中。因此,我只需要将“私人”切换为“公共”即可。
这是对我有用的脚本:
CLUSTER_REGION=<YOUR_CLUSTER_REGION>
CLUSTER_NAME=<YOUR_CLUSTER_NAME>
EFS_SECURITY_GROUP_NAME=<YOUR_EFS_SECURITY_GROUP_NAME>
EFS_FILE_SYSTEM_NAME<YOUR_EFS_FILE_SYSTEM_NAME>
create_efs_mount_targets() {
file_system_id=$(aws efs describe-file-systems \
--region $CLUSTER_REGION \
--query "FileSystems[?Name=='$EFS_FILE_SYSTEM_NAME'].FileSystemId" \
--output text) \
&& security_group_id=$(aws ec2 describe-security-groups \
--region $CLUSTER_REGION \
--query 'SecurityGroups[*]' \
--output json \
| jq -r 'map(select(.GroupName=="'$EFS_SECURITY_GROUP_NAME'")) | .[].GroupId') \
&& public_cluster_subnets=$(aws ec2 describe-subnets \
--region $CLUSTER_REGION \
--output json \
--filters Name=tag:alpha.eksctl.io/cluster-name,Values=$CLUSTER_NAME Name=tag:aws:cloudformation:logical-id,Values=SubnetPublic* \
| jq -r '.Subnets[].SubnetId')
if [[ $? != 0 ]]; then
exit 1
fi
for subnet in ${public_cluster_subnets[@]}
do
echo "Attempting to create mount target in "$subnet"..."
aws efs create-mount-target \
--file-system-id $file_system_id \
--subnet-id $subnet \
--security-groups $security_group_id \
&> /dev/null \
&& echo "Mount target created!"
done
}
create_efs_mount_targets
【讨论】: