在GKE中将就绪的SSD挂载到Pod

时间:2018-08-07 05:10:41

标签: google-kubernetes-engine persistent-storage

我将运行具有持久性SSD的Pod。我已经准备好了磁盘(从快照创建) 我想将此磁盘连接到Pod。到目前为止,我一直以这种方式创建pod

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: geth-stateful
  namespace: dev
spec:
  serviceName: geth-dev-service
  replicas: 2
  selector:
    matchLabels:
      app: geth-node
  template:
    metadata:
      labels:
        app: geth-node
    spec:
      containers:
      - name: geth-node
        image: asia.gcr.io/indiesquare-dev/geth-node:v1.8.12
        ports:
        volumeMounts:
        - name: geth-chaindata
          mountPath: /var/tmp
        resources:
          requests:
            memory: "13Gi"
            cpu: "5000m"
          limits:
            memory: "14Gi"
            cpu: "5500m"   
  volumeClaimTemplates:
  - metadata:
      name: geth-chaindata
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: fast
      resources:
        requests:
          storage: 500Gi

但是,这始终会创建一个新磁盘。有没有办法将现有磁盘提供为volumeMounts

1 个答案:

答案 0 :(得分:0)

如果您在未首先在GKE上拥有PVC的情况下声明了一个卷,则Google Cloud Platform每次都会为您提供一个新磁盘来满足要求。

由于已经创建并准备好磁盘,因此要配置Persistent Volume first that uses the preexisting disk和持久卷声明以使用它。