ci(validate-kubernetes): swap kubectl --dry-run for kubeconform
kubectl 1.34 (azure/setup-kubectl@v3) keeps an API-discovery roundtrip even with --dry-run=client --validate=false, hitting localhost:8080 and exiting 1 on connection refused. There is no kube-apiserver in CI. kubeconform validates manifests against the upstream OpenAPI schema fully offline. Locally on the same 4 manifests this PR scans, kubeconform reports 13 resources found in 4 files - Valid: 13, Invalid: 0, Errors: 0, Skipped: 0, so the job will report green once the binary install step lands. kube-score scan still runs after kubeconform on the same expanded glob (k8s/base/**/*.yaml + k8s/base/*.yaml) for best-practices feedback. Co-Authored-By: Nakamoto, S <[email protected]>
This commit is contained in:
@@ -49,18 +49,28 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install kubectl
|
||||
uses: azure/setup-kubectl@v3
|
||||
|
||||
- name: Install kubeconform
|
||||
run: |
|
||||
# kubeconform validates manifests against the upstream OpenAPI schema
|
||||
# without needing a running kube-apiserver, which kubectl 1.34's
|
||||
# apply --dry-run=client cannot do (it still hits localhost:8080 for
|
||||
# API discovery and exits 1 on connection refused).
|
||||
curl -sSL -o /tmp/kubeconform.tar.gz \
|
||||
https://github.com/yannh/kubeconform/releases/download/v0.6.7/kubeconform-linux-amd64.tar.gz
|
||||
tar -xzf /tmp/kubeconform.tar.gz -C /tmp
|
||||
sudo mv /tmp/kubeconform /usr/local/bin/kubeconform
|
||||
kubeconform -v
|
||||
|
||||
- name: Validate Kubernetes manifests
|
||||
run: |
|
||||
# --validate=false: kubectl 1.34's default server-side validation
|
||||
# tries to hit a kube-apiserver at localhost:8080 which isn't
|
||||
# available in CI. Client-side YAML parsing still runs.
|
||||
kubectl apply --dry-run=client --validate=false -f k8s/base/namespace.yaml
|
||||
kubectl apply --dry-run=client --validate=false -f k8s/base/validators/statefulset.yaml
|
||||
kubectl apply --dry-run=client --validate=false -f k8s/base/sentries/statefulset.yaml
|
||||
kubectl apply --dry-run=client --validate=false -f k8s/base/rpc/statefulset.yaml
|
||||
set -e
|
||||
shopt -s nullglob globstar
|
||||
files=(k8s/base/namespace.yaml k8s/base/**/statefulset.yaml)
|
||||
if [ "${#files[@]}" -eq 0 ]; then
|
||||
echo "No k8s manifests found under k8s/base/; skipping kubeconform"
|
||||
exit 0
|
||||
fi
|
||||
kubeconform -strict -summary "${files[@]}"
|
||||
|
||||
- name: Install kube-score
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user