This project provides a Rust-based custom resource and controller for Kubernetes. It introduces a custom resource, PodMonitor, which sends email notifications 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:
name: mymonitor
target_namespace: mynamespace
smtp_server: 127.0.0.1
smtp_port: 25
mail_to: user1@example.com
mail_from: user2@example.com
username: user
password: pass
Note: The username and password fields are optional and depend on your SMTP server's configuration.
apiVersion: "kk.dev/v1"
kind: PodMonitor
metadata:
name: mymonitor
spec:
name: mymonitor
target_namespace: mynamespace
smtp_server: 127.0.0.1
smtp_port: 25
mail_to: user1@example.com
mail_from: user2@example.com
Whenever a pod fails in the specified namespace, you will receive an email notification according to the configuration set in the PodMonitor instance.
This project is licensed under the MIT License. See LICENSE for details.