jon*_*ckt 19 amazon-ebs amazon-web-services kubernetes persistent-volumes amazon-eks
我们配置了 EKS 设置,其中使用基于云原生 Buildpacks 的 Tekton Pipeline,但我们PipelineRuns在没有获取 Pod 资源的情况下永远陷入困境并处于等待状态。我们创建了一个 PersistentVolumeClaim,如下所示:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: buildpacks-source-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
Run Code Online (Sandbox Code Playgroud)
创建后查看此 PVC 的事件,发现以下事件表明我们的 EKS 设置出现问题:
该命令kubectl describe pvc buildpacks-source-pvc给出以下事件消息:
Name: buildpacks-source-pvc
Namespace: default
StorageClass: gp2
Status: Pending
Volume:
Labels: <none>
Annotations: volume.beta.kubernetes.io/storage-provisioner: ebs.csi.aws.com
volume.kubernetes.io/selected-node: ip-999-99-99-99.eu-central-1.compute.internal
volume.kubernetes.io/storage-provisioner: ebs.csi.aws.com
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Used By: affinity-assistant-0b3d266b91-0
affinity-assistant-53a7c08baf-0
affinity-assistant-a375f28de3-0
affinity-assistant-e8cb1a6e15-0
buildpacks-test-pipeline-run-9rz4l-fetch-repository-pod
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ExternalProvisioning 3m43s (x561 over 143m) persistentvolume-controller waiting for a volume to be created, either by external provisioner "ebs.csi.aws.com" or manually created by system administrator
Run Code Online (Sandbox Code Playgroud)
EBS CSI 是什么?我们如何让集群像以前一样工作?
jon*_*ckt 58
从 EKS 1.23 开始,需要容器存储接口 (CSI) 驱动程序,以便让 PersisentVolumeClaims 由 PersisentVolume 提供服务,就像您在早期 EKS 版本中所习惯的那样。
文档告诉我们,需要配置什么:
本质上,我们需要启用 AWS EBS CSI 驱动程序作为 EKS 插件。但事先我们需要启用 IAM OIDC 提供程序并为 EBS CSI 驱动程序创建 IAM 角色。实现这两者的最简单方法是使用eksctl (文档中描述了使用普通awscli 或 AWS GUI等其他方法)。
我们在此假设已安装并配置 aws cli - 并且您可以访问 EKS 集群。要使用eksctl我们需要先安装它。在Mac上使用brew,例如:
brew tap weaveworks/tap
brew install weaveworks/tap/eksctl
Run Code Online (Sandbox Code Playgroud)
或者在 Linux 上使用:
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
Run Code Online (Sandbox Code Playgroud)
EBS CSI 驱动程序正常工作的先决条件是您的集群拥有现有的 AWS Identity and Access Management (IAM) OpenID Connect (OIDC) 提供商。可以使用以下命令启用此 IAM OIDC 提供程序:
eksctl utils associate-iam-oidc-provider --region=eu-central-1 --cluster=YourClusterNameHere --approve
Run Code Online (Sandbox Code Playgroud)
现在已经eksctl到位,创建 IAM 角色:
eksctl create iamserviceaccount \
--region eu-central-1 \
--name ebs-csi-controller-sa \
--namespace kube-system \
--cluster YourClusterNameHere \
--attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \
--approve \
--role-only \
--role-name AmazonEKS_EBS_CSI_DriverRole
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,AWS 为我们维护了一个托管策略,我们可以简单地使用 ( AWS maintains a managed policy, available at ARN arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy)。仅当您使用加密的 EBS 驱动器时,您才需要向策略中另外添加配置。
命令...
...部署一个 AWS CloudFormation 堆栈,该堆栈创建 IAM 角色、向其附加 IAM 策略,并使用 IAM 角色的 Amazon 资源名称 (ARN) 注释现有 ebs-csi-controller-sa 服务账户。
现在我们终于可以添加 EBS CSI 附加组件了。因此,我们还需要可以通过运行获取的 AWS 账户 ID aws sts get-caller-identity --query Account --output text(请参阅从 AWS CLI 工具获取 AWS 账户号的快速方法?)。现在eksctl create addon命令如下所示:
eksctl create addon --name aws-ebs-csi-driver --cluster YourClusterNameHere --service-account-role-arn arn:aws:iam::$(aws sts get-caller-identity --query Account --output text):role/AmazonEKS_EBS_CSI_DriverRole --force
Run Code Online (Sandbox Code Playgroud)
Bound现在,您的 PersistentVolumeClaim 应该会在为您创建 EBS 卷时获得状态- 并且 Tekton Pipeline 应该再次运行。
| 归档时间: |
|
| 查看次数: |
19039 次 |
| 最近记录: |