超时已到期,等待卷连接或挂载到Pod

时间:2019-04-02 14:23:45

标签: kubernetes rook

我在裸机上的ubuntu上安装了kubernetes。我部署了1个主控和3个工人。然后部署rook,一切正常。但是当我想在其上部署wordpress时,出现此错误

  

无法挂载Pod的卷   “ wordpress-mysql-b78774f44-lxtfv_default(ffb4ff12-553e-11e9-a229-52540076d16c)”:超时已到期,等待卷连接或挂载Pod   “默认” /“ wordpress-mysql-b78774f44-lxtfv”。卸载清单   volume = [mysql-persistent-storage]。未连接的列表   volume = [mysql-persistent-storage-default-token-nj8xw]

#kubectl describe pods wordpress-mysql-b78774f44-lxtfv

Events:
  Type     Reason            Age                    From               Message
  ----     ------            ----                   ----               -------
  Warning  FailedScheduling  7m11s (x4 over 7m18s)  default-scheduler  pod has unbound immediate PersistentVolumeClaims (repeated 3 times)
  Normal   Scheduled         7m5s                   default-scheduler  Successfully assigned default/wordpress-mysql-b78774f44-lxtfv to worker3
  Warning  FailedMount       2m46s (x2 over 5m1s)   kubelet, worker3   Unable to mount volumes for pod "wordpress-mysql-b78774f44-lxtfv_default(ffb4ff12-553e-11e9-a229-52540076d16c)": timeout expired waiting for volumes to attach or mount for pod "default"/"wordpress-mysql-b78774f44-lxtfv". list of unmounted volumes=[mysql-persistent-storage]. list of unattached volumes=[mysql-persistent-storage default-token-nj8xw]
  Normal   Pulled            107s                   kubelet, worker3   Container image "mysql:5.6" already present on machine
  Normal   Created           104s                   kubelet, worker3   Created container mysql
  Normal   Started           101s                   kubelet, worker3   Started container mysql


and my pods is running
#kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
wordpress-595685cc49-2bmzk        1/1     Running   4          15m
wordpress-mysql-b78774f44-lxtfv   1/1     Running   0          15m

我的pv和pvc

#kubectl get pv,pvc
NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS     CLAIM                    STORAGECLASS      REASON   AGE
persistentvolume/pvc-0f6722a0-553f-11e9-a229-52540076d16c   20Gi       RWO            Delete           Bound      default/wp-pv-claim      rook-ceph-block            15m
persistentvolume/pvc-e9797517-553b-11e9-a229-52540076d16c   20Gi       RWO            Delete           Released   default/wp-pv-claim      rook-ceph-block            37m
persistentvolume/pvc-ff52a22e-553e-11e9-a229-52540076d16c   20Gi       RWO            Delete           Bound      default/mysql-pv-claim   rook-ceph-block            16m

NAME                                   STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS      AGE
persistentvolumeclaim/mysql-pv-claim   Bound    pvc-ff52a22e-553e-11e9-a229-52540076d16c   20Gi       RWO            rook-ceph-block   16m
persistentvolumeclaim/wp-pv-claim      Bound    pvc-0f6722a0-553f-11e9-a229-52540076d16c   20Gi       RWO   

     rook-ceph-block   15m

我的wordpress yaml文件

# cat wordpress.yaml 
apiVersion: v1
kind: Service
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  ports:
  - port: 80
  selector:
    app: wordpress
    tier: frontend
  type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: wp-pv-claim
  labels:
    app: wordpress
spec:
  storageClassName: rook-ceph-block
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: wordpress
  labels:
    app: wordpress
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: wordpress
        tier: frontend
    spec:
      containers:
      - image: wordpress:4.6.1-apache
        name: wordpress
        env:
        - name: WORDPRESS_DB_HOST
          value: wordpress-mysql
        - name: WORDPRESS_DB_PASSWORD
          value: changeme
        ports:
        - containerPort: 80
          name: wordpress
        volumeMounts:
        - name: wordpress-persistent-storage
          mountPath: /var/www/html
      volumes:
      - name: wordpress-persistent-storage
        persistentVolumeClaim:
          claimName: wp-pv-claim
and my mysql yaml file
cat mysql.yaml 
apiVersion: v1
kind: Service
metadata:
  name: wordpress-mysql
  labels:
    app: wordpress
spec:
  ports:
    - port: 3306
  selector:
    app: wordpress
    tier: mysql
  clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
  labels:
    app: wordpress
spec:
  storageClassName: rook-ceph-block
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: wordpress-mysql
  labels:
    app: wordpress
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: wordpress
        tier: mysql
    spec:
      containers:
      - image: mysql:5.6
        name: mysql
        env:
        - name: MYSQL_ROOT_PASSWORD
          value: changeme
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim

1 个答案:

答案 0 :(得分:1)

看来您的部署已成功完成!从您执行describe开始,发生错误的时间为2分46秒。这可能是由于ceph设置了PV / PVC,或者是由于某些其他情况您尚未准备好安装PVC。但是,根据事件,您的容器最终将成功安装并启动。所有Pod运行状况检查均通过,并且Kube调度程序将其进行到READY状态。

是否有证据表明您的容器和底座在启动后无法正常工作?