【问题标题】:Error - "Transport endpoint is not connected" while using s3fs with kubernetes when pod fails错误 - 在 pod 失败时使用 s3fs 和 kubernetes 时出现“传输端点未连接”
【发布时间】:2020-11-06 07:16:55
【问题描述】:

我有一个 EKS 集群,其中有一个将 s3 存储桶安装到所有 pod 的守护进程。

每当出现问题或 pod 重新启动时,挂载卷都无法访问并引发以下错误。

Transport endpoint is not connected

为了解决这个错误,我必须手动卸载卷并重新启动守护程序。

umount /mnt/data-s3-fuse

这个问题的永久解决方案是什么?

我的守护进程文件

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  labels:
    app: s3-provider
  name: s3-provider
  namespace: airflow
spec:
  template:
    metadata:
      labels:
        app: s3-provider
    spec:
      containers:
      - name: s3fuse
        image: image
        lifecycle:
          preStop:
            exec:
              command: ["/bin/sh","-c","umount -f /opt/airflow/dags"]
        securityContext:
          privileged: true
          capabilities:
            add:
            - SYS_ADMIN
        # use ALL  entries in the config map as environment variables
        envFrom:
        - configMapRef:
            name: s3-config
        volumeMounts:
        - name: devfuse
          mountPath: /dev/fuse
        - name: mntdatas3fs
          mountPath: /opt/airflow/dags:shared
      volumes:
      - name: devfuse
        hostPath:
          path: /dev/fuse
      - name: mntdatas3fs
        hostPath:
          path: /mnt/data-s3-fuse

我的 pod yaml 是

apiVersion: v1
kind: Pod
metadata:
  name: test-pd
  namespace: airflow
spec:
  containers:
  - image: nginx
    name: s3-test-container
    securityContext:
      privileged: true
    volumeMounts:
    - name: mntdatas3fs
      mountPath: /opt/airflow/dags:shared
    livenessProbe:
      exec:
        command: ["ls", "/opt/airflow/dags"]
      failureThreshold: 3
      initialDelaySeconds: 10
      periodSeconds: 5
      successThreshold: 1
      timeoutSeconds: 1
  volumes:
  - name: mntdatas3fs
    hostPath:
      path: /mnt/data-s3-fuse

我正在为 s3 kubernetes fuse 使用以下代码。

https://github.com/freegroup/kube-s3

【问题讨论】:

  • s3fs 正在运行吗? “传输端点未连接”表明它意外退出。通过-f -d 查看调试日志,您可能会有所了解。
  • 遇到同样的问题,在跟踪器上打开它:github.com/freegroup/kube-s3/issues/10

标签: amazon-s3 kubernetes amazon-eks s3fs


【解决方案1】:

好的,我想我解决了。 似乎有时 pod 会失去连接,导致“传输未连接”。 我发现解决此问题的解决方法是添加一个 init 容器,该容器尝试在之前卸载该文件夹。这似乎可以解决问题。 请注意,您要挂载更高级别的文件夹,因此您可以访问该节点。 让它运行,看看它是否回来,它似乎已经解决了这里的问题:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: s3-provider
  name: s3-provider
spec:
  selector:
    matchLabels:
      app: s3-provider
  template:
    metadata:
      labels:
        app: s3-provider
    spec:
      initContainers:
      - name: init-myservice
        image: bash
        command: ['bash', '-c', 'umount -l /mnt/data-s3-fs/root ; true']
        securityContext:
          privileged: true
          capabilities:
            add:
            - SYS_ADMIN
        # use ALL  entries in the config map as environment variables
        envFrom:
        - configMapRef:
            name: s3-config
        volumeMounts:
        - name: devfuse
          mountPath: /dev/fuse
        - name: mntdatas3fs-init
          mountPath: /mnt:shared
      containers:
      - name: s3fuse
        image: 963341077747.dkr.ecr.us-east-1.amazonaws.com/kube-s3:1.0
        imagePullPolicy: Always
        lifecycle:
          preStop:
            exec:
              command: ["bash", "-c", "umount -f /srv/s3-mount/root"]
        securityContext:
          privileged: true
          capabilities:
            add:
            - SYS_ADMIN
        # use ALL  entries in the config map as environment variables
        envFrom:
        - configMapRef:
            name: s3-config
        env:
        - name: S3_BUCKET
          value: s3-mount
        - name: MNT_POINT
          value: /srv/s3-mount/root
        - name: IAM_ROLE
          value: none
        volumeMounts:
        - name: devfuse
          mountPath: /dev/fuse
        - name: mntdatas3fs
          mountPath: /srv/s3-mount/root:shared
      volumes:
      - name: devfuse
        hostPath:
          path: /dev/fuse
      - name: mntdatas3fs
        hostPath:
          type: DirectoryOrCreate
          path: /mnt/data-s3-fs/root
      - name: mntdatas3fs-init
        hostPath:
          type: DirectoryOrCreate
          path: /mnt

【讨论】:

    【解决方案2】:

    对我来说,解决方案是在 pod 退出之前使用 preStop 挂钩事件来卸载路径:

        containers:
          - name: aws-sync
            lifecycle:
              preStop:
                exec:
                  command: ['bash', '-c', 'umount -l /mounted/path; true']
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-11
      • 1970-01-01
      • 2015-06-23
      • 2012-12-10
      • 2018-07-07
      • 2013-04-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多