Skip to content

Commit c65e0e0

Browse files
committed
feat(argocd): configure resource tracking and health checks for Crossplane
Add patch for Argo CD ConfigMap to enable annotation-based tracking, health checks for Upbound resources, and exclusions for ProviderConfigUsage. Also patch Argo CD server during bootstrap.
1 parent ee21243 commit c65e0e0

File tree

4 files changed

+72
-8
lines changed

4 files changed

+72
-8
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# @see https://docs.crossplane.io/latest/guides/crossplane-with-argo-cd
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: argocd-cm
6+
namespace: argocd-system
7+
data:
8+
application.resourceTrackingMethod: annotation
9+
resource.customizations: |
10+
"*.upbound.io/*":
11+
health.lua: |
12+
health_status = {
13+
status = "Progressing",
14+
message = "Provisioning ..."
15+
}
16+
17+
local function contains (table, val)
18+
for i, v in ipairs(table) do
19+
if v == val then
20+
return true
21+
end
22+
end
23+
return false
24+
end
25+
26+
local has_no_status = {
27+
"ProviderConfig",
28+
"ProviderConfigUsage"
29+
}
30+
31+
if obj.status == nil or next(obj.status) == nil and contains(has_no_status, obj.kind) then
32+
health_status.status = "Healthy"
33+
health_status.message = "Resource is up-to-date."
34+
return health_status
35+
end
36+
37+
if obj.status == nil or next(obj.status) == nil or obj.status.conditions == nil then
38+
if obj.kind == "ProviderConfig" and obj.status.users ~= nil then
39+
health_status.status = "Healthy"
40+
health_status.message = "Resource is in use."
41+
return health_status
42+
end
43+
return health_status
44+
end
45+
resource.exclusions: |
46+
- apiGroups:
47+
- "*"
48+
kinds:
49+
- ProviderConfigUsage

.bootstrap/argocd/up.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if [[ "$(kubectl config current-context)" != "kind-platform" ]]; then
1111
fi
1212

1313
NS=argocd-system
14-
BASE_DIR=./argocd
14+
BASE_DIR="$(dirname "$0")"
1515
MANIFESTS_DIR="$BASE_DIR/manifests"
1616
PORT=8080
1717
ARGO_PWD_NEW="12345678"
@@ -32,6 +32,10 @@ kubectl wait --for=condition=available --timeout=120s deployment/argocd-server -
3232
exit 1
3333
}
3434

35+
kubectl patch configmap argocd-cm -n $NS --patch-file $MANIFESTS_DIR/argocd-cm-patch.yaml
36+
kubectl rollout restart deployment argocd-server -n $NS
37+
kubectl rollout status deployment argocd-server -n $NS
38+
3539
# Start port-forward only if not already active
3640
if ! lsof -i TCP:$PORT >/dev/null 2>&1; then
3741
if kubectl get svc/argocd-server -n "$NS" >/dev/null 2>&1; then
@@ -81,6 +85,6 @@ fi
8185

8286
# Apply Argo CD applications or configs
8387
echo "Applying Argo CD manifests..."
84-
kubectl apply -f "$BASE_DIR/crossplane-claims.yaml"
88+
kubectl apply -f "./argocd/crossplane-claims.yaml"
8589

8690
echo "✅ Argo CD setup completed successfully!"

.bootstrap/backstage/up.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ else
2828
echo "✅ Namespace $NS already exists."
2929
fi
3030

31-
echo "Building Backstage image $IMAGE..."
32-
cd ./backstage
33-
docker rmi -f $IMAGE
34-
yarn build:all
35-
yarn build-image --tag "$IMAGE" --no-cache
31+
echo "Checking if Backstage image '$IMAGE' already exists..."
32+
if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
33+
echo "🔨 Building Backstage image $IMAGE..."
34+
cd ./backstage
35+
yarn build:all
36+
yarn build-image --tag "$IMAGE" --no-cache
37+
cd ..
38+
else
39+
echo "✅ Docker image $IMAGE already exists. Skipping build."
40+
fi
41+
3642
kind load docker-image "$IMAGE" --name "$CLUSTER_NAME"
37-
cd ..
3843

3944
# Apply manifests to the cluster (idempotent)
4045
echo "Applying manifests from $MANIFESTS_DIR..."

argocd/crossplane-claims.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ spec:
1818
automated:
1919
prune: true
2020
selfHeal: true
21+
# ignoreDifferences:
22+
# - group: platform.hooli.tech
23+
# kind: XQueue
24+
# jsonPointers:
25+
# - /spec
26+
# - /status

0 commit comments

Comments
 (0)