7

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

无法为 pod“wordpress-mysql-b78774f44-lxtfv_default(ffb4ff12-553e-11e9-a229-52540076d16c)”挂载卷:超时已过期,等待卷附加或挂载 pod“default”/“wordpress-mysql-b78774f44-lxtfv” ”。卸载卷列表=[mysql-persistent-storage]。未附加卷列表=[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
4

2 回答 2

6

看起来您的部署已成功进行!您看到的错误发生在您执行describe. 这可能是由于 ceph 配置了 PV/PVC,或者您的 PVC 尚未准备好安装的其他情况。但是,根据事件,您的容器最终成功安装并启动。所有 pod 健康检查都通过了,Kube 调度程序将其推进到 READY 状态。

是否有任何证据表明您的容器和挂载在启动后无法正常工作?

于 2019-04-02T15:39:20.190 回答
1

过去当卷太大(如 2TB 卷)时,我也经历过类似的事情。由于您只有一个主节点和 3 个工作节点,因此看看它们的资源有多大也会很有趣。

您是否在配置卷时检查了节点的 CPU 负载?如果集群太小,如果它们运行的​​节点负载过大,则其中一个 rook provisioner-pod 可能会遇到超时。

于 2022-02-25T19:23:14.580 回答