apiVersion: apps/v1
kind: Deployment
metadata:
  name: datamon-coord-demo
  namespace: datamon-ci
spec:
  selector:
    matchLabels:
      app: datamon-coord-demo
  replicas: 1
  template:
    metadata:
      labels:
        app: datamon-coord-demo
    spec:
      initContainers:
      - name: init-application-wrap
        image: gcr.io/onec-co/datamon-fuse-demo-coord-datamon:latest
        imagePullPolicy: "$PULL_POLICY"
        command: ["sh", "-c", "mkdir /tmp/coord/.scripts; cp wrap_application.sh /tmp/coord/.scripts/wrap_application.sh; chmod a+x /tmp/coord/.scripts/wrap_application.sh; echo 'placed application wrapper'"]
        stdin: true
        tty: true
        volumeMounts:
        - mountPath: /tmp/coord
          name: container-coord
      containers:
      - name: demo-app
        image: gcr.io/onec-co/datamon-fuse-demo-coord-app:latest
        imagePullPolicy: "$PULL_POLICY"
        command: ["/bin/zsh"]
        args: ["-i"]
        stdin: true
        tty: true
        volumeMounts:
        - mountPath: /tmp/coord
          name: container-coord
        - mountPath: /tmp/upload
          name: upload-source
        - mountPath: /tmp/mount
          name: fuse-mountpoint
          mountPropagation: "HostToContainer"

      - name: datamon-sidecar
        image: gcr.io/onec-co/datamon-fuse-demo-coord-datamon:latest
        imagePullPolicy: "$PULL_POLICY"
        command: ["/bin/zsh"]
        args: ["-i"]
        securityContext:
          # allows FUSE access on gke, docker-desktop
          # (with sudo for the latter)
          privileged: true
        stdin: true
        tty: true
        volumeMounts:
        - mountPath: /tmp/coord
          name: container-coord
        - mountPath: /tmp/upload
          name: upload-source
        - mountPath: /tmp/mount
          name: fuse-mountpoint
          mountPropagation: "Bidirectional"
# pass credentials via environment variable in Circle-CI
        - mountPath: /tmp/gac
          name: google-application-credentials
        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /tmp/gac/google-application-credentials.json

        - name: dm_fuse_params
          value: /fuse-params.yaml

#
      volumes:
      - name: fuse-mountpoint
        emptyDir: {}
      - name: container-coord
        emptyDir: {}
      - name: upload-source
        emptyDir: {}
      - name: google-application-credentials
        secret:
          secretName: google-application-credentials
