本地持久卷1节点未找到可用的持久卷进行绑定

时间:2019-03-12 00:34:44

标签: kubernetes persistent-volumes

我从持久卷和k8开始。我试图在安装了minikube的RH7盒上使用本地文件夹。我收到错误消息:

0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind.

StorageClass.yaml

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

PersistentVolume.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-local-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage
  local:
    path: /usr/local/docker/vol1
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - my-node

PersistentVolumeClaim.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: example-local-claim
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: local-storage
  resources:
    requests:
      storage: 1Gi

Nginx.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
    name: nginx-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
      name: nginx-deployment
  template:
    metadata:
      labels:
        app: nginx
        name: nginx-deployment
    spec:
      containers:
      - name: nginx-deployment
        image: nginx
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: storage
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: example-local-claim

[root @ localhost docker]#kubectl获取pv

NAME               CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM   STORAGECLASS    REASON   AGE
example-local-pv   1Gi        RWO            Retain           Available           local-storage            76s

[root @ localhost docker]#kubectl获取pvc

NAME                  STATUS    VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS    AGE
example-local-claim   Pending                                      local-storage   75s

0 个答案:

没有答案