"MountVolume.SetUp failed for volume" 使用 EKS 和 EFS
"MountVolume.SetUp failed for volume" with EKS and EFS
我正在尝试使用 EKS 设置 EFS,但是当我部署我的 pod 时,出现类似 MountVolume.SetUp failed for volume "efs-pv3" : rpc error: code = DeadlineExceeded desc = context deadline exceeded
的错误
在我的活动中。
这是什么原因?
这原来是分配给 EFS 挂载点的安全组的问题。我已经创建了挂载点,但安全组不允许来自持有我的 EKS 节点的 VPC 的流量。
将正确配置的安全组添加到 EFS 挂载点后,该错误就消失了。
这是使用 的自动方法。
起初,我使用集群的 private 子网,这导致了该线程提到的错误。看到提到的答案后,我注意到我所有的节点都在 public 子网中。因此,我只需将“私人”切换为“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
我正在尝试使用 EKS 设置 EFS,但是当我部署我的 pod 时,出现类似 MountVolume.SetUp failed for volume "efs-pv3" : rpc error: code = DeadlineExceeded desc = context deadline exceeded
的错误
在我的活动中。
这是什么原因?
这原来是分配给 EFS 挂载点的安全组的问题。我已经创建了挂载点,但安全组不允许来自持有我的 EKS 节点的 VPC 的流量。
将正确配置的安全组添加到 EFS 挂载点后,该错误就消失了。
这是使用
起初,我使用集群的 private 子网,这导致了该线程提到的错误。看到提到的答案后,我注意到我所有的节点都在 public 子网中。因此,我只需将“私人”切换为“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