卷已经专门连接到一个节点,不能连接到另一个节点

时间:2019-02-25 22:39:01

标签: kubernetes kops statefulset

我有一个非常简单的Kubernetes窗格。我需要一个有状态的集,并需要以下过程:

  1. 我想下载一个initcontainer并将s3的tarball解压缩到装入initcontainer的卷中
  2. 我想将该卷安装到要使用的主容器中

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: app
  namespace: test
  labels:
    name: app
spec:
  serviceName: app
  replicas: 1
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      initContainers:
      - name: preparing
        image: alpine:3.8
        imagePullPolicy: IfNotPresent
        command:
          - "sh"
          - "-c"
          - |
            echo "Downloading data"
            wget https://s3.amazonaws.com/.........
            tar -xvzf xxxx-........ -C /root/
        volumeMounts:
        - name: node-volume
          mountPath: /root/data/

      containers:
      - name: main-container
        image: ecr.us-west-2.amazonaws.com/image/:latest
        imagePullPolicy: Always

        volumeMounts:
        - name: node-volume
          mountPath: /root/data/

  volumeClaimTemplates:
  - metadata:
      name: node-volume
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: gp2-b
      resources:
        requests:
          storage: 80Gi

我继续出现以下错误:

首先,我运行此命令,然后可以看到initcontainer正在下载我的tarball的日志。大约完成一半,它终止并给我以下错误:

Multi-Attach error for volume "pvc-faedc8" Volume is 
already exclusively attached to one node and can't be 
attached to another

1 个答案:

答案 0 :(得分:3)

好像您有一个悬挂在PVC和/或PV上的节点上。您可以进入节点并运行dfmount进行检查。

如果您查看this,则StatefulSet中的PVC始终会映射到它们的容器名称,因此可能还有悬挂的容器(?)

您可以尝试删除PVC及其对应的PV:

$ kubectl -n test-node delete pvc pvc-faedc8
$ kubectl -n test-node delete pv <pv-name>