---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: cdi-file-host
  namespace: {{ cdi_namespace }}
  labels:
    cdi.kubevirt.io/testing: ""
spec:
  selector:
    matchLabels:
      name: cdi-file-host
  replicas: 1
  template:
    metadata:
      labels:
        name: cdi-file-host
        cdi.kubevirt.io/testing: ""
    spec:
      securityContext:
        runAsUser: 0
      serviceAccountName: cdi-sa
      initContainers:
      - name: init
        image: {{ docker_prefix }}/cdi-func-test-file-host-init:{{ docker_tag }}
        imagePullPolicy: {{ pull_policy }}
        args: ["-certDir", "/tmp/shared/certs", "-inFile", "/tmp/source/tinyCore.iso", "-outDir", "/tmp/shared/images"]
        volumeMounts:
        - name: "images"
          mountPath: "/tmp/shared"
      containers:
      - name: http
        image: {{ docker_prefix }}/cdi-func-test-file-host-http:{{ docker_tag }}
        imagePullPolicy: {{ pull_policy }}
        command: ["/usr/sbin/nginx"]
        ports:
        - name: http-no-auth
          containerPort: 80
        - name: http-auth
          containerPort: 81
        - name: rate-limit
          containerPort: 82
        volumeMounts:
        - name: "images"
          mountPath: "/tmp/shared/"
        readinessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 20
          periodSeconds: 20
        livenessProbe:
          httpGet:
            path: /
            port: 80
          initialDelaySeconds: 20
          periodSeconds: 20
      - name: s3
        image: minio/minio:RELEASE.2018-08-02T23-11-36Z
        imagePullPolicy: {{ pull_policy }}
        env:
        - name: MINIO_ACCESS_KEY
          value: "admin"
        - name: MINIO_SECRET_KEY
          value: "password"
        args: ["server", "--address", ":9000", "/tmp/shared"]
        volumeMounts:
        - name: "images"
          mountPath: "/tmp/shared"
        readinessProbe:
          httpGet:
            path: /minio/health/ready
            port: 9000
          initialDelaySeconds: 20
          periodSeconds: 20
        livenessProbe:
          httpGet:
            path: /minio/health/live
            port: 9000
          initialDelaySeconds: 20
          periodSeconds: 20
      volumes:
      - name: "images"
        emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: cdi-file-host
  namespace: {{ cdi_namespace }}
  labels:
    cdi.kubevirt.io/testing: ""
spec:
  selector:
      name: cdi-file-host
  type: NodePort
  ports:
  - name: rate-limit
    port: 82
    targetPort: 82
  - name: http-auth
    port: 81
    targetPort: 81
  - name: http-no-auth
    port: 80
    targetPort: 80
  - name: s3
    port: 9000
    targetPort: 9000
  - name: tls
    port: 443
    targetPort: 443
