docs icon indicating copy to clipboard operation
docs copied to clipboard

Document Goofys Usage with Kubernetes

Open osterman opened this issue 7 years ago • 4 comments

what

  • Document how to use goofys as a sidecar container in kubernetes

why

  • Useful for certain kinds of services that simple object storage but only work with POSIX-style filesystems

example

apiVersion: v1
kind: Pod
metadata:
  name: example
spec:
  restartPolicy: Never
  imagePullSecrets:
    - name: dockercfg
  volumes:
  - name: s3-mount
    emptyDir: {}

  containers:
  - name: nginx-container
    image: nginx
    volumeMounts:
    - mountPath: /data:slave
      name: s3-mount
      mountPropagation: Bidirectional      

  - name: goofys
    env:
    - name: MOUNT_DIR
      value: /vortex-artifacts
    - name: BUCKET
      value: eg-example-data
    - name: REGION
      value: us-west-2
    - name: DIR_MODE
      value: "0777"
    - name: FILE_MODE
      value: "0777"
    image: cloudposse/goofys
    imagePullPolicy: Always
    resources: {}
    securityContext:
      privileged: true
      runAsUser: 0
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /data:shared
      name: s3-mount
      mountPropagation: Bidirectional

osterman avatar May 24 '18 00:05 osterman

Thank you for this :)

chrissound avatar May 30 '19 22:05 chrissound

Is there maybe a specific API version I should be referencing? v1 does not seem to work for a deployment. And with apps/v1 I keep getting an error of Error: Error response from daemon: invalid volume specification: '/var/lib/kubelet/pods/19d006ba-832f-11e9-9901-be858c5f860b/volumes/kubernetes.io~empty-dir/s3-mount:/data:shared:rshared'.

chrissound avatar May 30 '19 23:05 chrissound

Not sure - it's been a while since we looked into this. I think we might have been on kubernetes 1.8-1.10 at the time.

osterman avatar May 30 '19 23:05 osterman

I know it's been years, but in case somebody sees it: @chrissound's problem can be gotten around with:

---
spec:
  containers: 
    - name: app
      resources: {}
      volumeMounts:
        - mountPath: /mnt/s3
          mountPropagation: HostToContainer
          name: s3-mount
    - command:
        - env
        - "--unset=REGION"
        - goofys
        - "-f"
        - $BUCKET_NAME
        - /mnt/s3
      image: cloudposse/goofys
      imagePullPolicy: Always
      name: goofys
      resources: {}
      securityContext:
        privileged: true
        runAsUser: 0
      terminationMessagePath: /dev/termination-log
      terminationMessagePolicy: File
      volumeMounts:
        - mountPath: /mnt/s3
          mountPropagation: Bidirectional
          name: s3-mount
  volumes:
    - emptyDir: {}
      name: s3-mount

jcaesar avatar Nov 25 '22 05:11 jcaesar