Skip to content

Commit a09d9c8

Browse files
committed
ci: replace kubectl --dry-run with kubeconform (offline schema validation)
1 parent cfe3392 commit a09d9c8

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

.github/workflows/lint.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,20 @@ jobs:
4545
**/*.md
4646
config: .markdownlint.jsonc
4747

48-
kubectl-dry-run:
48+
kubeconform:
4949
runs-on: ubuntu-24.04
5050
steps:
5151
- uses: actions/checkout@v5
52-
- name: Install kubectl
53-
uses: azure/setup-kubectl@v4
54-
- name: kubectl --dry-run=client on every manifest
52+
- name: Install kubeconform
5553
run: |
56-
set -e
57-
fail=0
58-
# Skip CRDs that the client doesn't know about (Calico/Cilium/Istio/SPIRE/Gatekeeper).
59-
# We validate plain k8s manifests only.
60-
while IFS= read -r f; do
61-
case "$f" in
62-
*/policy-db-l4.yaml|*/policy-cart-l7.yaml|*/policy-deny-staging-to-prod.yaml|\
63-
*/policy-allow-audit-exception.yaml|*/peer-auth-strict.yaml|\
64-
*/authz-httpbin-cart-only.yaml|*/template-required-labels.yaml|\
65-
*/constraint-required-labels.yaml|*/template-no-pod-without-netpol.yaml|\
66-
*/constraint-no-pod-without-netpol.yaml|*/sync-config.yaml)
67-
echo "skip CRD-bound: $f"; continue;;
68-
esac
69-
echo "::group::kubectl dry-run $f"
70-
# --validate=false: there's no cluster, so skip OpenAPI download
71-
if ! kubectl apply --dry-run=client --validate=false -f "$f"; then fail=1; fi
72-
echo "::endgroup::"
73-
done < <(find . -type f -path '*/manifests/*.yaml')
74-
exit "$fail"
54+
curl -fsSL -o /tmp/kc.tgz \
55+
https://github.com/yannh/kubeconform/releases/download/v0.6.7/kubeconform-linux-amd64.tar.gz
56+
tar -xzf /tmp/kc.tgz -C /tmp
57+
sudo install /tmp/kubeconform /usr/local/bin/
58+
- name: Validate manifests against bundled k8s schemas
59+
run: |
60+
# -strict catches unknown fields. -summary prints a final count.
61+
# -ignore-missing-schemas lets CRDs (Calico/Cilium/Istio/SPIRE/Gatekeeper)
62+
# pass without failing the build; we still validate core k8s objects.
63+
find . -type f -path '*/manifests/*.yaml' -print0 \
64+
| xargs -0 kubeconform -strict -summary -ignore-missing-schemas

0 commit comments

Comments
 (0)