0

gcePersistentDiskkubernetes. 目前我所有的虚拟机,磁盘都在相同的可用区和帐户下google cloud。但仍然gcePersistentDisk没有安装。下面是我的部署文件。

储藏室

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ssd-sc 
provisioner: kubernetes.io/gce-pd
reclaimPolicy: Retain # Retain storage even if we delete PVC
parameters:
  type: pd-ssd 

体积

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ssd-sc
  resources:
    requests:
      storage: 10Gi

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
spec:
  storageClassName: ssd-sc
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  gcePersistentDisk:
    pdName: nfs-disk
    fsType: ext4  

服务和容器

   apiVersion: apps/v1 
kind: Deployment
metadata:
  name: apache-service
spec:
  selector:
    matchLabels:
      app: apache
  replicas: 1 
  template:
    metadata:
      labels:
        app: apache
    spec:
     volumes:
      - name: service-pv-storage
        gcePersistentDisk:
          pdName: nfs-disk
          fsType: ext4  
     containers:
      - name: apache
        image: mobingi/ubuntu-apache2-php7:7.2
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: "/var/www/html"
          name: service-pv-storage

---
apiVersion: v1
kind: Service
metadata:
  name: apache-service
spec:
  selector:
    app: apache
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
    nodePort: 30751
  type: NodePort

当我使用此部署时,它会在 pod 描述上出现以下错误。

在此处输入图像描述

注意:-我没有使用kubernetes谷歌引擎。我已经设置了我的自定义集群。

4

0 回答 0