首页 > 解决方案 > 删除 pod 后 kubernetes pod 无法挂载 gcloud 持久化磁盘

问题描述

我有一个带有 gcloud 持久性磁盘的工作 redis pod。有时在删除 pod 时会抛出以下错误:

AttachVolume.Attach failed for volume "redis-volume" : GCE persistent disk not found: diskName="redis-volume" zone="europe-west3-c"

如果删除 pod 失败,请再次解决问题 - 但这不是一个问题。

使用以下 Kubernetes 配置:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
        - name: redis
          image: redis:3.2-alpine
          imagePullPolicy: Always
          args: ["--requirepass", "password", "--appendonly", "yes", "--save", "900", "1", "--save", "30", "1"]
          ports:
            - containerPort: 6379
              name: redis
          env:
          volumeMounts:
            - name: redis-volume
              mountPath: /data
      volumes:
        - name: redis-volume
          gcePersistentDisk:
            pdName: redis-volume
            fsType: ext4

有没有人遇到过这个问题?

标签: kubernetesgcloud

解决方案


在将持久卷与持久卷声明分开后,我遇到了同样的问题。

部署应该使用声明。 https://www.youtube.com/watch?v=n06kKYS6LZE


推荐阅读