---
apiVersion: v1
kind: Service
metadata:
  name: cdi-http-import-server
  namespace: kubevirt
  labels:
    kubevirt.io: "cdi-http-import-server"
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  selector:
    kubevirt.io: cdi-http-import-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cdi-http-import-server
  namespace: kubevirt
  labels:
    kubevirt.io: "cdi-http-import-server"
spec:
  selector:
    matchLabels:
      kubevirt.io: "cdi-http-import-server"
  replicas: 1
  template:
    metadata:
      labels:
        kubevirt.io: cdi-http-import-server
    spec:
      serviceAccountName: kubevirt-testing
      containers:
        - name: cdi-http-import-server
          image: quay.io/kubevirt/cdi-http-import-server:v0.45.0
          imagePullPolicy: Always
          ports:
            - containerPort: 80
              name: "http"
              protocol: "TCP"
          readinessProbe:
            tcpSocket:
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: disks-images-provider
  namespace: kubevirt
  labels:
    kubevirt.io: "disks-images-provider"
spec:
  selector:
    matchLabels:
      kubevirt.io: "disks-images-provider"
  template:
    metadata:
      labels:
        name: disks-images-provider
        kubevirt.io: disks-images-provider
      name: disks-images-provider
    spec:
      serviceAccountName: kubevirt-testing
      containers:
        - name: target
          image: quay.io/kubevirt/disks-images-provider:v0.45.0
          imagePullPolicy: Always
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh","-c","source /etc/bashrc && losetup -d ${LOOP_DEVICE}"]
          volumeMounts:
          - name: images
            mountPath: /hostImages
          - name: local-storage
            mountPath: /local-storage
          securityContext:
            privileged: true
          readinessProbe:
            exec:
              command:
              - cat
              - /ready
            initialDelaySeconds: 10
            periodSeconds: 5
      volumes:
        - name: images
          hostPath:
            path: /tmp/hostImages
            type: DirectoryOrCreate
        - name: local-storage
          hostPath:
            path: /mnt/local-storage
            type: DirectoryOrCreate
