---
apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: cdi-file-host
  namespace: cdi
  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: kubevirt/cdi-func-test-file-host-init:v1.9.2
        imagePullPolicy: IfNotPresent
        args: ["-certDir", "/tmp/shared/certs", "-inFile", "/tmp/source/tinyCore.iso", "-outDir", "/tmp/shared/images"]
        volumeMounts:
        - name: "images"
          mountPath: "/tmp/shared"
      containers:
      - name: http
        image: kubevirt/cdi-func-test-file-host-http:v1.9.2
        imagePullPolicy: IfNotPresent
        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: IfNotPresent
        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
  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
