---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cdi-file-host
  namespace: {{ .Namespace }}
  labels:
    cdi.kubevirt.io/testing: ""
spec:
  strategy:
    type: Recreate
  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-testing-sa
      initContainers:
      - name: init
        image: {{ .DockerRepo }}/cdi-func-test-file-host-init:{{ .DockerTag }}
        imagePullPolicy: {{ .PullPolicy }}
        args: ["-certDir", "/tmp/shared/certs", "-inFile", "/tmp/source/tinyCore.iso", "-outDir", "/tmp/shared/images"]
        volumeMounts:
        - name: "images"
          mountPath: "/tmp/shared"
      containers:
      - name: http
        image: {{ .DockerRepo }}/cdi-func-test-file-host-http:{{ .DockerTag }}
        imagePullPolicy: {{ .PullPolicy }}
        command: ["/usr/sbin/nginx"]
        ports:
        - name: http-no-auth
          containerPort: 80
        - name: http-auth
          containerPort: 81
        - name: rate-limit
          containerPort: 82
        - name: https-auth
          containerPort: 444
        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: quay.io/kubevirt/minio:RELEASE.2024-10-02T17-50-41Z
        imagePullPolicy: {{ .PullPolicy }}
        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: {{ .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
  - name: tls-auth
    port: 444
    targetPort: 444
  - name: rate-limit-registry-proxy
    port: 83
    targetPort: 83
