apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: kube-gelf-reload-config
  namespace: kube-system
spec:
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 1
  schedule: "*/30 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: kube-gelf
          containers:
          - name: cron
            image: roffe/kubectl:v1.9.1
            args:
            - /bin/sh
            - -c
            - for POD in $( kubectl get pods --namespace kube-system --selector app=kube-gelf --output jsonpath='{.items[*].metadata.name}'); do echo RELOAD ${POD}; kubectl exec --namespace kube-system ${POD} -- /bin/sh -c "ps aux|grep '/usr/bin/ruby2.5 /usr/local/bin/fluentd' | grep -v grep | awk {'print \$2'} | xargs kill -1"; done
          restartPolicy: Never
