Skip to content

Commit af90ea9

Browse files
committed
Add cluster name setup script and update notifications config for ArgoCD
1 parent f7d364e commit af90ea9

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

.github/argocd/argocd-notifications-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ metadata:
44
name: argocd-notifications-cm
55
namespace: argocd
66
data:
7+
# Cluster name - set this to your cluster context name
8+
# You can set this automatically with: kubectl patch configmap argocd-notifications-cm -n argocd -p "{\"data\":{\"cluster-name\":\"$(kubectl config current-context)\"}}"
9+
cluster-name: "CLUSTER_NAME_PLACEHOLDER"
10+
711
# GitHub webhook service configuration
812
service.webhook.github-webhook: |
913
url: https://api.github.com/repos/DevExpGbb/agentic-platform-engineering/dispatches
@@ -42,7 +46,7 @@ data:
4246
"message": "{{.app.status.operationState.message}}",
4347
"revision": "{{.app.status.sync.revision}}",
4448
"repo_url": "{{.app.spec.source.repoURL}}",
45-
"cluster": "{{.app.spec.destination.server}}",
49+
"cluster": "$cluster-name",
4650
"namespace": "{{.app.spec.destination.namespace}}",
4751
"timestamp": "{{.app.status.operationState.finishedAt}}",
4852
"resources": {{toJson .app.status.resources}}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Run this script once when ArgoCD is installed to set the cluster name
3+
# Usage: ./setup-cluster-name.sh
4+
5+
set -e
6+
7+
CLUSTER_NAME=$(kubectl config current-context)
8+
9+
echo "Setting cluster name in ArgoCD notifications: $CLUSTER_NAME"
10+
11+
# Update the cluster-name in the argocd-notifications-cm ConfigMap
12+
kubectl patch configmap argocd-notifications-cm -n argocd \
13+
-p "{\"data\":{\"cluster-name\":\"$CLUSTER_NAME\"}}"
14+
15+
# Restart the notifications controller to pick up the change
16+
kubectl rollout restart deployment argocd-notifications-controller -n argocd
17+
18+
echo "✓ Cluster name configured: $CLUSTER_NAME"
19+
echo ""
20+
echo "ArgoCD notifications will now use cluster name: $CLUSTER_NAME"

.github/workflows/argocd-deployment-failure.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,13 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- name: Get cluster info
17-
id: cluster-info
18-
run: |
19-
CLUSTER_CONTEXT=$(kubectl config current-context 2>/dev/null || echo "unknown")
20-
echo "context=$CLUSTER_CONTEXT" >> $GITHUB_OUTPUT
21-
continue-on-error: true
22-
2316
- name: Create GitHub Issue
2417
uses: actions/github-script@v7
2518
with:
2619
script: |
2720
const payload = context.payload.client_payload || {};
2821
const appName = payload.app_name || 'unknown';
29-
const cluster = payload.cluster || 'unknown';
22+
const clusterName = payload.cluster || 'in-cluster';
3023
const namespace = payload.namespace || 'default';
3124
const healthStatus = payload.health_status || 'unknown';
3225
const syncStatus = payload.sync_status || 'unknown';
@@ -36,10 +29,6 @@ jobs:
3629
const timestamp = payload.timestamp || new Date().toISOString();
3730
const resources = payload.resources || [];
3831
39-
// Get cluster name - prefer from outputs, fallback to parsing URL
40-
const clusterContext = process.env.CLUSTER_CONTEXT || 'unknown';
41-
let clusterName = clusterContext !== 'unknown' ? clusterContext : cluster;
42-
4332
// Build degraded resources section
4433
let degradedDetails = '';
4534
const degradedResources = resources.filter(r =>

Act-3/argocd-test-app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: argoproj.io/v1alpha1
22
kind: Application
33
metadata:
4-
name: another-kind-of-working-aks-store
4+
name: half-working-aks-store
55
namespace: argocd
66
annotations:
77
# Enable notifications on sync failures

0 commit comments

Comments
 (0)