!!! This project was created with a single goal: to learn how to use CRDs in Kubernetes to store an application's state in Kubernetes' own etcd and have it manage everything autonomously. The chosen idea was to develop a notification application.
ArgoCD Notifier is a Kubernetes-based application that monitors ArgoCD applications for state changes and sends notifications to a specified Telegram chat. Notifications include details about new applications, updates to existing applications, and deletions.
- Monitors ArgoCD applications for:
- Newly added applications.
- State changes (e.g.,
Sync
andHealth
statuses). - Deleted applications.
- Sends real-time notifications to a Telegram chat.
- Stores state information in a Custom Resource Definition (CRD).
- Kubernetes cluster with ArgoCD installed.
- Helm installed on your local machine.
- Telegram bot token and chat ID for receiving notifications.
kubectl
configured to interact with your Kubernetes cluster.
git clone <repository-url>
cd argocd-notifier
Customize the configuration:
image:
repository: alexshnup/argocd-notifier
tag: latest
pullPolicy: IfNotPresent
env:
ARGOCD_SERVER: "https://your-argocd-server"
ARGOCD_TOKEN: "your-argocd-token"
TELEGRAM_BOT_TOKEN: "your-telegram-bot-token"
TELEGRAM_CHAT_ID: "your-telegram-chat-id"
resources: {}
Run the following command:
helm upgrade --install argocd-notifier ./helm --namespace argocd -f values.yml
- Monitoring Applications: The application continuously polls the ArgoCD API for the list of applications and their states (
Sync
andHealth
). - State Comparison: Current states are compared with the saved states stored in the CRD.
- Notification Trigger: If a state change is detected (new application, update, or deletion), a Telegram message is sent.
- State Persistence: The application saves the latest state in the Kubernetes CRD to ensure continuity after restarts.
The state is stored in a Kubernetes CRD. Below is the structure:
apiVersion: argocd-notifier.example.com/v1
kind: Notifier
metadata:
name: argocd-notifier-state
namespace: argocd
spec:
state: {}
Check logs for debugging:
kubectl logs -n argocd pod/argocd-notifier-<pod-id>
-
Forbidden Error for CRD: Ensure the correct RBAC rules are applied:
kubectl apply -f helm/templates/role.yaml kubectl apply -f helm/templates/rolebinding.yaml
-
Telegram Notifications Not Working:
- Check the Telegram bot token and chat ID.
- Ensure the Telegram API is accessible from the cluster.
-
Missing Applications in Notifications:
- Verify the ArgoCD server and token configuration in
values.yml
.
- Verify the ArgoCD server and token configuration in
Contributions are welcome! Feel free to submit issues or create pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.