---
apiVersion: v1
kind: Pod
metadata:
  name: testrunner
  labels:
    name: testrunner
spec:
  terminationGracePeriodSeconds: 60
  containers:
  - name: testrunner
    readinessProbe:
      exec:
        command:
        - "/bin/bash"
        - "-c"
        - "/opt/eap/bin/readinessProbe.sh"
      initialDelaySeconds: 60
      timeoutSeconds: 10
      periodSeconds: 20
      successThreshold: 2
      failureThreshold: 5
    image: "${DOCKER_REGISTRY_REDHAT}jboss-eap-7/eap71-openshift:1.3-10"
    ports:
    - containerPort: 8080
      protocol: TCP
    - containerPort: 9990
      protocol: TCP
    - containerPort: 9999
      protocol: TCP
    - containerPort: 8787
      protocol: TCP
    env:
    - name: ADMIN_USERNAME
      value: admin
    - name: ADMIN_PASSWORD
      value: Admin#70365
    - name: KUBERNETES_AUTH_TOKEN
      value: "${kubernetes.auth.token}"
    - name: DEBUG
      value: 'true'
    volumeMounts:
    - name: truststore-volume
      mountPath: "/var/run/secrets/java.io/keystores"
  initContainers:
  - name: pem-to-truststore
    image: "${image}"
    env:
    - name: CA_BUNDLE
      value: "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
    - name: TRUSTSTORE_FILE
      value: "/var/run/secrets/java.io/keystores/truststore.p12"
    - name: TRUSTSTORE_PASSWORD
      value: test99
    command:
    - "/bin/bash"
    args:
    - "-c"
    - rm -f $TRUSTSTORE_FILE && csplit -z -f crt- $CA_BUNDLE '/-----BEGIN CERTIFICATE-----/'
      '{*}' && for file in crt-*; do keytool -import -noprompt -storetype pkcs12 -keystore
      $TRUSTSTORE_FILE -file $file -storepass $TRUSTSTORE_PASSWORD -alias service-$file;
      done
    volumeMounts:
    - name: truststore-volume
      mountPath: "/var/run/secrets/java.io/keystores"
  volumes:
  - name: truststore-volume
    emptyDir: {}
