apiVersion: apps/v1
kind: Deployment
metadata:
  name: ffmpeg-worker
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ffmpeg-worker
  template:
    metadata:
      labels:
        annotations:
          cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
        app: ffmpeg-worker
    spec:
      containers:
      - name: ffmpeg-worker
        # Replace $GCLOUD_PROJECT with your project ID
        image: gcr.io/$GCLOUD_PROJECT/ffmpeg-worker:latest
        volumeMounts:
        - mountPath: /buckets/
          name: buckets
          mountPropagation: HostToContainer
        ports:
        - containerPort: 8080
      - name: esp
        image: gcr.io/endpoints-release/endpoints-runtime:1
        args: [
          "--http2_port=9000",
          # Replace $GCLOUD_PROJECT with your project ID
          "--service=ffmpeg.endpoints.$GCLOUD_PROJECT.cloud.goog",
          "--rollout_strategy=managed",
          "--backend=grpc://127.0.0.1:8080",
          "--service_account_key=/etc/nginx/creds/service-account-creds.json"
        ]
        volumeMounts:
        - mountPath: /etc/nginx/creds
          name: service-account-creds
          readOnly: true
      volumes:
      - name: buckets
        hostPath:
          path: /home/buckets/
          type: Directory
      - name: service-account-creds
        secret:
          secretName: service-account-creds

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ffmpeg-worker
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ffmpeg-worker
  template:
    metadata:
      labels:
        annotations:
          cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
        app: ffmpeg-worker
    spec:
      containers:
      - name: ffmpeg-worker
        # Replace $GCLOUD_PROJECT with your project ID
        image: gcr.io/$GCLOUD_PROJECT/ffmpeg-worker:latest
        volumeMounts:
        - mountPath: /buckets/
          name: buckets
          mountPropagation: HostToContainer
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "512Mi"
            cpu: "500m"
          limits:
            memory: "4096Mi"
            cpu: "1000m"
      - name: esp
        image: gcr.io/endpoints-release/endpoints-runtime:1
        args: [
          "--http2_port=9000",
          # Replace $GCLOUD_PROJECT with your project ID
          "--service=ffmpeg.endpoints.$GCLOUD_PROJECT.cloud.goog",
          "--rollout_strategy=managed",
          "--backend=grpc://127.0.0.1:8080",
          "--service_account_key=/etc/nginx/creds/service-account-creds.json"
        ]
        volumeMounts:
        - mountPath: /etc/nginx/creds
          name: service-account-creds
          readOnly: true
      volumes:
      - name: buckets
        hostPath:
          path: /home/buckets/
          type: Directory
      - name: service-account-creds
        secret:
          secretName: service-account-creds

Set resource limits for ffmpeg-worker container.
Set resource limits for ffmpeg-worker container.

These resource limits prevent the container from taking too many
resources which causes node failure.
