fix(gitops): apply argocd with server-side ownership

This commit is contained in:
ximenchuifeng committed 2026-07-15 01:19:12 +08:00
1 parent 9d263ebcc0
commit 92f26c4d64
3 files changed
+9 -3

No files matched your search

+7 -1
View File
@@ -36,7 +36,13 @@ The script is idempotent. Before applying anything, it:
3. Verifies all three exact Harbor image references are in the local k3s image cache. 3. Verifies all three exact Harbor image references are in the local k3s image cache.
4. Records the existing Argo CD Applications. 4. Records the existing Argo CD Applications.
It then applies the render, waits up to 300 seconds per workload, verifies the live pull policies, rejects image-pull failures, and confirms that pre-existing Applications remain present. It then applies the render with Kubernetes Server-Side Apply and conflict resolution, waits up to 300 seconds per workload, verifies the live pull policies, rejects image-pull failures, and confirms that pre-existing Applications remain present.
Server-Side Apply is required for Argo CD 3.3 and later because the ApplicationSet CRD exceeds Kubernetes' 262144-byte annotation limit for client-side apply. The flags match the official Argo CD install and upgrade procedure:
```text
--server-side --force-conflicts
```
The script never pulls, retags, deletes, or garbage-collects images. If an image is missing, restore Harbor or deliberately import that exact image before retrying. The script never pulls, retags, deletes, or garbage-collects images. If an image is missing, restore Harbor or deliberately import that exact image before retrying.
+1 -1
View File
@@ -61,7 +61,7 @@ else
fi fi
echo "Applying the verified manifest..." echo "Applying the verified manifest..."
k3s kubectl apply -f "$rendered_manifest" k3s kubectl apply --server-side --force-conflicts -f "$rendered_manifest"
while read -r resource _containers; do while read -r resource _containers; do
[[ -n "$resource" ]] || continue [[ -n "$resource" ]] || continue
+1 -1
View File
@@ -32,7 +32,7 @@ while IFS= read -r actual_image; do
"${expected_images[0]}"|"${expected_images[1]}"|"${expected_images[2]}") ;; "${expected_images[0]}"|"${expected_images[1]}"|"${expected_images[2]}") ;;
*) fail "unexpected workload image in render: $actual_image" ;; *) fail "unexpected workload image in render: $actual_image" ;;
esac esac
done < <(awk '$1 == "image:" {gsub(/\"/, "", $2); print $2}' "$rendered_manifest" | sort -u) done < <(awk '$1 == "image:" {gsub(/"/, "", $2); print $2}' "$rendered_manifest" | sort -u)
if grep -Eq 'image:[[:space:]]+(quay\.io|ghcr\.io|public\.ecr\.aws)/' "$rendered_manifest"; then if grep -Eq 'image:[[:space:]]+(quay\.io|ghcr\.io|public\.ecr\.aws)/' "$rendered_manifest"; then
fail "upstream image reference remains in render" fail "upstream image reference remains in render"