Sub topic 18
Catching deprecated APIs automatically in CI
Earlier chapters showed how to find and migrate deprecated APIs by hand. This chapter moves that check into your CI pipeline, so a manifest that uses a removed API fails a pull request instead of failing during an upgrade.
This chapter assumes you know how API versions and the deprecation policy work. It also assumes you can read a basic CI workflow and run helm template or kubectl from a shell.
What CI can and cannot check
CI sees the files in your repository: raw manifests, Kustomize output, and rendered Helm charts. It does not see objects created by hand, by operators, or by other teams' pipelines. Treat the CI check as a gate for code you own. Keep checking the live cluster with the apiserver_requested_deprecated_apis metric from the detection chapter.
Two complementary tools
Two kinds of checks catch different problems.
| Check | Example tool | What it catches |
|---|---|---|
| Deprecation scan | Pluto | APIs that are deprecated or removed in a given release |
| Schema validation | kubeconform | Fields that are invalid for the target version, such as a missing `pathType` |
The second row matters because, as the Ingress example showed, a migration can change the schema and not only the apiVersion line.
A check script
Put the logic in a script so developers can run it locally and CI runs the same thing. This script assumes pluto, kubeconform, and helm are installed.
#!/usr/bin/env bash
set -euo pipefail
# Kubernetes version you plan to upgrade to
TARGET="1.32.0"
# 1. Scan plain manifests for deprecated or removed APIs
pluto detect-files -d manifests/ --target-versions "k8s=v${TARGET}"
# 2. Validate plain manifests against the target version's schemas
kubeconform -strict -summary -kubernetes-version "${TARGET}" manifests/
# 3. Render a Helm chart and validate the result
helm template web ./charts/web \
| kubeconform -strict -summary -kubernetes-version "${TARGET}" -Pluto exits with a non-zero code when it finds deprecated or removed APIs for the target version. set -e turns that into a failed job. Kubeconform reports an error for a resource whose API version has no schema in the target release.
Wiring it into a pipeline
The workflow below runs the script on every pull request. Add steps that install the three tools before the script runs.
name: k8s-api-checks
on: pull_request
jobs:
deprecations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install pluto, kubeconform, and helm here
- name: Check manifests
run: ./ci/check-k8s-apis.shKeeping the guardrail useful
- Set
TARGETto the next minor version you plan to adopt, not the version you run today. Today's version passes by definition. - Pin tool versions. Pluto's list of deprecations is updated with each release, so an old Pluto does not know about newer removals.
- Run the job on a schedule as well as on pull requests. A manifest that was valid last month can become flagged after you raise
TARGET. - Fail the build on removed APIs. Deprecated-only findings can start as warnings if the backlog is large.
Exercise
Your CI check passes with TARGET set to the version your cluster already runs, yet the next upgrade breaks a Deployment's Ingress. What change to the CI configuration would have caught it, and why?
Show answer
Set TARGET to the version you are upgrading to. The scan and schema validation only flag APIs that are deprecated or removed as of the target version. With TARGET at the current version, the Ingress still validates because its API is still served there.