Skip to content
Kuberenets Job/CronJob Notifier
Go Dockerfile
Branch: master
Clone or download
Latest commit 8d8a5ec Nov 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
env add dockerfile Nov 26, 2019
message fix nil map assign issue Nov 27, 2019
slack fix same job name issue by calcing hash Nov 28, 2019
.deepsource.toml Create .deepsource.toml Nov 28, 2019
.gitignore remove binary file Nov 28, 2019
Dockerfile add dockerfile Nov 26, 2019
LICENSE Create LICENSE Nov 27, 2019
README.md Update README.md Nov 28, 2019
go.mod fix same job name issue by calcing hash Nov 28, 2019
go.sum fix same job name issue by calcing hash Nov 28, 2019
main.go fix comments Nov 28, 2019

README.md

Kubernetes Job/CronJob Notifier

GitHub followers Twitter URL

DeepSource

GoReport Docker Pulls GitHub commit activity

This tool sends an alert to slack whenever there is a Kubernetes cronJob/Job failure/success.

No extra setup required to deploy this tool on to your cluster, just apply below K8s deploy manifest 🎉

This uses InClusterConfig for accessing Kubernetes API.

Limitations

  • Namespace scoped i.e., each namespace should have this deploy separately
  • All the jobs in the namespace are fetched and verified for failures
    • Will add support for selectors in future 📋

Development

If you wish to run this locally, clone this repository, set webhook and namespace env variables. This expects kube config to be in ~/.kube/config (default)

$ export webhook="slack_webhook_url" && export namespace="<namespace_name>" && go build &&  ./k8s-job-notify

Docker 🐳

Docker images are hosted at hub.docker/k8s-job-notify

Releases

  • If you want to use stable releases, please use github release tags. For example, image: sukeesh/k8s-job-notify:1.0
  • If you wish to use unstable, use image: sukeesh/k8s-job-notify:beta (triggered whenever push to master is made)

To start using this

Create and apply below kubernetes deployment in your cluster

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: kjn
  name: k8s-job-notify
  namespace: <namespace_name>
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kjn
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "false"
      labels:
        app: kjn
    spec:
      restartPolicy: Never  
      containers:
      - env:
        - name: webhook
          value: <slack_webhook_url> # creating a secret for this var is recommended
        - name: namespace
          valueFrom:
            fieldRef:
                fieldPath: metadata.namespace
        - name: incluster
          value: "1"
        image: sukeesh/k8s-job-notify:<tag>
        name: k8s-job-notify
        resources:
          limits:
            cpu: 500m
            memory: 256Mi
          requests:
            cpu: 500m
            memory: 128Mi

Contributing 🤝

Contributions, issues and feature requests are welcome.

Author

👤 Sukeesh

Please feel free to ⭐️ this repository if this project helped you! 😉

📝 License

Copyright © 2019 Sukeesh.
This project is MIT licensed.

You can’t perform that action at this time.