apiVersion: apps/v1
kind: Deployment
metadata:
  name: testsuite
  namespace: family
spec:
  replicas: 1
  selector:
    matchLabels:
      app:  testsuite
  template:
    metadata:
      labels:
        app:  testsuite
    spec:
      hostAliases:
      - ip: "192.168.0.100"
        hostnames:
        - "frontend.kieni.at"
      volumes:
      - name: testsuite-storage
        emptyDir: {}
      - name: dshm
        emptyDir:
          medium: Memory
      initContainers:
      - name: wait-for-gui
        image: stefanevinance/wait-for-200
        env:
          - name: TIMEOUT
            value: '5'
          - name: URL
            valueFrom:
              configMapKeyRef:
                name: family-config
                key: GUI_URL
        imagePullPolicy: IfNotPresent
      - name:  testsuite
        image: luke19/familytestsuite:7.0
        imagePullPolicy: IfNotPresent
        volumeMounts:
        - name: testsuite-storage
          mountPath: /report
        - name: dshm
          mountPath: /dev/shm
        env:
        - name: TZ
          valueFrom:
            configMapKeyRef:
              name: family-config
              key: TZ
        - name: PROJECT_NAME
          valueFrom:
            configMapKeyRef:
              name: family-config
              key: PROJECT_NAME
        - name: URL
          valueFrom:
            configMapKeyRef:
              name: family-config
              key: GUI_URL
        - name: TAKE_SCREENSHOTS
          valueFrom:
            configMapKeyRef:
              name: family-config
              key: TAKE_SCREENSHOTS
        - name: TA_USERNAME
          valueFrom:
            secretKeyRef:
              name: family-secret
              key: TA_USERNAME
        - name: TA_PASSWORD
          valueFrom:
            secretKeyRef:
              name: family-secret
              key: TA_PASSWORD
        - name: TA_SECRET
          valueFrom:
            secretKeyRef:
              name: family-secret
              key: TA_SECRET
      containers:
      - name:  testsuite-webserver
        image: twalter/openshift-nginx:stable
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            memory: 1000Mi
            cpu: 1000m
          requests:
            memory: 100Mi
            cpu: 150m
        env:
        - name: TZ
          valueFrom:
            configMapKeyRef:
              name: family-config
              key: TZ
        ports:
        - containerPort: 8081 #Expose containerport to the pod
        livenessProbe: #Check that pod is ready
          httpGet:
            path: / #path to check
            port: 8081
          initialDelaySeconds: 10 #start checking after 30 seconds
          periodSeconds: 10 #check every 30 seconds
          failureThreshold: 10
        readinessProbe: #Check that pod is healthy
          httpGet:
            path: / #path to check
            port: 8081 #port to check
          initialDelaySeconds: 15 #start checking after 15 seconds
          periodSeconds: 10 #check every 3 seconds
          failureThreshold: 10
        volumeMounts:
        - name: testsuite-storage
          mountPath: /usr/share/nginx/html
        - name: dshm
          mountPath: /dev/shm