I am trying to use gcs bucket as the volume in gke pod

12,868

Your Deployment object looks correct using name and path as keys. You can see an example on how to mount a GCS bucket on kubernetes here

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: gcsfuse-test
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: gcsfuse-test
    spec:
      containers:
        - name: gcsfuse-test
          image: gcr.io/some-repo/gcs-fuse:latest
          securityContext:
            privileged: true
            capabilities:
              add:
                - SYS_ADMIN
          lifecycle:
            postStart:
              exec:
                command: ["gcsfuse", "-o", "nonempty", "some-bucket", "/mnt/some-bucket"]
            preStop:
              exec:
                command: ["fusermount", "-u", "/mnt/some-bucket"]

This Stack Overflow question might help too.

Share:
12,868
Ram
Author by

Ram

Updated on July 25, 2022

Comments

  • Ram
    Ram almost 2 years

    I am getting the error:

    error validating "mysql.yaml": error validating data: ValidationError(Deployment.spec.template.spec.volumes[0]): unknown field "path" in io.k8s.kubernetes.pkg.api.v1.Volume; )

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: mysql
      labels:
        app: mysql
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: mysql
      template:
        metadata:
          labels:
            app: mysql
        spec:
          containers:
            - image: mysql:5.6
              name: mysql
              env:
                - name: MYSQL_ROOT_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: mysql
                      key: password
              ports:
                - containerPort: 3306
                  name: mysql
              volumeMounts:
                - name: mapping-sandbox-test
                  mountPath: /var/lib/mysql
          volumes:
            - name: mapping-sandbox-test
              path: gs://<bucket-name>
    
  • Ram
    Ram over 6 years
    I tried this but I did am getting CrashLoopBackOff error. I used the same Dockerfile and I replaced bucket with my bucket. My container has complete access to the bucket as well. please check this file once.
  • Jose Armesto
    Jose Armesto over 6 years
    what's the output for kubectl describe pod <podname> ?