我有一个由2个节点组成的EKS集群,由以下命令创建

time eksctl create cluster --name=eks-spinnaker --ssh-access=true --ssh-public-key=testkeyG --nodes=2 --region=ap-southeast-2 --write-kubeconfig=false
然后,我将ssh切换到两个新创建的VM并添加了EFS,如下所示,因此我可以将其用于PersistenceVolume
sudo  yum update -y
EFS_FILE_SYSTEM_DNS_NAME=fs-efb24ad7.efs.ap-southeast-2.amazonaws.com
sudo mkdir /efs-data
sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport $EFS_FILE_SYSTEM_DNS_NAME:/ /efs-data
df -Ph
cd /efs-data/
chmod -R 777 .
touch abc
我在两个节点上都清楚地看到以下内容:
节点01
[ec2-user@ip-192-168-74-31 efs-data]$ df -Ph |grep -i efs
fs-efb24ad7.efs.ap-southeast-2.amazonaws.com:/  8.0E     0  8.0E   0% /efs-data
[ec2-user@ip-192-168-74-31 efs-data]$

节点02
[ec2-user@ip-192-168-21-167 efs-data]$ df -Ph |grep -i efs
fs-efb24ad7.efs.ap-southeast-2.amazonaws.com:/  8.0E     0  8.0E   0% /efs-data
[ec2-user@ip-192-168-21-167 efs-data]$
我现在将Jenkins作为k8s部署进行纺纱,并使用/ efs-data作为PV,但是没有运气。
[centos@ip-10-0-0-61 storage]$ kubectl get pv,pvc -n jenkins
NAME                      CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE
persistentvolume/efs-pv   5Gi        RWX            Retain           Bound    jenkins/efs-claim   efs-sc                  7h6m

NAME                              STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/efs-claim   Bound    efs-pv   5Gi        RWX            efs-sc         7h6m
[centos@ip-10-0-0-61 storage]$
添加了 Helm 仓库并安装
helm repo add jenkinsci https://charts.jenkins.io
helm install jenkins jenkinsci/jenkins --set rbac.create=true,master.servicePort=8081,master.serviceType=LoadBalancer,persistence.existingClaim=efs-claim -n jenkins
不幸的是,kubectl describe pods <od name> -n jenkins没有提供任何关于出问题的线索
kubectl describe pods jenkins-c7498bcdf-4jk9w -n jenkins


Events:
  Type     Reason       Age                    From                                                        Message
  ----     ------       ----                   ----                                                        -------
  Warning  FailedMount  26m (x6 over 117m)     kubelet, ip-192-168-21-167.ap-southeast-2.compute.internal  Unable to attach or mount volumes: unmounted volumes=[jenkins-home], unattached volumes=[plugin-dir jenkins-token-xgzf4 sc-config-volume tmp jenkins-home jenkins-config plugins]: timed out waiting for the condition
  Warning  FailedMount  17m (x8 over 110m)     kubelet, ip-192-168-21-167.ap-southeast-2.compute.internal  Unable to attach or mount volumes: unmounted volumes=[jenkins-home], unattached volumes=[plugins plugin-dir jenkins-token-xgzf4 sc-config-volume tmp jenkins-home jenkins-config]: timed out waiting for the condition
  Warning  FailedMount  6m12s (x11 over 128m)  kubelet, ip-192-168-21-167.ap-southeast-2.compute.internal  Unable to attach or mount volumes: unmounted volumes=[jenkins-home], unattached volumes=[tmp jenkins-home jenkins-config plugins plugin-dir jenkins-token-xgzf4 sc-config-volume]: timed out waiting for the condition
  Warning  FailedMount  110s (x72 over 132m)   kubelet, ip-192-168-21-167.ap-southeast-2.compute.internal  MountVolume.SetUp failed for volume "efs-pv" : kubernetes.io/csi: mounter.SetupAt failed: rpc error: code = Internal desc = Could not mount "fs-efb24ad7:/efs-data" at "/var/lib/kubelet/pods/66e53953-8678-404c-beb6-d21908cc8dee/volumes/kubernetes.io~csi/efs-pv/mount": mount failed: exit status 32
Mounting command: mount
Mounting arguments: -t efs fs-efb24ad7:/efs-data /var/lib/kubelet/pods/66e53953-8678-404c-beb6-d21908cc8dee/volumes/kubernetes.io~csi/efs-pv/mount
Output: mount.nfs4: mounting fs-efb24ad7.efs.ap-southeast-2.amazonaws.com:/efs-data failed, reason given by server: No such file or directory

因此,我在安装了EFS的一个EKS集群上使用ssh,也出现了相同的错误
Sep  5 16:19:17 ip-192-168-21-167 kubelet: {"level":"info","ts":"2020-09-05T16:19:17.390Z","caller":"/usr/local/go/src/runtime/proc.go:203","msg":"CNI Plugin version: v1.6.3 ..."}
Sep  5 16:19:22 ip-192-168-21-167 kubelet: {"level":"info","ts":"2020-09-05T16:19:22.415Z","caller":"/usr/local/go/src/runtime/proc.go:203","msg":"CNI Plugin version: v1.6.3 ..."}
Sep  5 16:19:22 ip-192-168-21-167 su: (to root) ec2-user on pts/0
Sep  5 16:19:27 ip-192-168-21-167 kubelet: {"level":"info","ts":"2020-09-05T16:19:27.440Z","caller":"/usr/local/go/src/runtime/proc.go:203","msg":"CNI Plugin version: v1.6.3 ..."}
Sep  5 16:19:27 ip-192-168-21-167 kubelet: I0905 16:19:27.732162    3861 csi_attacher.go:310] kubernetes.io/csi: attacher.MountDevice STAGE_UNSTAGE_VOLUME capability not set. Skipping MountDevice...
Sep  5 16:19:27 ip-192-168-21-167 kubelet: I0905 16:19:27.732616    3861 operation_generator.go:587] MountVolume.MountDevice succeeded for volume "efs-pv" (UniqueName: "kubernetes.io/csi/efs.csi.aws.com^fs-efb24ad7:/efs-data") pod "jenkins-c7498bcdf-4jk9w" (UID: "66e53953-8678-404c-beb6-d21908cc8dee") device mount path "/var/lib/kubelet/plugins/kubernetes.io/csi/pv/efs-pv/globalmount"
Sep  5 16:19:29 ip-192-168-21-167 kubelet: E0905 16:19:29.715185    3861 nestedpendingoperations.go:301] Operation for "{volumeName:kubernetes.io/csi/efs.csi.aws.com^fs-efb24ad7:/efs-data podName: nodeName:}" failed. No retries permitted until 2020-09-05 16:21:31.715151408 +0000 UTC m=+86869.996160364 (durationBeforeRetry 2m2s). Error: "MountVolume.SetUp failed for volume \"efs-pv\" (UniqueName: \"kubernetes.io/csi/efs.csi.aws.com^fs-efb24ad7:/efs-data\") pod \"jenkins-c7498bcdf-4jk9w\" (UID: \"66e53953-8678-404c-beb6-d21908cc8dee\") : kubernetes.io/csi: mounter.SetupAt failed: rpc error: code = Internal desc = Could not mount \"fs-efb24ad7:/efs-data\" at \"/var/lib/kubelet/pods/66e53953-8678-404c-beb6-d21908cc8dee/volumes/kubernetes.io~csi/efs-pv/mount\": mount failed: exit status 32\nMounting command: mount\nMounting arguments: -t efs fs-efb24ad7:/efs-data /var/lib/kubelet/pods/66e53953-8678-404c-beb6-d21908cc8dee/volumes/kubernetes.io~csi/efs-pv/mount\nOutput: mount.nfs4: mounting fs-efb24ad7.efs.ap-southeast-2.amazonaws.com:/efs-data failed, reason given by server: No such file or directory\n"
Sep  5 16:19:32 ip-192-168-21-167 kubelet: {"level":"info","ts":"2020-09-05T16:19:32.458Z","caller":"/usr/local/go/src/runtime/proc.go:203","msg":"CNI Plugin version: v1.6.3 ..."}
Sep  5 16:19:35 ip-192-168-21-167 dhclient[2857]: XMT: Solicit on eth0, interval 111090ms.
Sep  5 16:19:37 ip-192-168-21-167 kubelet: {"level":"info","ts":"2020-09-05T16:19:37.477Z","caller":"/usr/local/go/src/runtime/proc.go:203","msg":"CNI Plugin version: v1.6.3 ..."}

/ efs-data的权限如下:
[root@ip-192-168-21-167 ~]# ls -ld /efs-data/
drwxrwxrwx 4 root root 6144 Sep  5 13:19 /efs-data/
[root@ip-192-168-21-167 ~]#

精疲力竭...请让我知道问题是什么以及如何解决...

最佳答案

问题是/efs-data实际上在您的EFS驱动器中不存在。 Jenkins正在尝试从注销登出该目录:

-t efs fs-efb24ad7:/efs-data /var/lib/kubelet/pods/66e53953-8678-404c-beb6-d21908cc8dee/volumes/kubernetes.io~csi/efs-pv/mount
所以消息:
Output: mount.nfs4: mounting fs-efb24ad7.efs.ap-southeast-2.amazonaws.com:/efs-data failed, reason given by server: No such file or directory
是正确的。
运行时:
sudo mount -t nfs -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport $EFS_FILE_SYSTEM_DNS_NAME:/ /efs-data
它实际上将/挂载在本地/efs-data目录上,但这不是EFS目录。为此,您可以简单地运行:
cd /efs-data
mkdir efs-data
然后/efs-data实际上将存在于EFS卷中。
✌️

关于kubernetes - 由于efs驱动程序问题,Jenkins应用程序无法启动,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63756077/

10-11 17:36