---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: app-namespace
  labels:
    name: app-namespace
rules:
- apiGroups: ["*"]
  resources: ["*"]
  verbs: ["*"]

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: app-namespace
  namespace: app-namespace
  labels:
    name: app-namespace

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: app-namespace
  labels:
    name: app-namespace
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: app-namespace
subjects:
- kind: ServiceAccount
  name: app-namespace
  namespace: app-namespace

---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: busybox-liveness-
  namespace: app-namespace
spec:
  template:
    metadata:
      name: busybox-liveness
      namespace: app-namespace
      labels:
        liveness: busybox-liveness

        # label used for mass-liveness check upon infra-chaos
        infra-aid: liveness

    spec:
      serviceAccountName: app-namespace
      restartPolicy: Never
 
      containers:
      - name: busybox-liveness  
        image: openebs/busybox-client
        imagePullPolicy: Always

        env:
          - name: LIVENESS_TIMEOUT_SECONDS
            value: "liveness-timeout-seconds"

            # number of retries when livenss-fails 
          - name: LIVENESS_RETRY_COUNT
            value: "liveness-retry-count"

            # Namespace in which busybox is running
          - name: NAMESPACE
            value: app-namespace 

          - name: POD_NAME
            value: pod-name   

        command: ["/bin/bash"]
        args: ["-c", "./liveness.sh; exit 0"]