apiVersion: apps/v1
kind: Deployment
metadata:
  name: pod-watcher
  labels:
    app: pod-watcher
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pod-watcher
  template:
    metadata:
      labels:
        app: pod-watcher
    spec:
      containers:
      - name: pod-watcher
        image: hirokimatsumoto/kubernetes-pod-watch:1.0.0
        command: ["/bin/sh" ,"-c"]
        args:
        - 'kubectl get pod -A -w
          | grep -v -E "^(NAMESPACE|kube-system).*" --line-buffered
          | xargs -I{} curl -s -X POST --data-urlencode
              "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"POD WATCHER\", \"text\": \"{}\"}"
              ${SLACK_URL};'
        imagePullPolicy: IfNotPresent
        env:
        - name: SLACK_URL
          value: "https://hooks.slack.com/services/XXXXX/XXXXXXXXXXXXXX"
        - name: SLACK_CHANNEL
          value: "#XXXXXX"
      terminationGracePeriodSeconds: 1




