/cicd-tooling-skills:complete-cicd-pipeline-deployment-for-kubernetes-from-scratchfrom cicd-tooling-skills
Builds a CI/CD pipeline for Kubernetes from scratch: checkout, container build, SCA/SAST gates, registry push, and GitOps commit. Ends with Argo CD/Flux handoff, not direct cluster deploy.
Ships in cicd-tooling-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A Kubernetes-targeted pipeline's defining mechanical trait is where its job ends: it builds a container image, gates it, and pushes it to a registry — but it does not touch the cluster. The last step is a Git commit (a new image tag in a manifests/config repo), and a separate in-cluster GitOps operator (Argo CD/Flux) performs the actual apply. This is the opposite shape from the VM-based and serverless variants of this skill, both of which end with the pipeline itself calling a deploy API against live infrastructure. Every individual mechanic here — the Dockerfile, the SAST/SCA tool invocations, the GitOps repo structure — already has its own deep skill; this one sequences them into one coherent "empty repo to running-via-GitOps" walkthrough and is explicit about the handoff boundary so a well-meaning "just add a deploy step" doesn't reintroduce direct cluster credentials into CI.
kubectl apply/helm upgrade
run directly from CI, and the user wants to migrate it to a GitOps
handoff instead.Application/ApplicationSet (or Flux Kustomization)
already watching it. This skill assumes that operator-side setup exists;
see the four complete-gitops-argocd-deployment-on-*-from-scratch
skills in gitops-argo-ecosystem if it doesn't yet.Standard trigger/concurrency setup per
ci-cd-pipeline-design
and
github-actions-single-repo-workflows:
run the full pipeline on PRs and pushes to main, path-filtered in a
monorepo.
Follow container-build-and-release in full for the Dockerfile itself (multi-stage, non-root, pinned base image, immutable tagging by commit SHA). This is the Kubernetes-specific build artifact — contrast with Phase 2 of the serverless variant of this skill (a zip/layer, no Dockerfile at all) and the VM variant (a full machine image, not a container layer).
Per sast-integration and software-composition-analysis-sca, run diff-aware static analysis and a dependency/lockfile scan before the image is pushed anywhere — failing fast on a critical finding before spending registry storage and pipeline minutes on an image that won't ship:
jobs:
sast:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: semgrep ci --config p/owasp-top-ten --baseline-commit "${{ github.event.pull_request.base.sha }}"
sca:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aquasecurity/[email protected]
with: { scan-type: 'fs', severity: 'CRITICAL,HIGH', exit-code: '1', ignore-unfixed: true }
Only after Phase 3 passes:
build-and-push:
needs: [sast, sca]
runs-on: ubuntu-latest
permissions: { contents: read, packages: write }
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with: { registry: ghcr.io, username: "${{ github.actor }}", password: "${{ secrets.GITHUB_TOKEN }}" }
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/example/payments-api:${{ github.sha }}
A follow-on image scan (per software-composition-analysis-sca's container-image scanning step) on the pushed digest catches base-image CVEs the filesystem scan in Phase 3 couldn't see.
This is the defining step. The pipeline's last action is a Git commit
against the manifests repo, bumping the image tag/digest in the relevant
overlay — never a direct kubectl apply, helm upgrade, or any command
carrying a cluster credential:
update-manifests:
needs: build-and-push
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: example/gitops-config
token: ${{ secrets.GITOPS_REPO_TOKEN }}
- run: |
cd apps/payments-api/overlays/staging
kustomize edit set image payments-api=ghcr.io/example/payments-api:${{ github.sha }}
git config user.name "ci-bot"
git config user.email "[email protected]"
git commit -am "payments-api: bump to ${{ github.sha }}"
git push
GITOPS_REPO_TOKEN is scoped only to the manifests repo (never a
cluster kubeconfig or cloud credential) — the in-cluster Argo CD
Application/ApplicationSet (see the relevant
complete-gitops-argocd-deployment-on-*-from-scratch skill) picks up this
commit and performs the actual kubectl apply on its own reconciliation
loop, per
gitops-workflow.
The pipeline's own success/failure only reflects "the manifests repo was
updated correctly" — it cannot and should not report "the cluster is
running the new version," since that's the GitOps operator's job.
Separately, monitor argocd app get payments-api-staging (or a
notification wired from Argo CD/Flux) for the actual rollout outcome.
kubectl apply — the entire point of the GitOps handoff is that CI's
blast radius, if compromised, is "can propose a manifest change," not
"can directly mutate the cluster."Symptom: Someone adds a "quick fix" kubectl apply step directly to
the pipeline "just for this one hotfix," and it works — until the next
regular GitOps sync reverts the hotfix moments later because the config
repo was never updated to match.
Fix: This is exactly the sequencing failure this skill exists to
prevent — any change to what's running must go through the manifests
repo commit (Phase 5), even for an emergency fix; a direct kubectl apply against a selfHeal: true Application is reverted on the next
reconciliation, per the drift-handling behavior in
gitops-workflow.
Symptom: The pipeline reports green ("deploy succeeded") but the
service in the cluster is still running the old version an hour later.
Fix: "Pipeline green" here only means the manifests-repo commit
landed — it says nothing about whether Argo CD/Flux actually
reconciled it. Check argocd app get <app> (or Flux's equivalent)
separately; if it's OutOfSync/stuck, that's a GitOps-operator issue
(see
argocd-application-configuration),
not a pipeline bug.
Symptom: Two different pipelines (the app's own CI, and a separate "promote to prod" job) both push commits to the same manifests-repo overlay, and their commits race, silently overwriting each other's image tag bump. Fix: Give exactly one pipeline stage ownership of writing to a given overlay path per environment, and have any "promotion" step read the currently-deployed staging tag and bump prod to that exact value rather than independently recomputing it — avoid two automated writers racing on the same file.
Symptom: The SAST/SCA gates (Phase 3) are placed after the image
build and push (Phase 4) "to save a rebuild if it fails," and a
vulnerable image sits in the registry (and is briefly pullable) before
the gate result comes back.
Fix: Order gates before the push, not after — a failed post-push
gate still leaves a bad image in the registry for however long it takes
to notice and delete it; scanning the filesystem/dependencies before
docker build/push (Phase 3 before Phase 4) means a failing gate
never produces a pushed artifact at all.
Scenario: payments-api, a Node.js service, gets its first full
pipeline: PR-time SAST/SCA, main-branch image build/push to GHCR, and a
GitOps handoff bumping the staging overlay in example/gitops-config.
.github/workflows/ci-cd.yml (abbreviated to the phases above; full
Dockerfile/scan config lives in the linked skills):
name: ci-cd
on:
pull_request: { branches: [main] }
push: { branches: [main] }
jobs:
sast:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: semgrep ci --config p/owasp-top-ten --baseline-commit "${{ github.event.pull_request.base.sha || github.event.before }}"
sca:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aquasecurity/[email protected]
with: { scan-type: 'fs', severity: 'CRITICAL,HIGH', exit-code: '1' }
build-and-push:
needs: [sast, sca]
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions: { contents: read, packages: write }
steps:
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with: { registry: ghcr.io, username: "${{ github.actor }}", password: "${{ secrets.GITHUB_TOKEN }}" }
- uses: docker/build-push-action@v6
with: { push: true, tags: "ghcr.io/example/payments-api:${{ github.sha }}" }
update-manifests:
needs: build-and-push
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: { repository: example/gitops-config, token: "${{ secrets.GITOPS_REPO_TOKEN }}" }
- run: |
cd apps/payments-api/overlays/staging
kustomize edit set image payments-api=ghcr.io/example/payments-api:${{ github.sha }}
git config user.name "ci-bot" && git config user.email "[email protected]"
git commit -am "payments-api: bump to ${{ github.sha }}"
git push
Argo CD's payments-api-staging Application (automated: {prune: true, selfHeal: true} per
argocd-application-configuration)
picks up the new commit on its next poll and reconciles the cluster —
the CI pipeline itself never held a cluster credential at any point.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
13 skills in this plugin
/aws-codepipeline-and-codedeployDesigns AWS CodePipeline stage/action structure and integrates it with CodeDeploy deployment groups and appspec.yml for EC2/on-prem, ECS, or Lambda deploys. Use when the user asks to "set up CodePipeline," "add a CodeDeploy deployment group," "write an appspec.yml," "wire CodePipeline to CodeDeploy," "troubleshoot a stuck/failed CodePipeline action," or "add a manual approval action before an AWS deploy."
/azure-pipelines-yaml-and-multi-stageDesigns Azure Pipelines YAML (azure-pipelines.yml), multi-stage pipelines with environments/approvals, templates for reuse across repos, and self-hosted vs. Microsoft-hosted agent pools. Use when the user asks to "set up Azure Pipelines," "write an azure-pipelines.yml," "add a multi-stage pipeline with approvals," "create a reusable pipeline template," "configure a self-hosted agent pool," or "troubleshoot a stuck/failed Azure DevOps pipeline run."
/bamboo-pipeline-yaml-and-java-specsAuthors Atlassian Bamboo pipeline definitions using either Bamboo Specs (Java DSL, compiled and run to create/update a plan) or Bamboo's YAML specs format, covering plan/job/stage structure and how a Specs definition links to and updates a live Bamboo plan. Use when the user asks to "write a Bamboo Specs plan," "convert our Bamboo plan to code," "add a stage/job to a Bamboo build," "use Bamboo YAML specs," or "troubleshoot a Bamboo Specs plan not updating the linked plan."
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin cicd-tooling-skillsOther plugins' skills for the same job