apiVersion: v1
kind: ConfigMap
metadata:
  name: test-script
data:
  test.sh: |
    #!/bin/bash
    ACTIVE=true
    
    if [ -z "$DELAY" ]
    then
      DELAY=15
    fi

    wait_exit() {
      echo "Waiting $DELAY to exit: $(date)"
      sleep $DELAY
      echo "Exiting $(date)"
      ACTIVE=false
    }

    trap wait_exit SIGINT SIGTERM

    echo "Starting..."

    while $ACTIVE; do 
      # echo "Waiting"
      sleep 5
    done
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: wait-pod
spec:
  selector:
    matchLabels:
      test1: wait-pod
  template:
    metadata:
      labels:
        test1: wait-pod
    spec:
      nodeSelector:
        node-role.kubernetes.io/worker: ''
      volumes:
        - name: test-script
          configMap:
           name: test-script
           defaultMode: 0777
      containers:
        - name: tester
          #image: centos
          image: image-registry.openshift-image-registry.svc:5000/openshift/tests:latest
          volumeMounts:
            - name: test-script
              mountPath: /script
          command: ["/script/test.sh"]
          env:
            - name: DELAY
              value: '20'