Skip to content

ci: validate k8s manifests in deployment#102

Closed
iSwiin wants to merge 1 commit intoskyflo-ai:mainfrom
iSwiin:chore/k8s-manifest-validation
Closed

ci: validate k8s manifests in deployment#102
iSwiin wants to merge 1 commit intoskyflo-ai:mainfrom
iSwiin:chore/k8s-manifest-validation

Conversation

@iSwiin
Copy link

@iSwiin iSwiin commented Feb 13, 2026

Description

Check: Infrastructure/build changes

Related Issue(s)

Closes #99

Type of Change

  • Feature (new functionality)
  • Bug fix (fixes an issue)
  • Documentation update
  • Code refactor
  • Performance improvement
  • [ x] Tests
  • [ x] Infrastructure/build changes
  • Other (please describe):

Testing

Opened PR that modifies deployment/** and confirmed k8s-validate workflow triggers.

Verified schema validation step fails on invalid manifest and passes after fix.

Verified kube score reports findings as warnings (workflow still passes).

Checklist

Before Requesting Review

  • [ x] I have tested my changes locally
  • [ x] My code follows the coding standards
  • [ x] I have added/updated necessary documentation
  • [ x] I have checked for and resolved any merge conflicts
  • [ x] I have linked this PR to relevant issue(s)

Code Quality

  • [x ] No debug print statements or console.log calls
  • [ x] No package-lock.json (we use yarn only for the UI)
  • [ x] No redundant or self-explanatory comments
  • x[ ] Error handling does not expose internal details to users

Screenshots (if applicable)

Additional Notes

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new GitHub Actions workflow .github/workflows/k8s-validate.yml that triggers on PRs touching deployment/** and manually, installs pinned kubeconform and kube-score, discovers manifests under deployment/, runs strict schema validation for Kubernetes v1.28.0, and runs kube-score in warn-only mode.

Changes

Cohort / File(s) Summary
Kubernetes Manifest Validation Workflow
​.github/workflows/k8s-validate.yml
Adds "Validate Kubernetes manifests" workflow triggered on PRs to deployment/** and workflow_dispatch. Job checks out repo, installs pinned kubeconform (v0.7.0) and kube-score (v1.20.0), discovers `deployment/*.yml

Sequence Diagram(s)

sequenceDiagram
    participant PR as Pull Request
    participant GH as GitHub Actions
    participant Runner as Runner (ubuntu-latest)
    participant Repo as Repository (deployment/*)
    participant KC as kubeconform
    participant KS as kube-score

    PR->>GH: PR modifies deployment/**
    GH->>Runner: start validate job
    Runner->>Repo: checkout repository
    Runner->>KC: download & install kubeconform v0.7.0
    Runner->>KS: download & install kube-score v1.20.0
    Runner->>Repo: discover manifests in deployment/
    alt manifests found
        Runner->>KC: run strict schema validation (K8s v1.28.0)
        KC-->>Runner: validation results (fail on schema errors)
        Runner->>KS: run kube-score (WARN-only)
        KS-->>Runner: warnings reported (non-fatal unless invocation error)
    else no manifests
        Runner-->>GH: skip validation steps
    end
    Runner-->>GH: report job outcome
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 I hopped through CI with a checklist so neat,
I found every manifest, each YAML heartbeat,
Kubeconform tapped, “schemas must align,”
Kube-score nudged softly, “tweak here and refine,”
I twitched my whiskers — validation complete!

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding CI validation for Kubernetes manifests in the deployment directory.
Description check ✅ Passed The description is related to the changeset, documenting the infrastructure/build changes and testing performed for the k8s manifest validation workflow.
Linked Issues check ✅ Passed The workflow implementation meets all requirements from #99: installs kubeconform and kube-score, validates YAML against Kubernetes schemas, runs best-practice checks, fails on schema errors, warns on best-practice violations, and completes in under 2 minutes.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the Kubernetes manifest validation workflow as defined in #99; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In @.github/workflows/k8s-validate.yml:
- Around line 76-82: The current kube-score step ("kube-score (WARN only; do not
fail workflow)") uses a blanket `|| true` after the pipeline (`find ... | xargs
-0 kube-score score --output-format ci || true`) which hides real failures;
change it to capture the kube-score exit code and only ignore the specific exit
code(s) that indicate policy findings while failing on execution errors: run the
pipeline into a variable (e.g., `set +e; find ... | xargs -0 kube-score score
--output-format ci; rc=$?; set -e`), then if rc indicates a runtime/installation
error (e.g., command not found or non-kube-score exit codes) `exit $rc`,
otherwise `echo "kube-score reported findings (rc=$rc)"` and continue; update
the step to use that conditional logic instead of unconditional `|| true` so
tool invocation failures still fail the job but findings remain non-fatal.
- Around line 51-61: The "Check for manifests" step (id: files) can fail when
the deployment directory is missing; update the step to defensively check for
the deployment directory before running find (e.g., use if [ -d deployment ] to
set COUNT via the existing find pipeline only when the directory exists,
otherwise set COUNT=0), preserving the existing behavior that writes
found=true/false to GITHUB_OUTPUT and keeping set -euo pipefail in place.
- Around line 1-7: The pull_request trigger only watches the "deployment/**"
pattern so changes to this workflow (k8s-validate.yml) won't run validation;
update the pull_request.paths list in the workflow's on: block to also include
the workflow file itself (add the k8s-validate.yml path alongside
"deployment/**") so the job runs when the workflow is modified.
- Around line 23-26: Remove the explicit "Install jq" step from the workflow
(the job step that runs "sudo apt-get update" and "sudo apt-get install -y jq");
since ubuntu-latest already includes jq, delete that entire step to eliminate
the unnecessary apt-get overhead and shorten job runtime.
- Around line 28-49: Replace the fragile "latest" GitHub API lookups for
kubeconform and kube-score with pinned-version downloads and authenticate
requests using the runner's GITHUB_TOKEN: stop using the jq/API flow that sets
URL via curl+jq (the URL variable and select logic), instead use the known
release asset URLs for kubeconform v0.7.0 and kube-score v1.20.0 and download
them directly; when using curl to fetch from api.github.com or GitHub releases,
add an Authorization: Bearer $GITHUB_TOKEN header to avoid rate limits; keep the
subsequent steps (tar extraction/chmod + sudo mv to /usr/local/bin and version
checks like kubeconform -v and kube-score version) but change the URL assignment
and curl invocations to the pinned URLs and authenticated curl headers and
remove the jq dependency.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/k8s-validate.yml:
- Line 93: Remove the leaked AI citation artifact
":contentReference[oaicite:0]{index=0}" from the kube-score comment on the line
that currently reads "# kube-score exits non-zero (commonly 1) when it reports
problems in CI usage. :contentReference[oaicite:0]{index=0}"; update the comment
to only contain the human-readable text (e.g., "# kube-score exits non-zero
(commonly 1) when it reports problems in CI usage.") so no AI-generated tokens
remain.
- Around line 29-39: The workflow step references ${GITHUB_TOKEN} in the install
shell but set -u aborts because GITHUB_TOKEN isn't exported to the shell; update
the workflow to provide the token as an environment variable either by adding an
env mapping for GITHUB_TOKEN at the job level so both the kubeconform install
and any other steps can use it, or by replacing ${GITHUB_TOKEN} in the curl
command with the GitHub Actions expression (e.g., ${{ secrets.GITHUB_TOKEN }})
so the value is injected inline; adjust the step that constructs the url and the
curl header usage accordingly (symbols: KUBECONFORM_VERSION, GITHUB_TOKEN,
kubeconform install step).

@KaranJagtiani
Copy link
Member

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

✅ Actions performed

Full review triggered.

@KaranJagtiani
Copy link
Member

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Feb 14, 2026

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/k8s-validate.yml:
- Around line 92-99: The kubeconform invocation (the command starting with
"kubeconform" and its flags like -strict, -summary, -ignore-missing-schemas,
-kubernetes-version) should include an explicit --output flag for CI-friendly
parsing; update the command to add either --output json or --output tap (e.g.,
--output json) so validation failures are machine-readable and easier to
integrate with CI reporters/annotations.
- Around line 72-99: The manifest-discovery (find + grep apiVersion/kind) logic
is duplicated; extract it into the existing "Check for manifests" step by
writing the matching file paths to a single shared file (e.g.,
"$RUNNER_TEMP/k8s-manifests.txt") and change both validation steps (including
the "Schema validate (FAIL on errors)" step and the other validation step that
repeats the same discovery) to read that file into the files array instead of
re-running find/grep; update references in the steps that currently use the
inline discovery so they populate files from the shared list and remove the
duplicate discovery blocks.

Comment on lines +92 to +99
kubeconform \
-strict \
-summary \
-ignore-missing-schemas \
-kubernetes-version "${K8S_VERSION}" \
-schema-location default \
-schema-location "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/{{.NormalizedKubernetesVersion}}-standalone-strict/{{.ResourceKind}}.json" \
"${files[@]}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider adding --output format for CI-friendly kubeconform output.

Currently kubeconform uses its default text output. Adding --output json or --output tap can make failures easier to parse in CI logs and enables future integration with annotation/reporting tools.

This is purely optional — the current setup is functional.

🤖 Prompt for AI Agents
In @.github/workflows/k8s-validate.yml around lines 92 - 99, The kubeconform
invocation (the command starting with "kubeconform" and its flags like -strict,
-summary, -ignore-missing-schemas, -kubernetes-version) should include an
explicit --output flag for CI-friendly parsing; update the command to add either
--output json or --output tap (e.g., --output json) so validation failures are
machine-readable and easier to integrate with CI reporters/annotations.

@iSwiin
Copy link
Author

iSwiin commented Feb 14, 2026

Pushed updates . Could you take another look when you get a chance?

Copy link
Member

@KaranJagtiani KaranJagtiani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squash commits: ci: add Kubernetes manifest validation workflow

else
echo "kube-score failed to run correctly (rc=$rc)"
exit "$rc"
fi No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a newline at EOF

Comment on lines +81 to +85
while IFS= read -r -d '' f; do
if grep -qE '^[[:space:]]*apiVersion:' "$f" && grep -qE '^[[:space:]]*kind:' "$f"; then
files+=("$f")
fi
done < <(find deployment -type f \( -name '*.yml' -o -name '*.yaml' \) -print0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated logic. Centralize it in "Check for manifests" step, write to $RUNNER_TEMP/k8s-manifests.txt, and have both validation steps read from it to avoid drift.

Comment on lines +87 to +90
if [ "${#files[@]}" -eq 0 ]; then
echo "No Kubernetes manifest YAMLs (apiVersion/kind) found under deployment/. Skipping schema validation."
exit 0
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant “no manifests found” checks since steps.files.outputs.found already guards execution.

run: |
set -euo pipefail

# Only validate files that look like Kubernetes manifests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant comments.

@iSwiin
Copy link
Author

iSwiin commented Feb 17, 2026

Pushed updates again. Could you take another look when you get a chance?

Copy link
Member

@KaranJagtiani KaranJagtiani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squash commits: ci: add Kubernetes manifest validation workflow

@KaranJagtiani
Copy link
Member

@iSwiin Please squash the commits into a single clean commit.
Once the commits are squashed and workflows are green, I’ll take a final pass and merge.

@iSwiin iSwiin force-pushed the chore/k8s-manifest-validation branch from cac0bc4 to 0405157 Compare February 21, 2026 06:38
@iSwiin
Copy link
Author

iSwiin commented Feb 21, 2026

Squashed into a single commit (ci: add Kubernetes manifest validation workflow) and force pushed. Please take a final pass when you get a chance.

Copy link
Member

@KaranJagtiani KaranJagtiani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename the file to: "deployment-ci.yml" so that it can be later upgraded to support additional checks for the deployment/** path.

else
echo "kube-score failed to run correctly (rc=$rc)"
exit "$rc"
fi No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline is still missing here

@@ -0,0 +1,111 @@
name: Validate Kubernetes manifests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Validate Kubernetes manifests
name: Deployment

This way the checks render as:

Deployment / validate
Deployment / security-scan (future)
Deployment / lint-helm (future)

@KaranJagtiani
Copy link
Member

@iSwiin There are pending changes blocking this PR.
Please address them or confirm if you’d prefer this closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Kubernetes manifest validation CI workflow

2 participants