0

我在裸机上的 ubuntu 上安装 kubernetes。我部署了 1 个 master 和 3 个 worker。然后部署 rook,一切正常。但是当我想在其上部署 wordpress 时,它卡在容器创建中,然后我删除了 wordpress,现在我得到了这个错误

卷已由 pod default/wordpress-mysql-b78774f44-gvr58 附加。运行状态

#kubectl describe pods wordpress-mysql-b78774f44-bjc2c

Events:
  Type     Reason       Age                    From               Message
  ----     ------       ----                   ----               -------
  Normal   Scheduled    3m21s                  default-scheduler  Successfully assigned default/wordpress-mysql-b78774f44-bjc2c to worker2
  Warning  FailedMount  2m57s (x6 over 3m16s)  kubelet, worker2   MountVolume.SetUp failed for volume "pvc-dcba7817-553b-11e9-a229-52540076d16c" : mount command failed, status: Failure, reason: Rook: Mount volume failed: failed to attach volume pvc-dcba7817-553b-11e9-a229-52540076d16c for pod default/wordpress-mysql-b78774f44-bjc2c. Volume is already attached by pod default/wordpress-mysql-b78774f44-gvr58. Status Running
  Normal   Pulling      2m26s                  kubelet, worker2   Pulling image "mysql:5.6"
  Normal   Pulled       110s                   kubelet, worker2   Successfully pulled image "mysql:5.6"
  Normal   Created      106s                   kubelet, worker2   Created container mysql
  Normal   Started      101s                   kubelet, worker2   Started container mysql

   for more information
# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                    STORAGECLASS      REASON   AGE
pvc-dcba7817-553b-11e9-a229-52540076d16c   20Gi       RWO            Delete           Bound    default/mysql-pv-claim   rook-ceph-block            13m
pvc-e9797517-553b-11e9-a229-52540076d16c   20Gi       RWO            Delete           Bound    default/wp-pv-claim      rook-ceph-block            13m
#kubectl get pvc
NAME             STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
mysql-pv-claim   Bound    pvc-dcba7817-553b-11e9-a229-52540076d16c   20Gi       RWO            rook-ceph-block   15m
wp-pv-claim      Bound    pvc-e9797517-553b-11e9-a229-52540076d16c   20Gi       RWO            rook-ceph-block   14m

#kubectl get pods --all-namespaces
NAMESPACE          NAME                                  READY   STATUS      RESTARTS   AGE
default            wordpress-595685cc49-sdbfk            1/1     Running     6          9m58s
default            wordpress-mysql-b78774f44-bjc2c       1/1     Running     0          8m14s
kube-system        coredns-fb8b8dccf-plnt4               1/1     Running     0          46m
kube-system        coredns-fb8b8dccf-xrkql               1/1     Running     0          47m
kube-system        etcd-master                           1/1     Running     0          46m
kube-system        kube-apiserver-master                 1/1     Running     0          46m
kube-system        kube-controller-manager-master        1/1     Running     1          46m
kube-system        kube-flannel-ds-amd64-45bsf           1/1     Running     0          40m
kube-system        kube-flannel-ds-amd64-5nxfz           1/1     Running     0          40m
kube-system        kube-flannel-ds-amd64-pnln9           1/1     Running     0          40m
kube-system        kube-flannel-ds-amd64-sg4pv           1/1     Running     0          40m
kube-system        kube-proxy-2xsrn                      1/1     Running     0          47m
kube-system        kube-proxy-mll8b                      1/1     Running     0          42m
kube-system        kube-proxy-mv5dw                      1/1     Running     0          42m
kube-system        kube-proxy-v2jww                      1/1     Running     0          42m
kube-system        kube-scheduler-master                 1/1     Running     0          46m
rook-ceph-system   rook-ceph-agent-8pbtv                 1/1     Running     0          26m
rook-ceph-system   rook-ceph-agent-hsn27                 1/1     Running     0          26m
rook-ceph-system   rook-ceph-agent-qjqqx                 1/1     Running     0          26m
rook-ceph-system   rook-ceph-operator-d97564799-9szvr    1/1     Running     0          27m
rook-ceph-system   rook-discover-26g84                   1/1     Running     0          26m
rook-ceph-system   rook-discover-hf7lc                   1/1     Running     0          26m
rook-ceph-system   rook-discover-jc72g                   1/1     Running     0          26m
rook-ceph          rook-ceph-mgr-a-68cb58b456-9rrj7      1/1     Running     0          21m
rook-ceph          rook-ceph-mon-a-6469b4c68f-cq6mj      1/1     Running     0          23m
rook-ceph          rook-ceph-mon-b-d59cfd758-2d2zt       1/1     Running     0          22m
rook-ceph          rook-ceph-mon-c-79664b789-wl4t4       1/1     Running     0          21m
rook-ceph          rook-ceph-osd-0-8778dbbc-d84mh        1/1     Running     0          19m
rook-ceph          rook-ceph-osd-1-84974b86f6-z5c6c      1/1     Running     0          19m
rook-ceph          rook-ceph-osd-2-84f9b78587-czx6d      1/1     Running     0          19m
rook-ceph          rook-ceph-osd-prepare-worker1-x4rqc   0/2     Completed   0          20m
rook-ceph          rook-ceph-osd-prepare-worker2-29jpg   0/2     Completed   0          20m
rook-ceph          rook-ceph-osd-prepare-worker3-rkp52   0/2     Completed   0          20m
4

1 回答 1

4

您正在为 PVC 使用标准类存储,您的策略将是ReadWriteOnce. 这并不意味着您只能将您的 PVC 连接到一个 pod,而只能连接到一个节点

ReadWriteOnce– 卷可以由单个节点以读写方式挂载

ReadWriteMany– 卷可以被许多节点以读写方式挂载

在这里,您似乎有 2 个 pod 试图挂载此卷。除非你做以下两件事之一,否则这将是不稳定的:

现在你有 2 个 Pod 试图挂载同一个卷,default/wordpress-mysql-b78774f44-gvr58并且default/wordpress-mysql-b78774f44-bjc2c.

您还可以缩减到 1 个 pod,因此您不必完全担心上述任何问题:

kubectl scale deploy wordpress-mysql --replicas=1
于 2019-04-02T14:14:46.227 回答