# chaoskube can stop after some time. This can be done
# if it is deployed as a Job and having --max-runtime set as well
apiVersion: batch/v1
kind: Job
metadata:
  name: chaoskube
  labels:
    app: chaoskube
spec:
  template:
    metadata:
      labels:
        app: chaoskube
    spec:
      restartPolicy: Never
      serviceAccountName: chaoskube
      containers:
      - name: chaoskube
        image: quay.io/linki/chaoskube:v0.22.0
        args:
        # kill a pod every 10 minutes
        - --interval=10m
        # only target pods in the test environment
        - --labels=environment=test
        # only consider pods with this annotation
        - --annotations=chaos.alpha.kubernetes.io/enabled=true
        # exclude all DaemonSet pods
        - --kinds=!DaemonSet
        # exclude all pods in the kube-system namespace
        - --namespaces=!kube-system
        # don't kill anything on weekends
        - --excluded-weekdays=Sat,Sun
        # don't kill anything during the night or at lunchtime
        - --excluded-times-of-day=22:00-08:00,11:00-13:00
        # don't kill anything as a joke or on christmas eve
        - --excluded-days-of-year=Apr1,Dec24
        # let's make sure we all agree on what the above times mean
        - --timezone=UTC
        # exclude all pods that haven't been running for at least one hour
        - --minimum-age=1h
        # terminate pods for real: this disables dry-run mode which is on by default
        - --no-dry-run
        # if set, chaoskube will exit after the max runtime
        - --max-runtime=3600s
        securityContext:
          runAsNonRoot: true
          runAsUser: 65534
          readOnlyRootFilesystem: true
          capabilities:
            drop: ["ALL"]
