This project provides a Rust-based custom resource and controller for Kubernetes. It introduces a custom resource, PodMonitor, which sends email notifications or triggers webhook upon pod failures.
Apply the Kubernetes YAML configuration to set up the necessary components, including the namespace, service account, cluster role, role binding, and controller deployment:
Use PodMonitor.yaml from release
kubectl apply -f PodMonitor.yaml
Alternatively, you can run the Rust code directly:
nohup RUST_LOG=info cargo run &
Or use the precompiled binary:
nohup RUST_LOG=info ./binary/podmon &
Once the controller is running, it will automatically create the CRD and operate in the background to manage instances of the custom resource.
Define a new instance of the PodMonitor custom resource using the following YAML template:
apiVersion: "kk.dev/v1"
kind: PodMonitor
metadata:
name: mymonitor
spec:
target_pods:
- pod1
- pod2
mail:
from: "sender"
to: "receiver"
smtp_server: 127.0.0.1
smtp_port: 25
tls: "false"
username: "username"
password: "password"
webhook:
url: "http://127.0.0.1/"
target_pods is optional and if not defined will monitor all the pods in namespacess The username and password fields are optional and depend on your SMTP server's configuration.
Optional Fields: mail, webhook, target_pods
Optional Fields [mail]: username, password
Whenever a pod fails in the specified namespace, you will receive an email notification according to the configuration set in the PodMonitor instance.
- ✔️ Monitor Pod within a target namespace
- ✔️ Monitor specific or all pods in a namespace
- ✔️ Trigger Email on pod failure
- ✔️ TSL option ("true", "false") and Authentication to smtp server
- ✔️ Trigger webhook url with data using post request on pod failure
- Enable use of kubernetes secret
- Enable authentication to webhook
- Enable
Kubectl logs podmonitor
This project is licensed under the MIT License. See LICENSE for details.