【问题标题】:After running Kompose I get: pod has unbound immediate PersistentVolumeClaims运行 Kompose 后,我得到: pod has unbound immediate PersistentVolumeClaims
【发布时间】:2020-06-23 23:10:17
【问题描述】:

什么问题?

我无法让正在使用卷的 pod 运行。在 Kubernetes 仪表板中,我收到以下错误:

为 pod“influxdb-6979bff6f9-hpf89”运行“VolumeBinding”过滤器插件:pod 具有未绑定的即时 PersistentVolumeClaims

我做了什么?

Kompose convert 运行到我的docker-compose.yml 文件后,我尝试使用micro8ks kubectl apply -f . 启动pod(我使用的是micro8ks)我不得不用networking.k8s.io/v1 替换networkpolicy yaml 文件的版本(请参阅here ) 但除了这个改变,我什么都没改变。

YAML 文件

influxdb-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: ./kompose convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: influxdb
  name: influxdb
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: influxdb
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: ./kompose convert
        kompose.version: 1.21.0 (992df58d8)
      creationTimestamp: null
      labels:
        io.kompose.network/cloud-net: "true"
        io.kompose.network/default: "true"
        io.kompose.service: influxdb
    spec:
      containers:
      - env:
        - name: INFLUXDB_HTTP_LOG_ENABLED
          value: "false"
        image: influxdb:1.8
        imagePullPolicy: ""
        name: influxdb
        ports:
        - containerPort: 8086
        resources: {}
        volumeMounts:
        - mountPath: /var/lib/influxdb
          name: influx
      restartPolicy: Always
      serviceAccountName: ""
      volumes:
      - name: influx
        persistentVolumeClaim:
          claimName: influx
status: {} 

influxdb-service.yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: ./kompose convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: influxdb
  name: influxdb
spec:
  ports:
  - name: "8087"
    port: 8087
    targetPort: 8086
  selector:
    io.kompose.service: influxdb
status:
  loadBalancer: {} 

influx-persistenvolumeclaim.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: influx
  name: influx
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {} 

【问题讨论】:

    标签: kubernetes microk8s kompose


    【解决方案1】:

    如果集群没有StorageClass 可以动态配置PersistentVolume,或者它没有手动创建的PersistentVolume 以满足PersistentVolumeClaim,则PersistentVolumeClaim 将被解除绑定

    这里是guide,关于如何配置 pod 以使用 PersistentVolume

    要解决当前场景,您可以手动创建 PV

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: task-pv-volume
      labels:
        type: local
    spec:
      storageClassName: manual
      capacity:
        storage: 100Mi
      accessModes:
        - ReadWriteOnce
      hostPath:
        path: "/mnt/data"
    

    请注意hostPath 的用法仅作为示例。不建议用于生产用途。考虑使用支持类型的外部块或文件存储here

    【讨论】:

    • 我用您在上面发布的文字创建了influx-volume.yaml,并在influx-persistentvolumeclaim.yaml 中插入了以下内容:storageClassName: manual 如您的指南中所述,它现在似乎可以工作,但我不明白为什么Kompose 不会自动执行此操作,因为它似乎是强制性的。我会试着弄清楚 StorageClass 是怎么回事,可能最好的解决方案就是在这里找到。
    猜你喜欢
    • 2019-06-07
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    • 2019-03-11
    • 2011-09-17
    • 1970-01-01
    • 2019-07-22
    • 2021-05-28
    相关资源
    最近更新 更多