<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Oleksandr Kuryzhev</title>
    <description>The latest articles on DEV Community by Oleksandr Kuryzhev (@oleksandr_kuryzhev_42873f).</description>
    <link>https://dev.to/oleksandr_kuryzhev_42873f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3970301%2Fff42dfb6-af2a-4fc7-968a-54326187a691.jpg</url>
      <title>DEV Community: Oleksandr Kuryzhev</title>
      <link>https://dev.to/oleksandr_kuryzhev_42873f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/oleksandr_kuryzhev_42873f"/>
    <language>en</language>
    <item>
      <title>Devcontainer onboarding with uv and mise</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Thu, 03 Dec 2026 08:02:08 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/devcontainer-onboarding-with-uv-and-mise-hka</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/devcontainer-onboarding-with-uv-and-mise-hka</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/12/03/devcontainer-onboarding-with-uv-and-mise" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;A new engineer joins on Monday. By Tuesday afternoon they are still comparing &lt;code&gt;python --version&lt;/code&gt; output with a teammate, installing the wrong Node, and asking which README section is stale. Devcontainer onboarding with uv and mise replaces that with a clone and a single "Reopen in Container".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; put tool versions in a committed &lt;code&gt;mise.toml&lt;/code&gt;, keep Python dependencies in &lt;code&gt;pyproject.toml&lt;/code&gt; and &lt;code&gt;uv.lock&lt;/code&gt;, and let a small &lt;code&gt;postCreateCommand&lt;/code&gt; script install mise and run &lt;code&gt;uv sync --locked&lt;/code&gt;. It fits teams of two or more who share a repo and a mix of laptops. It is overkill for a solo project and a poor fit for GPU-heavy or macOS-native work (see the last tip).&lt;/p&gt;

&lt;h2&gt;Keep devcontainer.json thin and put versions in mise.toml&lt;/h2&gt;



&lt;p&gt;&lt;strong&gt;The container should describe the OS and mounts; the toolchain should live in a file that CI and laptops can read too.&lt;/strong&gt; If Python and Node versions sit inside &lt;code&gt;devcontainer.json&lt;/code&gt;, people outside the container (and your CI) drift away from them. A &lt;code&gt;mise.toml&lt;/code&gt; at the repo root is the single source for both.&lt;/p&gt;

&lt;p&gt;Start with this file. The versions follow current stable cycles (Python 3.15, Node.js 26 LTS). Pin exact patch versions if you want fully reproducible builds.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# mise.toml
[tools]
python = "3.15"
node   = "26"
uv     = "latest"   # pin an exact version once the team agrees on one

[env]
_.path = [".venv/bin"]   # uv's virtualenv is on PATH after `uv sync`

[tasks.bootstrap]
description = "Install locked dependencies"
run = "uv sync --locked"

[tasks.test]
run = "uv run --locked pytest -q"   # --locked: fail instead of silently re-locking
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Docs: &lt;a href="https://mise.jdx.dev/" rel="noopener noreferrer"&gt;mise&lt;/a&gt; and &lt;a href="https://docs.astral.sh/uv/" rel="noopener noreferrer"&gt;uv&lt;/a&gt;. Check the mise docs for exact setting names, since they change between releases.&lt;/p&gt;

&lt;h2&gt;Install mise in a bootstrap script, not in forty lines of JSON&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;One idempotent shell script beats a chain of &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; in &lt;code&gt;postCreateCommand&lt;/code&gt;.&lt;/strong&gt; It can be read, linted with shellcheck, and run by hand when something breaks. The devcontainer file stays short.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// .devcontainer/devcontainer.json (the spec allows comments)
{
  "name": "platform-tools",
  "image": "mcr.microsoft.com/devcontainers/base:ubuntu", // verify the current tag on the registry
  "remoteUser": "vscode",
  "containerEnv": { "UV_LINK_MODE": "copy" },
  "mounts": [
    "source=uv-cache,target=/home/vscode/.cache/uv,type=volume",
    "source=mise-data,target=/home/vscode/.local/share/mise,type=volume"
  ],
  "postCreateCommand": "bash .devcontainer/bootstrap.sh"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash
# .devcontainer/bootstrap.sh
set -euo pipefail

# volume mount points missing from the image are created root-owned,
# including parent dirs; fix before installing anything
sudo chown "$(id -u):$(id -g)" ~/.cache ~/.local ~/.local/share
sudo chown -R "$(id -u):$(id -g)" ~/.cache/uv ~/.local/share/mise

export PATH="$HOME/.local/bin:$PATH"
command -v mise &amp;gt;/dev/null || curl -fsSL https://mise.run | sh

mise trust            # trust the repo's mise.toml inside the container
mise install          # python, node, uv from mise.toml
mise run bootstrap    # uv sync --locked

grep -q 'mise activate' ~/.bashrc || \
  echo 'eval "$(~/.local/bin/mise activate bash)"' &amp;gt;&amp;gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Watch out:&lt;/strong&gt; piping a remote script into &lt;code&gt;sh&lt;/code&gt; is convenient but unpinned. If your security team objects, download the mise release binary at a pinned version instead, or bake it into a custom image.&lt;/p&gt;

&lt;h2&gt;Let uv own dependencies and fail loudly on drift&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use &lt;code&gt;uv sync --locked&lt;/code&gt; in the bootstrap, never plain &lt;code&gt;uv sync&lt;/code&gt;.&lt;/strong&gt; With &lt;code&gt;--locked&lt;/code&gt;, uv errors out if &lt;code&gt;uv.lock&lt;/code&gt; no longer matches &lt;code&gt;pyproject.toml&lt;/code&gt;. A new hire sees a clear failure instead of silently resolving different versions than everyone else.&lt;/p&gt;

&lt;p&gt;The same applies to &lt;code&gt;uv run&lt;/code&gt;. By default it re-locks and syncs before running, so the test task passes &lt;code&gt;--locked&lt;/code&gt; as well.&lt;/p&gt;

&lt;p&gt;The setting &lt;code&gt;UV_LINK_MODE=copy&lt;/code&gt; in the config above avoids hardlink warnings when the cache volume and the workspace sit on different filesystems. This is the documented behavior. The trade-off is slightly more disk use.&lt;/p&gt;

&lt;p&gt;Verify the result inside the container:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mise doctor            # no errors about missing shims or untrusted config
mise ls                # python, node, uv listed with versions from mise.toml
uv run python -V       # Python 3.15.x
uv lock --check        # exits 0 when uv.lock matches pyproject.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Cache volumes make the second rebuild cheap, but mind ownership&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mount named volumes for the uv cache and the mise data directory so rebuilds skip the downloads.&lt;/strong&gt; The first build still pays for the image pull and tool downloads. After that, "Rebuild Container" mostly reuses what is on disk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out:&lt;/strong&gt; when a mount target does not already exist in the image, Docker creates it, and any missing parent directories, owned by root. If the bootstrap runs as &lt;code&gt;vscode&lt;/code&gt; without the &lt;code&gt;chown&lt;/code&gt; lines, you get permission-denied errors under &lt;code&gt;~/.cache/uv&lt;/code&gt;, &lt;code&gt;~/.local/share/mise&lt;/code&gt; or even &lt;code&gt;~/.local/bin&lt;/code&gt;. That is a typical failure on a fresh machine and easy to misread as a network problem.&lt;/p&gt;

&lt;p&gt;Volumes also persist stale state. If a tool install behaves oddly, remove the volumes (&lt;code&gt;docker volume rm uv-cache mise-data&lt;/code&gt;) and rebuild before debugging further.&lt;/p&gt;

&lt;h2&gt;Make devcontainer onboarding a three-command README&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The onboarding doc should shrink to what a human actually types.&lt;/strong&gt; Everything else belongs in tasks, so it cannot go stale without something failing.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone git@github.com:your-org/your-repo.git
code your-repo      # then: "Dev Containers: Reopen in Container"
mise run test       # green means the environment is correct
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That last command doubles as the acceptance check. If &lt;code&gt;mise run test&lt;/code&gt; passes, the engineer has the right interpreter, the locked dependencies, and a working PATH. Add one task per recurring chore (&lt;code&gt;lint&lt;/code&gt;, &lt;code&gt;fmt&lt;/code&gt;, &lt;code&gt;serve&lt;/code&gt;) and the README stops needing a "common commands" section. For more tooling patterns like this, browse &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Test the container in CI so it does not rot&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A devcontainer nobody builds automatically breaks quietly, usually the week a new hire needs it.&lt;/strong&gt; Build it in CI on changes to &lt;code&gt;.devcontainer/&lt;/code&gt;, &lt;code&gt;mise.toml&lt;/code&gt; or &lt;code&gt;uv.lock&lt;/code&gt;, and run the same test task. The reference &lt;code&gt;devcontainer&lt;/code&gt; CLI is documented at &lt;a href="https://containers.dev/" rel="noopener noreferrer"&gt;containers.dev&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;npm install -g @devcontainers/cli
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . mise run test   # non-zero exit fails the job
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Expect this job to be slower than a normal unit-test run because it builds an image and installs tools. Path filters keep the cost down.&lt;/p&gt;

&lt;p&gt;For secrets, never bake tokens into the image or &lt;code&gt;mise.toml&lt;/code&gt;. Forward them at runtime with &lt;code&gt;remoteEnv&lt;/code&gt; and &lt;code&gt;${localEnv:MY_TOKEN}&lt;/code&gt;, and keep them out of the committed files.&lt;/p&gt;

&lt;h2&gt;Know when not to use a devcontainer&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A devcontainer costs RAM, disk and some file I/O speed, and it is the wrong tool for a few jobs.&lt;/strong&gt; On Docker Desktop for macOS and Windows, bind-mounted workspaces can be noticeably slower than native, especially for large &lt;code&gt;node_modules&lt;/code&gt; trees. Cloning into a named volume helps, but it adds a step.&lt;/p&gt;

&lt;p&gt;Skip it in three cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GPU training boxes, where passthrough setup is its own project.&lt;/li&gt;
&lt;li&gt;macOS or iOS toolchains that cannot run in a Linux container.&lt;/li&gt;
&lt;li&gt;Solo repos where &lt;code&gt;mise install &amp;amp;&amp;amp; uv sync&lt;/code&gt; on the host is already quick.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In those cases keep &lt;code&gt;mise.toml&lt;/code&gt; and &lt;code&gt;uv.lock&lt;/code&gt;, which work fine on the host, and drop only the container layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out:&lt;/strong&gt; the container is not a security boundary for untrusted code. Mounted SSH agents, cloud credentials and the Docker socket are reachable from inside, so treat what you forward as part of your blast radius.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/23/ubuntu-26-04-golden-images-on-hetzner-with-cloud-init/" rel="noopener noreferrer"&gt;Ubuntu 26.04 golden images on Hetzner with cloud-init&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/22/k9s-incident-debugging-shortcuts-and-plugins-that-save-minutes/" rel="noopener noreferrer"&gt;k9s incident debugging: shortcuts and plugins that save minutes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/08/migrate-nvm-pyenv-and-tfenv-to-one-mise-toolchain-file/" rel="noopener noreferrer"&gt;Migrate nvm, pyenv and tfenv to one mise toolchain file&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>What changed in Grafana 13.3 alerting for ops teams</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Wed, 02 Dec 2026 08:02:01 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/what-changed-in-grafana-133-alerting-for-ops-teams-3cn1</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/what-changed-in-grafana-133-alerting-for-ops-teams-3cn1</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/12/02/what-changed-in-grafana-13-3-alerting-for-ops-teams" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;The on-call rotation is quiet and the Grafana container is pinned to an older 13.x tag. Then someone asks whether bumping to the new stable release is safe for the 400 alert rules that page people. That is the real question behind &lt;strong&gt;Grafana 13.3 alerting&lt;/strong&gt;. The question is not "what is new" but "what could silently stop notifying us".&lt;/p&gt;

&lt;p&gt;Grafana 13.3 shipped in October 2026 and is the current stable cycle, with 13.3.2 as the latest patch. The authoritative feature list is the &lt;a href="https://grafana.com/docs/grafana/latest/whatsnew/" rel="noopener noreferrer"&gt;Grafana what's new page&lt;/a&gt;. This runbook covers how to check that list against your alerting setup and move over without losing rules, routes or contact points.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Export all alerting configuration through the provisioning API.&lt;/li&gt;
&lt;li&gt;Read the 13.3 what's new and breaking-changes notes against your &lt;code&gt;grafana.ini&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Upgrade a staging instance first, with notifications disabled.&lt;/li&gt;
&lt;li&gt;Compare rule counts and evaluation-failure metrics before and after.&lt;/li&gt;
&lt;li&gt;Go to 13.3.2 rather than 13.3.0 if you are upgrading now.&lt;/li&gt;
&lt;li&gt;If you run HA alerting with several replicas on a shared database, plan the rollout order explicitly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;What changed and who is affected in Grafana 13.3 alerting&lt;/h2&gt;

&lt;p&gt;This article deliberately does not restate a feature-by-feature changelog from memory. Release notes are version-dependent, and the official page is the only source worth trusting for exact behavior. What can be said reliably is who needs to pay attention.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Teams with alert rules provisioned from files or Terraform/OpenTofu.&lt;/strong&gt; Schema or default changes can show up as provisioning errors at startup or as a plan diff.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Teams on HA alerting&lt;/strong&gt; (several Grafana replicas with &lt;code&gt;ha_peers&lt;/code&gt; and a shared database). Mixed versions during an upgrade are the main risk window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Teams routing to an external Alertmanager&lt;/strong&gt; or using Prometheus 3.16 as the data source. Check data source behavior separately, because the Prometheus side is its own upgrade.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Teams that edit rules in the UI&lt;/strong&gt; and also provision some. Mixed ownership makes diffs hard to read.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you only have a handful of dashboards with no alert rules, the upgrade is a normal application bump and most of this runbook is overkill. Everyone else needs some preparation time and a staging instance that mirrors production data sources.&lt;/p&gt;

&lt;h2&gt;Before/after config&lt;/h2&gt;

&lt;p&gt;The "before" state is whatever you run today. The "after" state should change as little as possible in one step. Pin the exact patch tag and keep the alerting section of your config explicit, so a diff against the 13.3 docs is easy to read.&lt;/p&gt;

&lt;p&gt;A compose fragment for a single-instance target state (no top-level &lt;code&gt;version:&lt;/code&gt; key, patch pinned, volume kept):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;services:
  grafana:
    image: grafana/grafana:13.3.2   # was: your current 13.x tag; never use :latest for upgrades
    environment:
      GF_UNIFIED_ALERTING_ENABLED: "true"
      # HA only: run separate services (grafana-1, grafana-2) that share a
      # MySQL/PostgreSQL database (GF_DATABASE_*), not a per-instance SQLite volume, then set:
      # GF_UNIFIED_ALERTING_HA_PEERS: "grafana-1:9094,grafana-2:9094"
    volumes:
      - grafana-data:/var/lib/grafana
      - ./provisioning:/etc/grafana/provisioning:ro   # rules, contact points, policies as files
volumes:
  grafana-data:
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Keep every alerting key you set in version control. That includes the &lt;code&gt;[unified_alerting]&lt;/code&gt; section, evaluation timeouts and the minimum interval. Then walk through the &lt;a href="https://grafana.com/docs/grafana/latest/alerting/" rel="noopener noreferrer"&gt;Grafana Alerting documentation&lt;/a&gt; and the 13.3 notes. Mark any key that is renamed, deprecated or has a changed default. If a key you set is not mentioned anywhere, leave it alone. Do not "tidy up" during the upgrade.&lt;/p&gt;

&lt;p&gt;For file provisioning, alerting files live under &lt;code&gt;/etc/grafana/provisioning/alerting/&lt;/code&gt;. Validate that your YAML still loads on staging before assuming it will in production.&lt;/p&gt;

&lt;h2&gt;Step-by-step migration&lt;/h2&gt;



&lt;p&gt;&lt;strong&gt;1. Export the current alerting state.&lt;/strong&gt; This is your rollback evidence and your diff baseline. Use a service account token with admin rights.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;export GRAFANA_URL=https://grafana.example.com
export GRAFANA_TOKEN="&amp;lt;service-account-token&amp;gt;"   # read from your secret store
mkdir -p backup/pre-13.3
for kind in alert-rules policies contact-points mute-timings; do
  curl -fsS -H "Authorization: Bearer $GRAFANA_TOKEN" \
    "$GRAFANA_URL/api/v1/provisioning/$kind/export?format=yaml" \
    -o "backup/pre-13.3/$kind.yaml"   # secure settings are redacted by default
done
curl -fsS -H "Authorization: Bearer $GRAFANA_TOKEN" \
  "$GRAFANA_URL/api/v1/provisioning/templates" -o backup/pre-13.3/templates.json
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Exports redact secrets by default. Webhook URLs and tokens must come from your secret store, not from these files. The templates endpoint returns plain JSON rather than a provisioning file. Keep it as a reference, or convert it to provisioning YAML if you plan to re-apply it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Back up the database.&lt;/strong&gt; Grafana's schema migrations run on startup, and downgrading against a migrated database is not supported. Copy the SQLite file from &lt;code&gt;/var/lib/grafana/grafana.db&lt;/code&gt; with Grafana stopped. If you use an external database, take a &lt;code&gt;pg_dump&lt;/code&gt;/&lt;code&gt;mysqldump&lt;/code&gt; instead. Without this, rollback means rebuilding from exports.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Upgrade staging first.&lt;/strong&gt; Restore the production database snapshot into staging. That snapshot contains your real contact points, so stop staging from evaluating and notifying before its first start. Set &lt;code&gt;GF_UNIFIED_ALERTING_EXECUTE_ALERTS=false&lt;/code&gt; and/or block outbound network access. Then start 13.3.2 and read the startup log for provisioning and migration errors.&lt;/p&gt;

&lt;p&gt;Once the logs are clean, you can re-enable evaluation with notifications still blocked. Repoint contact points to non-paging targets before allowing egress.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Upgrade production.&lt;/strong&gt; For a single instance: stop, bump the tag, start.&lt;/p&gt;

&lt;p&gt;For HA, all replicas share one database, and the first upgraded replica migrates its schema while older replicas are still using it. Mixed versions also gossip alert state with each other. Check the 13.3 upgrade notes for guidance on rolling upgrades. If the notes do not explicitly cover it, the conservative path is different:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stop all replicas.&lt;/li&gt;
&lt;li&gt;Start one on 13.3.2 so it runs the migrations.&lt;/li&gt;
&lt;li&gt;Verify it.&lt;/li&gt;
&lt;li&gt;Bring up the rest on the same tag.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;Verify and roll back&lt;/h2&gt;

&lt;p&gt;Verification is a comparison against step 1, not a feeling that dashboards load. Start with the version and health endpoint:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -fsS "$GRAFANA_URL/api/health"
# expected shape: {"database":"ok","version":"13.3.2","commit":"..."}

# rule count before vs after (yq v4)
curl -fsS -H "Authorization: Bearer $GRAFANA_TOKEN" \
  "$GRAFANA_URL/api/v1/provisioning/alert-rules/export?format=yaml" \
  -o backup/post-13.3-rules.yaml
yq '[.groups[].rules[]] | length' backup/pre-13.3/alert-rules.yaml backup/post-13.3-rules.yaml
diff backup/pre-13.3/policies.yaml &amp;lt;(curl -fsS -H "Authorization: Bearer $GRAFANA_TOKEN" \
  "$GRAFANA_URL/api/v1/provisioning/policies/export?format=yaml")
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The two counts must match, and the policy diff should be empty or explainable. Then watch Grafana's own metrics across several evaluation intervals. Confirm exact names on your &lt;code&gt;/metrics&lt;/code&gt; endpoint, since they are version-dependent. Evaluation counters such as &lt;code&gt;grafana_alerting_rule_evaluation_failures_total&lt;/code&gt; should not increase relative to the pre-upgrade rate. Finally, fire a test notification from each contact point in the UI and confirm it arrives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rollback:&lt;/strong&gt; stop Grafana (all replicas in HA), restore the database backup, and start the previous pinned tag. Do not start the old binary against a database that 13.3 already migrated.&lt;/p&gt;

&lt;p&gt;If the database restore is not possible, redeploy the old version fresh and re-apply the exported YAML via file provisioning. Templates need converting from JSON first. Then re-enter secrets manually.&lt;/p&gt;

&lt;h2&gt;Gotchas after the switch&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Watch out for silent no-data rules.&lt;/strong&gt; A rule can evaluate fine while its query now returns nothing. That triggers the no-data state you configured, which may be "OK" for some rules. Compare the count of firing and normal alert instances before and after, not just rule totals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out for duplicate or missing notifications in HA.&lt;/strong&gt; If replicas cannot reach each other on the gossip port (9094 by default), each sends its own copy. After an upgrade, confirm the peers list in the logs and check that a single test alert produces one notification.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Provisioned objects are read-only in the UI.&lt;/strong&gt; Incident fixes have to go through Git and a provisioning run. Workarounds applied by other means can be overwritten by the next provisioning run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Terraform/OpenTofu drift.&lt;/strong&gt; Run a plan right after the upgrade. A diff on rules you did not touch often means a changed default, so decide deliberately whether to accept it in code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prometheus 3.16 and Grafana move separately.&lt;/strong&gt; Upgrading both in one change window makes failures hard to attribute. Do one, verify, then the other.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost of this approach:&lt;/strong&gt; a staging instance and a database restore test. It is not free, but it is cheaper than discovering a broken route during an outage.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Last, put the pre-upgrade export in the same Git repository as your provisioning files, and tag the commit with the version you left. Then the next Grafana bump starts from a known baseline instead of a fresh export under pressure. For more on keeping dashboards and rules in code, browse the guides on &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/20/what-changed-in-prometheus-3-16-for-production-use/" rel="noopener noreferrer"&gt;What changed in Prometheus 3.16 for production use&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/11/grafana-dashboards-as-code-provisioning-without-the-ui/" rel="noopener noreferrer"&gt;Grafana dashboards as code: provisioning without the UI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/09/15/prometheus-and-grafana-docker-compose-setup-that-sticks/" rel="noopener noreferrer"&gt;Prometheus and Grafana Docker Compose Setup That Sticks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>monitoring</category>
      <category>devops</category>
    </item>
    <item>
      <title>ingress2gateway migration off ingress-nginx: fix what it misses</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Tue, 01 Dec 2026 08:01:51 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/ingress2gateway-migration-off-ingress-nginx-fix-what-it-misses-172f</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/ingress2gateway-migration-off-ingress-nginx-fix-what-it-misses-172f</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/12/01/ingress2gateway-migration-off-ingress-nginx-fix-what-it-misses" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;The scenario&lt;/h2&gt;

&lt;p&gt;A platform team has 140 Ingress objects behind ingress-nginx, each with a different pile of annotations, and a ticket that says "move to Gateway API." The first real ingress2gateway migration usually looks easy at first because the tool prints clean YAML. Then someone reads the warnings and finds that the rewrite rules, the auth annotation and a configuration snippet did not make it across.&lt;/p&gt;

&lt;p&gt;This matters now because ingress-nginx is retired: no more releases and no more security fixes, as the &lt;a href="https://kubernetes.io/blog/2025/11/11/ingress-nginx-retirement/" rel="noopener noreferrer"&gt;Kubernetes retirement announcement&lt;/a&gt; explains. A cluster still running it on Kubernetes 1.37 carries a controller that will never be patched again, and it sits on your public edge.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; export your Ingress objects, run &lt;code&gt;ingress2gateway print&lt;/code&gt; against the files, and treat the output as a first draft. Every warning it emits is a behavior you must re-create by hand, usually with an HTTPRoute filter or a controller-specific policy. This approach fits clusters with mostly standard host/path routing. If your routing depends on &lt;code&gt;configuration-snippet&lt;/code&gt; Lua or ModSecurity rules, expect real redesign work, or pick a maintained Ingress controller as an interim step.&lt;/p&gt;

&lt;h2&gt;Prerequisites&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Go toolchain (Go 1.27 is current) to install the CLI, or a release binary from the &lt;a href="https://github.com/kubernetes-sigs/ingress2gateway" rel="noopener noreferrer"&gt;kubernetes-sigs/ingress2gateway&lt;/a&gt; repository.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl&lt;/code&gt; access to read Ingresses, Services and IngressClasses in every namespace you plan to migrate.&lt;/li&gt;
&lt;li&gt;A Gateway API implementation you have chosen and installed, such as Envoy Gateway, Cilium, Istio, NGINX Gateway Fabric, or a cloud-managed one. The tool translates objects; it does not install a controller.&lt;/li&gt;
&lt;li&gt;The Gateway API CRDs at a version your controller supports. Check the &lt;a href="https://gateway-api.sigs.k8s.io/" rel="noopener noreferrer"&gt;Gateway API docs&lt;/a&gt; for the standard channel release notes.&lt;/li&gt;
&lt;li&gt;Room for a second load balancer. Running old and new side by side costs one extra LB and its IP until cutover is done.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flags and supported annotations change between releases, so run &lt;code&gt;ingress2gateway print --help&lt;/code&gt; and read the provider notes in the repo before trusting any example here.&lt;/p&gt;

&lt;h2&gt;Step 1: Run the ingress2gateway migration on real manifests&lt;/h2&gt;



&lt;p&gt;Work from files, not from the live cluster, so the run is repeatable and reviewable in Git. The commands below export the Ingresses and run the converter with the ingress-nginx provider.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;go install github.com/kubernetes-sigs/ingress2gateway@latest

mkdir -p migration/in migration/out
# Export all Ingresses (strip server-managed fields later in review)
kubectl get ingress -A -o yaml &amp;gt; migration/in/ingresses.yaml

# Translate; capture both streams separately
ingress2gateway print \
  --providers=ingress-nginx \
  --input-file=migration/in/ingresses.yaml \
  &amp;gt; migration/out/gateway-api.yaml 2&amp;gt; migration/out/warnings.txt

# Depending on the release, the notification table may be printed to stdout
# after the YAML. If so, move it out of gateway-api.yaml into warnings.txt.
grep -n -i 'notification' migration/out/gateway-api.yaml
wc -l migration/out/warnings.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;🧪 Lab — try this in your browser&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://tools.kuryzhev.cloud/?utm_source=devto&amp;amp;utm_medium=lab&amp;amp;utm_campaign=ingress2gateway-migration-off-ingress-nginx-fix-what-it-misses#nginxaudit" rel="noopener noreferrer"&gt;Nginx Config Analyzer&lt;/a&gt; — Parses nginx configuration into a block tree and audits it for TLS, security, routing and performance problems, with line numbers and a 0-100 score.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://tools.kuryzhev.cloud/?utm_source=devto&amp;amp;utm_medium=lab&amp;amp;utm_campaign=ingress2gateway-migration-off-ingress-nginx-fix-what-it-misses#k8sgen" rel="noopener noreferrer"&gt;Kubernetes YAML Generator&lt;/a&gt; — Generate Kubernetes Deployment, Service, Ingress, ConfigMap, Secret, HPA, PDB and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep the warnings, wherever your version prints them. They are your work list. In the documented behavior, annotations the tool does not understand are reported rather than silently carried over. That means a short warnings list on a complicated cluster is itself suspicious, so check that the input actually contained all your namespaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out:&lt;/strong&gt; do not &lt;code&gt;kubectl apply&lt;/code&gt; the output straight away. The generated Gateway names a &lt;code&gt;gatewayClassName&lt;/code&gt; derived from your input, and it may not match any GatewayClass that exists in your cluster.&lt;/p&gt;

&lt;h2&gt;Step 2: Fix what the tool misses&lt;/h2&gt;

&lt;p&gt;Sort the warnings into three buckets.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Direct equivalents.&lt;/strong&gt; Some annotations map to standard-channel features. Redirects, prefix rewrites, header changes and per-rule timeouts map to &lt;code&gt;RequestRedirect&lt;/code&gt;, &lt;code&gt;URLRewrite&lt;/code&gt;, header-modifier filters and the &lt;code&gt;timeouts&lt;/code&gt; field.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Controller-specific.&lt;/strong&gt; Rate limiting, external auth and body-size limits are not portable. They live in controller-specific policy objects. CORS and retries are also missing from the standard channel; recent Gateway API releases define them only in the experimental channel, so whether you can use them depends on your controller.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No equivalent.&lt;/strong&gt; Snippet annotations have no equivalent at all.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a hand-fixed route for a typical ingress-nginx &lt;code&gt;rewrite-target&lt;/code&gt; plus &lt;code&gt;proxy-read-timeout&lt;/code&gt; pair that the converter flagged.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: orders-api
  namespace: shop
spec:
  parentRefs:
    - name: public-gw          # must match the Gateway you actually deploy
      namespace: gateway-system
  hostnames: ["api.example.com"]
  rules:
    - matches:
        - path: { type: PathPrefix, value: /orders }
      filters:
        - type: URLRewrite
          urlRewrite:
            path:
              type: ReplacePrefixMatch
              replacePrefixMatch: /v2   # replaces the old rewrite-target
      timeouts:
        backendRequest: 60s            # closest analogue to proxy-read-timeout: "60"
      backendRefs:
        - name: orders
          port: 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The timeout semantics are not identical. &lt;code&gt;proxy-read-timeout&lt;/code&gt; limits the gap between two reads from the upstream. &lt;code&gt;timeouts.backendRequest&lt;/code&gt; bounds the whole backend request. Long-polling or streaming endpoints may need a larger value, or a controller-specific setting.&lt;/p&gt;

&lt;p&gt;Regex rewrites with capture groups are the common sore spot, because ingress-nginx allowed them and the standard filters do not. Either flatten them into several explicit prefix rules or check whether your controller offers a regex extension.&lt;/p&gt;

&lt;p&gt;For the non-portable bucket, look up the policy kind in your controller's docs. For example, Envoy Gateway documents its own policy resources for auth and rate limits, while other implementations use different names. Backend HTTPS (&lt;code&gt;backend-protocol: HTTPS&lt;/code&gt;) maps to a BackendTLSPolicy where your implementation supports it. Verify its API version in the Gateway API release you installed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out:&lt;/strong&gt; authentication annotations like &lt;code&gt;auth-url&lt;/code&gt; fail open in the worst way. If the policy is missing, the route may simply serve traffic unauthenticated. Review each of these by hand and test with an unauthenticated request.&lt;/p&gt;

&lt;h2&gt;Step 3: Deploy beside ingress-nginx, not over it&lt;/h2&gt;

&lt;p&gt;Create the GatewayClass and Gateway from your controller's documentation, with listeners and TLS secrets that match the old setup. Then apply the reviewed routes. Both stacks now serve the same hostnames from different load balancer addresses, and DNS still points at the old one.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl apply -f migration/gateway.yaml          # GatewayClass + Gateway, hand-written
kubectl apply -f migration/out/gateway-api.yaml  # reviewed and edited output

kubectl get gateway -n gateway-system public-gw
kubectl get httproute -A
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;TLS is the usual stumbling block. A Gateway listener references its certificate Secret in its own namespace unless a ReferenceGrant allows otherwise. cert-manager also needs Gateway API support enabled before it will issue certificates from Gateway resources. Check the cert-manager docs for the flag your version needs.&lt;/p&gt;

&lt;h2&gt;Step 4: Shift traffic with DNS&lt;/h2&gt;

&lt;p&gt;Lower the record TTL a day ahead. Move one low-risk hostname to the new Gateway address, watch error rates, then move the rest in batches. Keep ingress-nginx running until access logs show no meaningful traffic, because DNS caches and hardcoded clients linger. Do not leave it there for months, since the controller will not receive security fixes.&lt;/p&gt;

&lt;p&gt;Roll back by pointing the record back at the old load balancer. That is the whole point of the parallel setup, and it is why the extra LB cost is worth paying.&lt;/p&gt;

&lt;h2&gt;Verify and test&lt;/h2&gt;

&lt;p&gt;First, check that the control plane accepted everything. Each HTTPRoute should report &lt;code&gt;Accepted=True&lt;/code&gt; and &lt;code&gt;ResolvedRefs=True&lt;/code&gt; under its parent status.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl get httproute -A -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}{"\t"}{range .status.parents[*].conditions[*]}{.type}={.status} {end}{"\n"}{end}'
# expected shape: shop/orders-api  Accepted=True ResolvedRefs=True

# --resolve needs an IP; if your cloud LB reports a hostname, resolve it first
GW_IP=$(kubectl get gateway -n gateway-system public-gw -o jsonpath='{.status.addresses[0].value}')
curl -sS -o /dev/null -w '%{http_code}\n' --resolve api.example.com:443:$GW_IP https://api.example.com/orders/health
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Second, diff behavior, not YAML. Send the same list of URLs to the old and the new address with &lt;code&gt;--resolve&lt;/code&gt;. Compare status codes, redirect &lt;code&gt;Location&lt;/code&gt; headers and rewritten paths. Include requests that should be rejected: no token, oversized body, wrong host. A route that passes every happy-path check but returns 200 on the rejection cases has lost a policy.&lt;/p&gt;

&lt;p&gt;Third, watch real metrics during the DNS shift. Track 5xx ratio and p95 latency per hostname from your controller's metrics endpoint, and compare them with the ingress-nginx baseline from the day before. More Kubernetes upgrade notes live on &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Closing&lt;/h2&gt;

&lt;p&gt;The converter handles the tedious bulk of the translation, and its warning list tells you where the remainder hides. Budget time for that remainder, especially auth, rate limits and snippets, because those are the behaviors that break quietly. If the warning list is dominated by snippets and custom Lua, a staged move to another maintained controller may be cheaper than forcing everything into HTTPRoute. For everything else, use a parallel Gateway, hand-fixed routes and a DNS-based cutover. That gives you a migration you can reverse as quickly as your DNS TTLs and client caches allow.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/10/26/buildkit-cache-misses-in-ci-three-mistakes-and-a-safer-pattern/" rel="noopener noreferrer"&gt;BuildKit Cache Misses in CI: Three Mistakes and a Safer Pattern&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/10/11/kubernetes-ingress-manifest-or-gateway-api-which-to-ship/" rel="noopener noreferrer"&gt;Kubernetes Ingress Manifest or Gateway API: Which to Ship&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/30/cosign-sbom-attestation-for-every-image-in-ci/" rel="noopener noreferrer"&gt;Cosign SBOM attestation for every image in CI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>Cosign SBOM attestation for every image in CI</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Mon, 30 Nov 2026 08:02:06 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/cosign-sbom-attestation-for-every-image-in-ci-54b</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/cosign-sbom-attestation-for-every-image-in-ci-54b</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/30/cosign-sbom-attestation-for-every-image-in-ci" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;A new CVE lands on a Friday. Someone asks "which of our running images contain that library?", and the answer is a scramble through Dockerfiles and lockfiles. A cosign SBOM attestation fixes that at the source. Every image pushed by CI carries a signed, machine-readable list of what is inside it, stored next to the image in the registry.&lt;/p&gt;

&lt;p&gt;The timing matters. Since 11 September 2026, the EU Cyber Resilience Act requires manufacturers to report actively exploited vulnerabilities, with a 24-hour early warning and a 72-hour notification, as described on the &lt;a href="https://digital-strategy.ec.europa.eu/en/policies/cra-reporting" rel="noopener noreferrer"&gt;European Commission's CRA reporting page&lt;/a&gt;. You cannot report on a component you cannot find, and an SBOM you can query is the fastest way to find it. If you ship products with digital elements into the EU market, this is now operational, not nice-to-have.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; in the CI job that builds the image, use Syft to generate a CycloneDX or SPDX SBOM from the pushed image digest. Then run &lt;code&gt;cosign attest&lt;/code&gt; against that same digest, using keyless signing from your CI's OIDC identity. Verify with &lt;code&gt;cosign verify-attestation&lt;/code&gt; pinned to your workflow identity. Skip it if you only build throwaway images that never leave a dev machine.&lt;/p&gt;

&lt;h2&gt;What a cosign SBOM attestation actually does&lt;/h2&gt;



&lt;p&gt;An attestation is a signed statement about an artifact. It follows the in-toto format, which has three parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;em&gt;subject&lt;/em&gt; (your image digest)&lt;/li&gt;
&lt;li&gt;a &lt;em&gt;predicate type&lt;/em&gt; (for example CycloneDX)&lt;/li&gt;
&lt;li&gt;a &lt;em&gt;predicate&lt;/em&gt; (the SBOM itself)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cosign wraps this in a DSSE envelope, signs it, and pushes it to the registry as an OCI artifact referencing the image.&lt;/p&gt;

&lt;p&gt;Two properties make this stronger than "upload sbom.json as a build artifact":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It is bound to a digest.&lt;/strong&gt; The statement cannot be silently reused for a different image.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It records which workflow made the claim.&lt;/strong&gt; With keyless signing, the signature carries a short-lived certificate from Sigstore's Fulcio CA that identifies the workflow. A consumer can then verify "this SBOM was produced by the main-branch release workflow of this repository," not just "someone with a key said so."&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What it does not do: it does not prove the SBOM is complete or that the image is free of vulnerabilities. It proves who generated the list and that the list belongs to this exact image. Quality still depends on the scanner and on how you build.&lt;/p&gt;

&lt;h2&gt;How people use it wrong&lt;/h2&gt;

&lt;p&gt;The failures below are common mistakes, not exotic edge cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Attesting a tag instead of a digest.&lt;/strong&gt; Tags move. If you run &lt;code&gt;cosign attest&lt;/code&gt; against &lt;code&gt;app:latest&lt;/code&gt;, the signature is tied to whatever the tag resolved to at that moment, and cosign warns about it. Always use &lt;code&gt;repo@sha256:...&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Generating the SBOM from the source tree.&lt;/strong&gt; Scanning the repo misses base image packages, OS libraries and anything copied in during the build. Scan the built image.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Using the old &lt;code&gt;cosign attach sbom&lt;/code&gt; flow.&lt;/strong&gt; It attaches an unsigned blob and has been deprecated for a long time. An unsigned SBOM is just a file anyone could replace.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long-lived private keys in CI secrets.&lt;/strong&gt; They leak, they rarely get rotated, and they tell a verifier nothing about the build. Prefer keyless signing via OIDC.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attesting and never verifying.&lt;/strong&gt; If nothing checks the attestation, you have added build time and registry clutter, not security.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watch out for:&lt;/strong&gt; keyless signing writes to the public Rekor transparency log by default, which exposes the repository identity and image digest. If your repository or image names are confidential, plan for a private Sigstore deployment, or review the tlog options in the &lt;a href="https://docs.sigstore.dev/" rel="noopener noreferrer"&gt;Sigstore documentation&lt;/a&gt; before enabling it.&lt;/p&gt;

&lt;h2&gt;The correct approach: generate from the digest, attest keyless, verify by identity&lt;/h2&gt;

&lt;p&gt;The flow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build and push.&lt;/li&gt;
&lt;li&gt;Capture the digest.&lt;/li&gt;
&lt;li&gt;Scan that digest.&lt;/li&gt;
&lt;li&gt;Attest that digest.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The job needs &lt;code&gt;id-token: write&lt;/code&gt; for the OIDC token and &lt;code&gt;packages: write&lt;/code&gt; (or your registry's equivalent) to push the attestation. Pin third-party actions to the current major version or, better, a commit SHA. GHCR requires lowercase repository names, so the workflow normalises the image name before using it.&lt;/p&gt;

&lt;p&gt;This GitHub Actions job builds an image, generates a CycloneDX SBOM from the pushed digest and attaches it as an attestation:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# .github/workflows/build.yml
name: build
on:
  push:
    branches: [main]

permissions:
  contents: read
  packages: write      # push image + attestation to GHCR
  id-token: write      # required for keyless signing (OIDC)

jobs:
  image:
    runs-on: ubuntu-latest
    steps:
      - name: Normalise image name (GHCR requires lowercase)
        run: echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" &amp;gt;&amp;gt; "$GITHUB_ENV"
      - uses: actions/checkout@v6
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ "{{" }} github.actor }}
          password: ${{ "{{" }} secrets.GITHUB_TOKEN }}
      - id: build
        uses: docker/build-push-action@v6
        with:
          push: true
          tags: ${{ "{{" }} env.IMAGE }}:${{ "{{" }} github.sha }}
      - uses: sigstore/cosign-installer@v3   # use the current major from the action's README
      - uses: anchore/sbom-action/download-syft@v0
      - name: SBOM + attest
        env:
          DIGEST: ${{ "{{" }} steps.build.outputs.digest }}
        run: |
          REF="${IMAGE}@${DIGEST}"                       # digest, never a tag
          syft scan "registry:${REF}" -o cyclonedx-json=sbom.cdx.json
          cosign attest --yes --type cyclonedx --predicate sbom.cdx.json "${REF}"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now verify from any machine. The identity regexp is the important part: it pins the workflow file and branch, so an attestation from a fork, a feature branch or a different workflow fails.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;REF=ghcr.io/org/repo@sha256:&amp;lt;digest&amp;gt;

cosign verify-attestation --type cyclonedx \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity-regexp '^https://github\.com/ORG/REPO/\.github/workflows/build\.yml@refs/heads/main$' \
  "$REF" \
| jq -r '.payload' | base64 -d | jq '.predicate.components | length'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;How to confirm it worked:&lt;/strong&gt; cosign reports that the claims were validated and the signatures verified, and the final command prints a component count greater than zero. A non-zero exit code with an identity mismatch message means your regexp or workflow path is wrong. Output details can vary between cosign major versions, so check the release notes of the version you install.&lt;/p&gt;

&lt;h2&gt;Advanced patterns&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Enforce at deploy time.&lt;/strong&gt; Attestations earn their keep when something rejects images without them. Cosign can evaluate a policy during &lt;code&gt;verify-attestation --policy&lt;/code&gt;, and Kubernetes admission controllers such as Kyverno can require a verified attestation of a given type. The cluster side is covered in a separate piece on &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt; about verifying cosign signatures at admission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query the stored SBOMs, don't just keep them.&lt;/strong&gt; For the "are we affected?" question, pull the attestation for each deployed digest and feed it to a scanner. Keep the same strict identity pin here. A loose regexp would accept SBOMs produced by any workflow or branch in the repository. If a digest carries more than one CycloneDX attestation, cosign prints one per line, so take the first to keep the file valid JSON:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cosign verify-attestation --type cyclonedx \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity-regexp '^https://github\.com/ORG/REPO/\.github/workflows/build\.yml@refs/heads/main$' \
  "$REF" \
| head -n 1 | jq -r '.payload' | base64 -d | jq '.predicate' &amp;gt; sbom.cdx.json

grype sbom:sbom.cdx.json --fail-on high   # fails the pipeline or the audit script
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Add VEX next to the SBOM.&lt;/strong&gt; An SBOM lists everything; a VEX statement says "this CVE is present but not exploitable here." Attaching VEX as a second attestation with a different &lt;code&gt;--type&lt;/code&gt; cuts triage noise. It also supports the exploitability reasoning you may need inside a 72-hour notification window.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-arch images.&lt;/strong&gt; Packages can differ between architectures, so decide whether one SBOM is enough:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One SBOM per platform:&lt;/strong&gt; run Syft once per platform with &lt;code&gt;--platform&lt;/code&gt;, and attest each SBOM to that platform's manifest digest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A single SBOM:&lt;/strong&gt; attest it to the index digest.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure your verification and admission policy check the digest you actually attested.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BuildKit's built-in SBOM&lt;/strong&gt; (&lt;code&gt;sbom: true&lt;/code&gt; on build-push-action) produces a BuildKit attestation. That is a different mechanism with a different verification story. It is convenient, but it is not signed by your CI identity. Choose one path deliberately rather than shipping both by accident.&lt;/p&gt;

&lt;h2&gt;Performance notes&lt;/h2&gt;

&lt;p&gt;The cost is real but modest, and it lands in four places.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scanning&lt;/strong&gt; is usually the largest. Syft has to pull and catalogue the image layers, so time grows with image size and package count. Scan once per digest, not once per tag. Trim your images (distroless or slim bases) so the SBOM is smaller and the scan faster.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signing&lt;/strong&gt; adds network round-trips to Fulcio and, with the public log, to Rekor. The overhead is usually small compared with the scan, but it makes CI dependent on external services. Decide up front whether a Sigstore outage should fail the release or only warn. Failing closed is safer for regulated products; failing open keeps hotfixes flowing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Size limits.&lt;/strong&gt; Very large SBOMs can run into registry artifact limits or transparency-log entry limits. The exact thresholds are version and service dependent, so verify them in the Sigstore and registry docs rather than assuming. If you hit them, generate a leaner SBOM (omit file-level cataloguing) or use a private log.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The registry bill.&lt;/strong&gt; Each attestation is an extra small artifact per digest. Garbage-collect attestations together with the images they describe, or your retention policy will leave orphans pointing at deleted digests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When not to bother:&lt;/strong&gt; internal prototypes, images rebuilt hourly that nothing consumes, or teams with no admission policy or scanning process to read the result. Start with the images you actually ship to customers or production clusters, and expand once verification is wired in.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/24/verify-cosign-signatures-at-admission-in-kubernetes/" rel="noopener noreferrer"&gt;Verify cosign signatures at admission in Kubernetes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/10/14/ecr-image-scan-gate-in-gitlab-ci-passes-vulnerable-images/" rel="noopener noreferrer"&gt;ECR Image Scan Gate in GitLab CI Passes Vulnerable Images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/29/replace-pip-and-virtualenv-with-uv-in-ci-images/" rel="noopener noreferrer"&gt;Replace pip and virtualenv with uv in CI images&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>Replace pip and virtualenv with uv in CI images</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Sun, 29 Nov 2026 08:01:56 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/replace-pip-and-virtualenv-with-uv-in-ci-images-bm8</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/replace-pip-and-virtualenv-with-uv-in-ci-images-bm8</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/29/replace-pip-and-virtualenv-with-uv-in-ci-images" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Adopting uv in CI images usually starts with a Dockerfile everyone has copied for years: &lt;code&gt;python -m venv /opt/venv&lt;/code&gt;, &lt;code&gt;pip install -r requirements.txt&lt;/code&gt;, and a cache layer that is invalidated by every dependency bump. The build works, but it is slow to rebuild, and nothing guarantees that two builds a week apart resolve the same transitive versions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; if your CI installs Python dependencies on every run or image build, switch the install step to &lt;code&gt;uv sync --locked&lt;/code&gt; against a committed &lt;code&gt;uv.lock&lt;/code&gt;. Keep the old pip path available for one release cycle. Do it per repository, not fleet-wide in one go. Skip it if your builds depend on conda environments or on pip behavior you cannot yet express in &lt;code&gt;pyproject.toml&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;What changed and who is affected&lt;/h2&gt;

&lt;p&gt;uv, from Astral, is a single Rust binary that replaces several tools at once: &lt;code&gt;pip&lt;/code&gt;, &lt;code&gt;virtualenv&lt;/code&gt;/&lt;code&gt;venv&lt;/code&gt;, &lt;code&gt;pip-tools&lt;/code&gt;, and (optionally) &lt;code&gt;pyenv&lt;/code&gt;-style interpreter management. It resolves, locks, and installs. The full reference is in the &lt;a href="https://docs.astral.sh/uv/" rel="noopener noreferrer"&gt;uv documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For CI, three things change in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The lockfile becomes the contract.&lt;/strong&gt; &lt;code&gt;uv.lock&lt;/code&gt; pins every transitive dependency across platforms. &lt;code&gt;requirements.txt&lt;/code&gt; becomes an export, not the source of truth.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The install step is a project sync.&lt;/strong&gt; &lt;code&gt;uv sync&lt;/code&gt; creates &lt;code&gt;.venv&lt;/code&gt; and installs exactly what the lock says. There is no separate venv-creation step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interpreters can come from uv.&lt;/strong&gt; uv can download Python builds itself. This matters if your base image currently pins the interpreter. Python 3.15 is the current stable release, but check which minor version your project actually supports.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Affected: any team with Dockerfiles, GitHub Actions, GitLab CI or Jenkins agents that run &lt;code&gt;pip install&lt;/code&gt;. Least affected: libraries that only run tests in a matrix. Most affected: monorepos with several &lt;code&gt;requirements*.txt&lt;/code&gt; files and private package indexes.&lt;/p&gt;

&lt;h2&gt;Before/after config for uv in CI images&lt;/h2&gt;

&lt;p&gt;Here is the typical "before" and the replacement. The "after" is a multi-stage build that copies the uv binary from its official image, so the version is pinned explicitly.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# BEFORE: pip + venv
FROM python:3.15-slim
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;# AFTER: uv + lockfile
ARG UV_VERSION=&amp;lt;pin-a-version-from-the-uv-releases-page&amp;gt;
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv

FROM python:3.15-slim
COPY --from=uv /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1 \
    UV_LINK_MODE=copy \
    UV_PYTHON_DOWNLOADS=never \
    PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# Dependencies first: this layer only rebuilds when the lock changes
COPY pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --locked --no-install-project --no-dev
COPY . .
RUN --mount=type=cache,target=/root/.cache/uv \
    uv sync --locked --no-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here is what the key settings do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--locked&lt;/code&gt; fails the build if &lt;code&gt;uv.lock&lt;/code&gt; is out of date with &lt;code&gt;pyproject.toml&lt;/code&gt;. That is the behavior you want in CI.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;UV_LINK_MODE=copy&lt;/code&gt; avoids hardlink warnings when the cache mount sits on a different filesystem from the target.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;UV_PYTHON_DOWNLOADS=never&lt;/code&gt; forces uv to use the interpreter already in the image instead of fetching another one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also add a &lt;code&gt;.dockerignore&lt;/code&gt; that excludes &lt;code&gt;.venv&lt;/code&gt;. Otherwise &lt;code&gt;COPY . .&lt;/code&gt; can copy a developer's local virtual environment over the one built in the image.&lt;/p&gt;

&lt;h2&gt;Step-by-step migration&lt;/h2&gt;



&lt;p&gt;Run these on a branch, one repository at a time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Snapshot the current environment.&lt;/strong&gt; This is your comparison baseline.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# inside the CURRENT CI image
pip freeze | sort &amp;gt; /tmp/before.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;2. Import existing requirements into a project.&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;uv init --bare                       # creates pyproject.toml only
uv add -r requirements.txt           # records deps in pyproject.toml
uv add --dev -r requirements-dev.txt # dev group; skip if you have none
uv python pin 3.15                   # writes .python-version
uv lock                              # writes uv.lock
git add pyproject.toml uv.lock .python-version
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If the repo is a library with its own build backend, add a &lt;code&gt;[build-system]&lt;/code&gt; table first. Without one, uv treats it as a non-package project, which is fine for services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Switch the install step.&lt;/strong&gt; Replace the Dockerfile as shown above. In GitHub Actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;actions/checkout&lt;/code&gt; at its current major.&lt;/li&gt;
&lt;li&gt;Use the &lt;code&gt;astral-sh/setup-uv&lt;/code&gt; action, pinned to the major listed in its README.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;uv sync --locked&lt;/code&gt; and &lt;code&gt;uv run pytest&lt;/code&gt; instead of activating a venv.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Add a lock-drift gate.&lt;/strong&gt; Put &lt;code&gt;uv lock --check&lt;/code&gt; in the lint stage. A pull request that edits &lt;code&gt;pyproject.toml&lt;/code&gt; without updating the lock then fails early.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Replace activation with &lt;code&gt;uv run&lt;/code&gt;.&lt;/strong&gt; Anything in your pipeline that did &lt;code&gt;source venv/bin/activate&lt;/code&gt; can become &lt;code&gt;uv run &amp;lt;cmd&amp;gt;&lt;/code&gt;. Alternatively, rely on &lt;code&gt;.venv/bin&lt;/code&gt; being on &lt;code&gt;PATH&lt;/code&gt; in the image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Trim the cache.&lt;/strong&gt; For CI caches that persist between runs, finish the job with &lt;code&gt;uv cache prune --ci&lt;/code&gt;. Per the documented CI guidance, it removes pre-built wheels and unpacked source distributions, which are cheap to re-download. It keeps wheels built from source, which are costly to rebuild.&lt;/p&gt;

&lt;h2&gt;Verify and roll back&lt;/h2&gt;

&lt;p&gt;Compare the new image to the baseline before merging.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# inside the NEW image
uv pip freeze | sort &amp;gt; /tmp/after.txt
diff /tmp/before.txt /tmp/after.txt   # expect only intended version moves
uv pip check                          # expect: "All installed packages are compatible"
uv sync --locked --no-dev --dry-run   # expect no changes planned
python -c "import sys; print(sys.prefix)"   # expect a path ending in /app/.venv
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Expect some differences in the diff:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unpinned transitive dependencies.&lt;/strong&gt; Versions can move where the old &lt;code&gt;requirements.txt&lt;/code&gt; did not pin them. Review each one; this is where an unpinned package may have been drifting silently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Package names.&lt;/strong&gt; Names may also differ in case or separator style between the two tools. Normalize them before treating a line as a real change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then run the full test suite in the new image, not just an import check. Image build time and the size of the final layer in your registry are the most useful numbers to compare.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rollback plan.&lt;/strong&gt; Keep the old Dockerfile as &lt;code&gt;Dockerfile.pip&lt;/code&gt; for one release cycle, and keep the previous image tag in the registry. If you must fall back without reverting the repository layout, export the lock:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;uv export --format requirements-txt --no-dev -o requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That yields a pinned, hash-checked &lt;code&gt;requirements.txt&lt;/code&gt; that plain pip can install. The pip path keeps working during the transition.&lt;/p&gt;

&lt;h2&gt;Gotchas after the switch&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Watch out for index resolution differences.&lt;/strong&gt; pip with &lt;code&gt;--extra-index-url&lt;/code&gt; considers all indexes together. uv's default strategy uses the first index that has the package. This protects against dependency confusion, but it breaks setups that relied on the old merge behavior. Define named indexes in &lt;code&gt;pyproject.toml&lt;/code&gt;, and check the documented index strategy options before changing it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out for private index credentials.&lt;/strong&gt; Credentials that lived in &lt;code&gt;pip.conf&lt;/code&gt; or &lt;code&gt;PIP_INDEX_URL&lt;/code&gt; do not carry over. You have two options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For a named index, use uv's per-index environment variables (&lt;code&gt;UV_INDEX_&amp;lt;NAME&amp;gt;_USERNAME&lt;/code&gt; and &lt;code&gt;UV_INDEX_&amp;lt;NAME&amp;gt;_PASSWORD&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Inject a &lt;code&gt;.netrc&lt;/code&gt; as a build secret.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Never bake a token into a layer. Confirm the exact variable names in the docs for your uv version.&lt;/p&gt;

&lt;p&gt;More traps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Venv path must match.&lt;/strong&gt; If you copy &lt;code&gt;.venv&lt;/code&gt; between build stages, keep the same absolute path (&lt;code&gt;/app/.venv&lt;/code&gt;) in both. Otherwise scripts with hardcoded shebangs break.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local venvs in the build context.&lt;/strong&gt; Without a &lt;code&gt;.dockerignore&lt;/code&gt; entry for &lt;code&gt;.venv&lt;/code&gt;, &lt;code&gt;COPY . .&lt;/code&gt; can clobber the image's environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-root users.&lt;/strong&gt; The cache mount targets &lt;code&gt;/root/.cache/uv&lt;/code&gt;. If the build runs as another user, change the mount target and set &lt;code&gt;UV_CACHE_DIR&lt;/code&gt; to match.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CUDA and platform wheels.&lt;/strong&gt; Packages like PyTorch need an explicit index. Define it as a &lt;code&gt;[[tool.uv.index]]&lt;/code&gt; entry and map the package to it in &lt;code&gt;[tool.uv.sources]&lt;/code&gt;. The default PyPI wheel may not be the variant you ship.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bot support.&lt;/strong&gt; Confirm your dependency-update bot reads &lt;code&gt;uv.lock&lt;/code&gt; before you delete &lt;code&gt;requirements.txt&lt;/code&gt;. Otherwise updates will stop quietly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cost and when not to switch:&lt;/strong&gt; you take on a new tool whose lock format is uv-specific, so moving away later means exporting. Conda-based images, or builds that rely on pip plugins and exotic resolver flags, are poor first candidates. For other CI tooling consolidation, see more runbooks on &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/10/14/ecr-image-scan-gate-in-gitlab-ci-passes-vulnerable-images/" rel="noopener noreferrer"&gt;ECR Image Scan Gate in GitLab CI Passes Vulnerable Images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/15/self-hosted-runners-vs-github-hosted-after-the-price-cut/" rel="noopener noreferrer"&gt;Self-Hosted Runners vs GitHub-Hosted After the Price Cut&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/06/cra-vulnerability-reporting-a-24h-and-72h-runbook-for-small-teams/" rel="noopener noreferrer"&gt;CRA vulnerability reporting: a 24h and 72h runbook for small teams&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>Fix Ollama CPU offload when the GPU model runs slow</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Sat, 28 Nov 2026 08:01:45 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/fix-ollama-cpu-offload-when-the-gpu-model-runs-slow-4d5i</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/fix-ollama-cpu-offload-when-the-gpu-model-runs-slow-4d5i</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/28/fix-ollama-cpu-offload-when-the-gpu-model-runs-slow" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;Failure scenario: the GPU is "in use" but the model crawls&lt;/h2&gt;



&lt;p&gt;A typical case of Ollama CPU offload goes like this. A developer has a 16 GB GPU and a mid-sized quantized model that answered quickly all week. Then they point a coding agent or IDE plugin at it and raise the context window to 32k so it can read more files. Generation drops from fluent to a token every few hundred milliseconds. Nothing errors, and the model still answers, only slowly.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nvidia-smi&lt;/code&gt; shows VRAM nearly full, so everything looks fine. But GPU utilization is low and a few CPU cores are pinned. Part of the model is running on the CPU, and Ollama did not announce it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; run &lt;code&gt;ollama ps&lt;/code&gt; and read the &lt;code&gt;PROCESSOR&lt;/code&gt; column. If it says anything other than &lt;code&gt;100% GPU&lt;/code&gt;, the model plus its context cache no longer fits in VRAM. Lower &lt;code&gt;num_ctx&lt;/code&gt;, quantize the KV cache, cut parallel slots, or pick a smaller model or quant until it reads &lt;code&gt;100% GPU&lt;/code&gt; again. This applies whenever a model that used to be fast slows down after a context, model or tooling change.&lt;/p&gt;

&lt;p&gt;The symptom is easy to misdiagnose because nothing breaks. The server stays up, the API returns 200s, and quality is unchanged. Only latency gets worse. CPU-bound token generation can be several times slower than a fully GPU-resident run, and the exact ratio depends on your hardware.&lt;/p&gt;

&lt;h2&gt;Why it happens: weights are not the only thing in VRAM&lt;/h2&gt;

&lt;p&gt;Ollama loads model weights into VRAM, and it also allocates a KV cache for the context window. That cache grows linearly with context length, so doubling &lt;code&gt;num_ctx&lt;/code&gt; roughly doubles it. A model whose weights fit with room to spare at a small context can overflow once the context is raised.&lt;/p&gt;

&lt;p&gt;When the total does not fit, Ollama does not refuse to load. It splits the model by layers and keeps what fits on the GPU. The rest runs on the CPU from system RAM. Every token then crosses that boundary, and the slow CPU layers set the pace for the whole pass. This is the documented fallback behavior. It is also why a 10% spill can feel much worse than 10% slower.&lt;/p&gt;

&lt;p&gt;Several things inflate memory without you touching the model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client-side context overrides.&lt;/strong&gt; Many tools send &lt;code&gt;options.num_ctx&lt;/code&gt; per request, overriding whatever you set in a Modelfile or on the server. Check what the client actually sends.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallel slots.&lt;/strong&gt; &lt;code&gt;OLLAMA_NUM_PARALLEL&lt;/code&gt; multiplies the context memory, because each slot needs its own share.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A second loaded model.&lt;/strong&gt; Models stay resident for the keep-alive period (five minutes by default). A chat model and an embedding model can share the card and push each other into offload.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default context changes.&lt;/strong&gt; Recent Ollama releases may choose a default context based on available VRAM. This is version-dependent, so verify against the &lt;a href="https://docs.ollama.com/" rel="noopener noreferrer"&gt;official Ollama docs&lt;/a&gt; for your installed version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No GPU at all.&lt;/strong&gt; A container started without &lt;code&gt;--gpus=all&lt;/code&gt;, or a driver that stopped loading after a kernel update, means 100% CPU. &lt;code&gt;ollama ps&lt;/code&gt; shows that too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watch out for:&lt;/strong&gt; &lt;code&gt;nvidia-smi&lt;/code&gt; alone will not tell you this. Full VRAM is normal in both the healthy and the offloaded case. The split lives in Ollama's own view.&lt;/p&gt;

&lt;h2&gt;The fix: size the context to the card, then verify&lt;/h2&gt;

&lt;p&gt;First, confirm the diagnosis. Load the model the way your tool does by sending a real request, then check:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Which processor is each loaded model on?
ollama ps
# Expected shape when healthy:
#   NAME   ID   SIZE   PROCESSOR   CONTEXT   UNTIL
#   ...                100% GPU    ...
# Offloaded shape: a split like "NN%/MM% CPU/GPU" in PROCESSOR

# Watch VRAM while you test
nvidia-smi --query-gpu=memory.used,memory.total --format=csv -l 2

# On a systemd install, the server log reports how many layers went to the GPU
journalctl -u ollama --since "10 min ago" | grep -i -E "offload|layers"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If the processor column shows a split, apply server-level settings. On Linux with systemd, run &lt;code&gt;sudo systemctl edit ollama&lt;/code&gt; and add an override:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[Service]
# Default context for every model; a Modelfile or a per-request num_ctx overrides it
Environment="OLLAMA_CONTEXT_LENGTH=8192"
# Flash attention is required for KV cache quantization
Environment="OLLAMA_FLASH_ATTENTION=1"
# Roughly halves KV cache memory versus f16; small quality cost
Environment="OLLAMA_KV_CACHE_TYPE=q8_0"
# One slot unless you really serve concurrent users
Environment="OLLAMA_NUM_PARALLEL=1"
# Do not keep idle models fighting for VRAM
Environment="OLLAMA_MAX_LOADED_MODELS=1"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then run &lt;code&gt;sudo systemctl restart ollama&lt;/code&gt;. If you run the Ollama container, pass the same variables with &lt;code&gt;-e&lt;/code&gt; flags. You must recreate the container for new values to take effect.&lt;/p&gt;

&lt;p&gt;For a model you use constantly, pin its default context in a Modelfile. Tools that send their own &lt;code&gt;num_ctx&lt;/code&gt; will still override it, so audit those clients too:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cat &amp;gt; Modelfile &amp;lt;&amp;lt;'EOF'
FROM your-model:tag
PARAMETER num_ctx 8192
EOF
ollama create your-model-8k -f Modelfile
ollama stop your-model:tag    # unload the old instance
ollama run your-model-8k "hello" &amp;amp;&amp;amp; ollama ps
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Verify it worked:&lt;/strong&gt; &lt;code&gt;ollama ps&lt;/code&gt; should now report &lt;code&gt;100% GPU&lt;/code&gt;, and the CONTEXT column should show the value you set. Run &lt;code&gt;ollama run --verbose your-model-8k&lt;/code&gt; and compare the reported eval rate before and after. Use your own numbers, since they vary by card and model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What this costs:&lt;/strong&gt; a smaller context means agents see less of your repository per request, and long prompts get truncated. Quantizing the KV cache saves memory but can slightly degrade output on long contexts, and &lt;code&gt;q4_0&lt;/code&gt; is more aggressive than &lt;code&gt;q8_0&lt;/code&gt;. If you truly need a 32k+ window, shaving settings will not get you there. The honest fix is a smaller model, a lower weight quantization, or a card with more VRAM. Partial offload can still be acceptable for batch jobs where latency does not matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out for:&lt;/strong&gt; server environment variables are read only when the server starts. Restart the service (or recreate the container) after changing them, which also unloads models. Modelfile changes need the model unloaded with &lt;code&gt;ollama stop&lt;/code&gt; and reloaded. Otherwise you are testing the old allocation.&lt;/p&gt;

&lt;h2&gt;Prevention checklist&lt;/h2&gt;

&lt;p&gt;Offload is easiest to catch before it reaches users. Make the processor split a visible check, not something you discover through complaints. The block below can live in a team README or a pre-flight script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env bash
# preflight-ollama.sh: fail if any loaded model is not fully on GPU
set -euo pipefail
out=$(ollama ps | tail -n +2)
[ -z "$out" ] &amp;amp;&amp;amp; { echo "no model loaded; send a request first"; exit 2; }
if grep -q "CPU" &amp;lt;&amp;lt;&amp;lt;"$out"; then
  echo "CPU offload detected:"; echo "$out"; exit 1
fi
echo "all loaded models are 100% GPU"

# Keepable alias:
# alias ops='watch -n2 ollama ps'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The checklist to adopt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Record the VRAM budget for each shared GPU: weights, KV cache at your chosen context, and headroom for a second model.&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;OLLAMA_CONTEXT_LENGTH&lt;/code&gt; explicitly on the server instead of relying on a default that may change between releases.&lt;/li&gt;
&lt;li&gt;Pin &lt;code&gt;num_ctx&lt;/code&gt; in Modelfiles for models you depend on, and audit what your IDE and agent tools send per request.&lt;/li&gt;
&lt;li&gt;Keep &lt;code&gt;OLLAMA_NUM_PARALLEL&lt;/code&gt; at 1 on small cards. Raise it only after measuring.&lt;/li&gt;
&lt;li&gt;Re-run &lt;code&gt;ollama ps&lt;/code&gt; after every model pull, context change, driver update or kernel update.&lt;/li&gt;
&lt;li&gt;In containers, confirm GPU access once with &lt;code&gt;nvidia-smi&lt;/code&gt; inside the container and again with &lt;code&gt;ollama ps&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Treat a sudden tokens-per-second drop as a capacity signal. Check for CPU in the processor column before blaming the model.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When this approach is not enough:&lt;/strong&gt; if several people share one GPU, tuning flags only delays the problem. You need a scheduling layer or dedicated cards per workload. On Kubernetes, that means requesting GPUs explicitly rather than hoping a single node's card is free. You can do this through the device plugin's &lt;code&gt;nvidia.com/gpu&lt;/code&gt; resource or, since &lt;a href="https://kubernetes.io/blog/2026/08/26/kubernetes-v1-37-release/" rel="noopener noreferrer"&gt;Kubernetes v1.37&lt;/a&gt;, DRA-backed extended resources, which are now GA.&lt;/p&gt;

&lt;p&gt;Flag names and defaults move between Ollama releases, so cross-check this article against the &lt;a href="https://docs.ollama.com/" rel="noopener noreferrer"&gt;Ollama documentation&lt;/a&gt; for your installed version. For more practical notes on running AI tooling in production, see &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/27/cap-bedrock-spend-per-team-with-budgets-and-inference-profiles/" rel="noopener noreferrer"&gt;Cap Bedrock Spend Per Team with Budgets and Inference Profiles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/21/podgroup-gang-scheduling-in-kubernetes-1-37-for-training-jobs/" rel="noopener noreferrer"&gt;PodGroup Gang Scheduling in Kubernetes 1.37 for Training Jobs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/13/kubernetes-1-37-upgrade-what-changed-for-ops-teams/" rel="noopener noreferrer"&gt;Kubernetes 1.37 upgrade: what changed for ops teams&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>devops</category>
    </item>
    <item>
      <title>Cap Bedrock Spend Per Team with Budgets and Inference Profiles</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Fri, 27 Nov 2026 08:02:05 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/cap-bedrock-spend-per-team-with-budgets-and-inference-profiles-371g</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/cap-bedrock-spend-per-team-with-budgets-and-inference-profiles-371g</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/27/cap-bedrock-spend-per-team-with-budgets-and-inference-profiles" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Controlling Bedrock spend per team usually starts the same way: the monthly bill shows one large "Amazon Bedrock" line, three teams share one IAM role, and nobody can say whether the jump came from the support chatbot or a data-science batch job. Someone proposes an AWS Budget, and then discovers that a budget cannot filter on something the bill never recorded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; give each team its own tagged application inference profile, activate the tag as a cost allocation tag, and point a tag-filtered AWS Budget at it. For a real cap, attach a budget action that applies an IAM deny policy to the team's role. Use this when several teams share one AWS account; if each team already has its own account, per-account budgets are simpler.&lt;/p&gt;

&lt;h2&gt;What this actually does&lt;/h2&gt;



&lt;p&gt;On-demand Bedrock calls made against a foundation model ID carry no team identity. An &lt;em&gt;application inference profile&lt;/em&gt; is a resource you create in your account that wraps a model (or a system-defined cross-Region profile) and accepts tags. Callers pass the profile ARN where they would normally pass the model ID, and usage is attributed to that profile.&lt;/p&gt;

&lt;p&gt;Three separate mechanisms then do three jobs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tags on the profile&lt;/strong&gt; (for example &lt;code&gt;team=payments&lt;/code&gt;) become cost allocation tags once activated in the Billing console. They appear in Cost Explorer and the Cost and Usage Report.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Budgets&lt;/strong&gt; filters on that tag and notifies at thresholds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget actions&lt;/strong&gt; can attach an IAM or SCP policy automatically when a threshold is crossed. This is the only part that enforces anything.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nothing in this stack is a per-request meter. Billing data arrives with a delay, so the whole design is "stop soon after the limit", not "stop at the limit". Read the current behavior in the &lt;a href="https://docs.aws.amazon.com/bedrock/" rel="noopener noreferrer"&gt;Amazon Bedrock documentation&lt;/a&gt; and the &lt;a href="https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-managing-costs.html" rel="noopener noreferrer"&gt;AWS Budgets guide&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;How people use it wrong&lt;/h2&gt;

&lt;p&gt;The most common failure is tagging the wrong thing. Tagging an IAM role, a Lambda function or an EKS namespace does not tag the Bedrock charge. Cost allocation follows the resource that is billed, so if callers still use the raw model ID, the tag never reaches the bill.&lt;/p&gt;

&lt;p&gt;The second is treating a budget as a circuit breaker. A budget with only an email subscriber is an alarm. By the time actual-cost data crosses 100%, a looping agent may have spent well past the limit. &lt;strong&gt;Watch out:&lt;/strong&gt; a forecasted alert fires earlier, but forecasts are weak for spiky token workloads.&lt;/p&gt;

&lt;p&gt;Other documented traps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Forgetting to activate the tag.&lt;/strong&gt; User-defined tags show up as &lt;code&gt;user:team&lt;/code&gt; in billing only after activation, and data is not guaranteed for periods before activation. Verify backfill options in the Billing documentation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Filtering the budget by service name.&lt;/strong&gt; Third-party models can appear under their own service names in Cost Explorer. A filter on "Amazon Bedrock" alone may miss them, so filter on the tag and check the result against Cost Explorer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaving the bypass open.&lt;/strong&gt; If a team's role can still call &lt;code&gt;bedrock:InvokeModel&lt;/code&gt; on the bare foundation model, untagged spend continues and your per-team numbers lie.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;The correct approach&lt;/h2&gt;

&lt;p&gt;First create one profile per team and workload. The command below copies from a system-defined profile. Replace the placeholder with an ARN from &lt;code&gt;aws bedrock list-inference-profiles&lt;/code&gt;. The account ID and names are examples.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;aws bedrock create-inference-profile \
  --inference-profile-name payments-claude-sonnet \
  --model-source copyFrom=&amp;lt;system-inference-profile-arn&amp;gt; \
  --tags key=team,value=payments key=env,value=prod

# verify: status should be ACTIVE and tags present
aws bedrock get-inference-profile \
  --inference-profile-identifier &amp;lt;returned-inferenceProfileArn&amp;gt;
aws bedrock list-tags-for-resource --resource-arn &amp;lt;returned-inferenceProfileArn&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;🧪 Lab — try this in your browser&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://llm.kuryzhev.cloud/cost-calc?utm_source=devto&amp;amp;utm_medium=lab&amp;amp;utm_campaign=cap-bedrock-spend-per-team-with-budgets-and-inference-profiles" rel="noopener noreferrer"&gt;LLM Cost Calculator&lt;/a&gt; — Estimate monthly LLM API costs four ways: quick usage inputs, pasted real prompts, prebuilt workload profiles, or prompt-caching savings. One calculator, four modes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next, in Billing and Cost Management, activate &lt;code&gt;team&lt;/code&gt; under Cost allocation tags. The CLI equivalent is &lt;code&gt;aws ce update-cost-allocation-tags-status --cost-allocation-tags-status TagKey=team,Status=Active&lt;/code&gt;. The key must already appear in billing data before it can be activated. Then change the application code to call the profile ARN:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;import boto3

br = boto3.client("bedrock-runtime")
resp = br.converse(
    modelId="&amp;lt;payments-profile-arn&amp;gt;",  # profile ARN, not the model ID
    messages=[{"role": "user", "content": [{"text": "ping"}]}],
)
print(resp["usage"])  # inputTokens / outputTokens for this call&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally, create the budget filtered by the tag. The &lt;code&gt;user:team$payments&lt;/code&gt; form is the documented tag filter syntax.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cat &amp;gt; budget.json &amp;lt;&amp;lt;'EOF'
{
  "BudgetName": "bedrock-payments-monthly",
  "BudgetLimit": {"Amount": "2000", "Unit": "USD"},
  "TimeUnit": "MONTHLY",
  "BudgetType": "COST",
  "CostFilters": {"TagKeyValue": ["user:team$payments"]}
}
EOF
cat &amp;gt; notif.json &amp;lt;&amp;lt;'EOF'
[{"Notification": {"NotificationType": "ACTUAL",
   "ComparisonOperator": "GREATER_THAN",
   "Threshold": 80, "ThresholdType": "PERCENTAGE"},
  "Subscribers": [{"SubscriptionType": "EMAIL",
   "Address": "payments-oncall@example.com"}]}]
EOF
aws budgets create-budget --account-id 111122223333 \
  --budget file://budget.json \
  --notifications-with-subscribers file://notif.json&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To verify, run &lt;code&gt;aws budgets describe-budget --account-id 111122223333 --budget-name bedrock-payments-monthly&lt;/code&gt;. After the first billing refresh (allow up to a day), open Cost Explorer, group by tag &lt;code&gt;team&lt;/code&gt;, and confirm the spend is attributed to &lt;code&gt;payments&lt;/code&gt; rather than "No tag key".&lt;/p&gt;

&lt;h2&gt;Advanced patterns&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Make the profile the only door.&lt;/strong&gt; Give each team role an allow on its own profile ARN. Invoking through an application inference profile also requires permission on the underlying foundation models (in every Region a cross-Region profile covers). So the role cannot simply have no model permissions. Instead, scope the foundation-model allow so it only applies when the request comes through the team's profile. The Bedrock IAM examples use an inference-profile condition key such as &lt;code&gt;bedrock:InferenceProfileArn&lt;/code&gt; for this.&lt;/p&gt;

&lt;p&gt;A plain deny on &lt;code&gt;bedrock:InvokeModel&lt;/code&gt; and &lt;code&gt;bedrock:InvokeModelWithResponseStream&lt;/code&gt; against foundation-model resources would also block profile calls, because the model ARN is evaluated too. Any permissions boundary or SCP that closes the bypass must use that condition. Confirm the exact condition keys and resource list in the Service Authorization Reference before relying on them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Turn the alarm into a brake.&lt;/strong&gt; A budget action can attach a deny policy to the team role at 100% of actual cost. Use manual approval first, then switch to automatic once you trust the numbers.&lt;/p&gt;

&lt;p&gt;There is no separate IAM action for the Converse API. &lt;code&gt;Converse&lt;/code&gt; is authorized by &lt;code&gt;bedrock:InvokeModel&lt;/code&gt; and &lt;code&gt;ConverseStream&lt;/code&gt; by &lt;code&gt;bedrock:InvokeModelWithResponseStream&lt;/code&gt;, so &lt;code&gt;bedrock:InvokeModel*&lt;/code&gt; covers both. Batch inference jobs are started with &lt;code&gt;bedrock:CreateModelInvocationJob&lt;/code&gt; and need their own deny.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# deny policy (managed policy "bedrock-team-freeze") contains:
# {"Version":"2012-10-17","Statement":[{"Effect":"Deny",
#   "Action":["bedrock:InvokeModel*","bedrock:CreateModelInvocationJob"],
#   "Resource":"*"}]}
aws budgets create-budget-action \
  --account-id 111122223333 \
  --budget-name bedrock-payments-monthly \
  --notification-type ACTUAL \
  --action-type APPLY_IAM_POLICY \
  --action-threshold ActionThresholdValue=100,ActionThresholdType=PERCENTAGE \
  --definition 'IamActionDefinition={PolicyArn=arn:aws:iam::111122223333:policy/bedrock-team-freeze,Roles=[payments-app-role]}' \
  --execution-role-arn arn:aws:iam::111122223333:role/budgets-action-role \
  --approval-model MANUAL \
  --subscribers SubscriptionType=EMAIL,Address=finops@example.com&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Watch out:&lt;/strong&gt; a freeze policy on a production role is an outage you scheduled yourself. Cap dev and batch roles automatically. For customer-facing paths, page a human instead, or set a lower soft limit and a higher hard limit.&lt;/p&gt;

&lt;p&gt;For a faster signal than billing, alarm on the &lt;code&gt;AWS/Bedrock&lt;/code&gt; CloudWatch token metrics (&lt;code&gt;InputTokenCount&lt;/code&gt;, &lt;code&gt;OutputTokenCount&lt;/code&gt;) and convert tokens to dollars with your model's price. Verify in your account which dimension value identifies a profile. This is an estimate, not an invoice. More platform patterns like this live on &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Performance notes&lt;/h2&gt;

&lt;p&gt;Calling through an application inference profile is documented as a routing and attribution layer, and no per-call latency penalty is documented. Measure p50 and p95 on your own prompts before and after the switch rather than assuming either way.&lt;/p&gt;

&lt;p&gt;The delays that matter are administrative:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tag visibility:&lt;/strong&gt; up to roughly a day after activation or first usage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Budget evaluation:&lt;/strong&gt; follows billing data refreshes, documented as up to three times a day and typically lagging usage by hours. It is never per request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overshoot:&lt;/strong&gt; a busy agent fleet can spend meaningfully past the limit before the action fires. Set the hard threshold below what you can tolerate, such as 80-90% of the real ceiling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Throttling is not isolated by profile. Application inference profiles share the underlying model's service quotas, which apply per model and Region at account level. One team's batch job can therefore still throttle another team's interactive traffic. If that matters, move the noisy team to a separate account or use provisioned throughput for the latency-sensitive path.&lt;/p&gt;

&lt;p&gt;This approach has costs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;More resources to manage (profiles per team, per environment).&lt;/li&gt;
&lt;li&gt;A cost-allocation-tag activation step that Terraform may not cover in your provider version.&lt;/li&gt;
&lt;li&gt;Coupling to AWS-specific tagging.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Skip it if one team owns the whole account, or if you already route all calls through an LLM gateway that meters tokens per key. In that case, enforce limits there and use the tags only for reconciliation.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/10/12/content-workflow-automation-failing-in-n8n-or-bedrock-fixes/" rel="noopener noreferrer"&gt;Content Workflow Automation Failing in n8n or Bedrock? Fixes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/09/05/bedrock-iam-least-privilege-stopping-runaway-bot-costs/" rel="noopener noreferrer"&gt;Bedrock IAM Least Privilege: Stopping Runaway Bot Costs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/21/podgroup-gang-scheduling-in-kubernetes-1-37-for-training-jobs/" rel="noopener noreferrer"&gt;PodGroup Gang Scheduling in Kubernetes 1.37 for Training Jobs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>Migrate Prometheus latency metrics to native histograms</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Thu, 26 Nov 2026 08:02:12 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/migrate-prometheus-latency-metrics-to-native-histograms-2c3p</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/migrate-prometheus-latency-metrics-to-native-histograms-2c3p</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/26/migrate-prometheus-latency-metrics-to-native-histograms" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;The scenario&lt;/h2&gt;

&lt;p&gt;Your latency histogram has 14 buckets, 400 label combinations and a p99 alert that jumps around whenever someone adds a service with a different bucket layout. Every label combination produces one series per bucket plus &lt;code&gt;_sum&lt;/code&gt; and &lt;code&gt;_count&lt;/code&gt;, and your hand-picked &lt;code&gt;le&lt;/code&gt; boundaries are wrong for half the endpoints. This is the situation native histograms are designed for: one series per histogram, exponential buckets chosen automatically, and a bounded relative error instead of guessed boundaries.&lt;/p&gt;

&lt;p&gt;The timing is good. &lt;a href="https://github.com/prometheus/prometheus/releases" rel="noopener noreferrer"&gt;Prometheus 3.16 shipped in November 2026&lt;/a&gt;. Native histograms became a stable, documented feature during the 3.x line, so on current releases they no longer need to be explained as an experiment. If you are already planning a 3.16 upgrade, this is a sensible change to bundle with it, as long as you roll it out in phases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instrument services so they expose classic and native histograms at the same time.&lt;/li&gt;
&lt;li&gt;Enable native histogram scraping in Prometheus while keeping classic scraping.&lt;/li&gt;
&lt;li&gt;Rewrite dashboards and alerts to the native form one at a time.&lt;/li&gt;
&lt;li&gt;Drop the classic buckets only after the native queries have run in parallel for a full alert and SLO window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Skip the migration if your remote storage does not accept native histograms, or if your SLOs depend on exact custom bucket boundaries.&lt;/p&gt;

&lt;h2&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;Check these before touching a config file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prometheus 3.x&lt;/strong&gt; (3.16.0 is current). Option names for native histograms have moved between 3.x releases, so compare the snippets below with the &lt;a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/" rel="noopener noreferrer"&gt;configuration reference&lt;/a&gt; for your exact version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A client library with native histogram support.&lt;/strong&gt; The Go client (&lt;code&gt;client_golang&lt;/code&gt;) supports them. For Java, Python and others, check the library's release notes and the &lt;a href="https://prometheus.io/docs/specs/native_histograms/" rel="noopener noreferrer"&gt;native histograms specification&lt;/a&gt;. The examples use Go 1.27.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protobuf exposition.&lt;/strong&gt; The established way to transfer native histograms at scrape time is the Prometheus protobuf format. Support in text formats depends on your Prometheus and client versions. Any proxy or sidecar between Prometheus and the target must pass protobuf through untouched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Downstream support.&lt;/strong&gt; If you use &lt;code&gt;remote_write&lt;/code&gt; to Mimir, Thanos, Grafana Cloud or another vendor, confirm in their docs that native histograms are accepted and what they cost. Do not assume.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An inventory of consumers.&lt;/strong&gt; List the dashboards, recording rules, alert rules and SLO tooling that reference &lt;code&gt;*_bucket&lt;/code&gt; series. A &lt;code&gt;grep -rn "_bucket" rules/ dashboards/&lt;/code&gt; in your config repo is a good start.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also decide your rollback. Classic buckets stay in place through steps 1 to 3, so rollback means reverting the Prometheus config and leaving the instrumentation alone.&lt;/p&gt;

&lt;h2&gt;Step 1: Expose classic and native buckets together&lt;/h2&gt;



&lt;p&gt;In &lt;code&gt;client_golang&lt;/code&gt;, a histogram becomes native-capable when you set the native histogram options. If you also keep &lt;code&gt;Buckets&lt;/code&gt;, the same metric is exposed in both forms, which is exactly what the migration needs. Do not add a &lt;code&gt;job&lt;/code&gt; label in instrumentation. Prometheus attaches &lt;code&gt;job&lt;/code&gt; as a target label and would rename yours to &lt;code&gt;exported_job&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;package metrics

import (
    "time"

    "github.com/prometheus/client_golang/prometheus"
    "github.com/prometheus/client_golang/prometheus/promauto"
)

var RequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
    Name: "http_request_duration_seconds",
    Help: "HTTP request latency.",

    // Keep the old layout so existing dashboards and alerts keep working.
    Buckets: []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5},

    // Native histogram settings.
    NativeHistogramBucketFactor:     1.1,       // each bucket at most ~10% wider than the previous
    NativeHistogramMaxBucketNumber:  100,       // cap on buckets per histogram
    NativeHistogramMinResetDuration: time.Hour, // minimum time between resets when the cap is hit
}, []string{"route", "code"})
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;🧪 Lab — try this in your browser&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://tools.kuryzhev.cloud/?utm_source=devto&amp;amp;utm_medium=lab&amp;amp;utm_campaign=migrate-prometheus-latency-metrics-to-native-histograms#grafanaquery" rel="noopener noreferrer"&gt;PromQL Builder&lt;/a&gt; — Build Prometheus PromQL queries from metric name, labels, aggregation and range selectors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watch out for the bucket cap.&lt;/strong&gt; When a histogram exceeds &lt;code&gt;NativeHistogramMaxBucketNumber&lt;/code&gt;, &lt;code&gt;client_golang&lt;/code&gt; first checks &lt;code&gt;NativeHistogramMinResetDuration&lt;/code&gt;. If that much time has passed since the last reset, the histogram is reset, and Prometheus sees this as a counter reset. Otherwise the client widens the zero bucket (if &lt;code&gt;NativeHistogramMaxZeroThreshold&lt;/code&gt; allows it) or halves the resolution.&lt;/p&gt;

&lt;p&gt;The default of &lt;code&gt;0&lt;/code&gt; means the histogram never resets and only loses resolution. Set the option deliberately in a high-variance service instead of leaving the default.&lt;/p&gt;

&lt;h2&gt;Step 2: Scrape native histograms next to classic ones&lt;/h2&gt;

&lt;p&gt;Now tell Prometheus to ingest them. Start with a single scrape job so the blast radius is small.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# prometheus.yml
scrape_configs:
  - job_name: checkout-api
    scrape_native_histograms: true          # ingest native histograms (recent 3.x option; check your version's docs)
    always_scrape_classic_histograms: true  # keep _bucket series during migration
    scrape_protocols:                       # protobuf first, so native histograms can be negotiated
      - PrometheusProto
      - OpenMetricsText1.0.0
      - OpenMetricsText0.0.1
      - PrometheusText0.0.4
    kubernetes_sd_configs:
      - role: pod
    relabel_configs:                        # only scrape checkout-api pods, not the whole cluster
      - source_labels: [__meta_kubernetes_pod_label_app]
        regex: checkout-api
        action: keep

# Only if you forward to a backend that accepts native histograms:
remote_write:
  - url: https://metrics.example.internal/api/v1/push
    send_native_histograms: true
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Older 3.x releases gate native histograms behind &lt;code&gt;--enable-feature=native-histograms&lt;/code&gt; on the command line instead of the per-job option. The release notes for your version will say which applies.&lt;/p&gt;

&lt;p&gt;For services you cannot re-instrument, &lt;code&gt;convert_classic_histograms_to_nhcb: true&lt;/code&gt; converts classic histograms into native histograms with custom buckets. That gives you the single-series storage model but not the automatic exponential resolution, so treat it as a stopgap.&lt;/p&gt;

&lt;p&gt;Reload with &lt;code&gt;curl -X POST localhost:9090/-/reload&lt;/code&gt; (requires &lt;code&gt;--web.enable-lifecycle&lt;/code&gt;), send &lt;code&gt;SIGHUP&lt;/code&gt;, or restart. While both forms are ingested, expect the series count and memory to go up, not down. The savings from fewer series only arrive after classic scraping is switched off in step 4, and each native histogram sample is larger than a single classic sample.&lt;/p&gt;

&lt;h2&gt;Step 3: Rewrite queries, rules and alerts&lt;/h2&gt;

&lt;p&gt;Native histograms live under the base metric name. There is no &lt;code&gt;_bucket&lt;/code&gt; suffix and no &lt;code&gt;le&lt;/code&gt; label, so the classic pattern changes shape.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Classic
histogram_quantile(0.99,
  sum by (job, le) (rate(http_request_duration_seconds_bucket[5m])))

# Native: no le, no _bucket
histogram_quantile(0.99,
  sum by (job) (rate(http_request_duration_seconds[5m])))

# Request count and mean latency from the same series
histogram_count(sum by (job) (rate(http_request_duration_seconds[5m])))
histogram_sum(sum by (job) (rate(http_request_duration_seconds[5m])))
  / histogram_count(sum by (job) (rate(http_request_duration_seconds[5m])))

# Share of requests under 250 ms (an SLI)
histogram_fraction(0, 0.25, sum by (job) (rate(http_request_duration_seconds[5m])))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Gotcha:&lt;/strong&gt; &lt;code&gt;histogram_fraction&lt;/code&gt; and &lt;code&gt;histogram_quantile&lt;/code&gt; interpolate inside exponential buckets. A threshold that falls mid-bucket yields an estimate, not an exact count. If your SLO contract names a precise boundary such as 300 ms and auditors expect exact counts, keep a classic (or custom-bucket) histogram that includes that boundary for that metric.&lt;/p&gt;

&lt;p&gt;Recording rules can output native histograms too. For example, recording &lt;code&gt;sum by (job) (rate(http_request_duration_seconds[5m]))&lt;/code&gt; lets dashboards run quantiles on a pre-aggregated histogram.&lt;/p&gt;

&lt;p&gt;Duplicate each alert as a temporary &lt;code&gt;*_native&lt;/code&gt; rule and compare firing behavior before replacing the original. In Grafana 13.3, use the Prometheus data source with the heatmap panel for native histograms. See the &lt;a href="https://grafana.com/docs/grafana/latest/whatsnew/" rel="noopener noreferrer"&gt;Grafana what's new page&lt;/a&gt; for current panel support.&lt;/p&gt;

&lt;h2&gt;Step 4: Cut over and drop the classic buckets&lt;/h2&gt;

&lt;p&gt;Only shrink the footprint once every consumer reads the native form:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Remove &lt;code&gt;always_scrape_classic_histograms&lt;/code&gt; from the job.&lt;/li&gt;
&lt;li&gt;In code, delete the &lt;code&gt;Buckets&lt;/code&gt; field.&lt;/li&gt;
&lt;li&gt;Do it job by job, not fleet-wide.&lt;/li&gt;
&lt;li&gt;Keep the previous config in Git so a revert is one commit.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Historical classic data stays queryable until retention expires, so old dashboards over past ranges still work. New data will not appear in them.&lt;/p&gt;

&lt;h2&gt;Verify and test&lt;/h2&gt;

&lt;p&gt;First, confirm Prometheus is actually storing native histograms. A raw instant query returns a &lt;code&gt;histogram&lt;/code&gt; field instead of a &lt;code&gt;value&lt;/code&gt; field:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -s localhost:9090/api/v1/query \
  --data-urlencode 'query=http_request_duration_seconds{job="checkout-api"}' \
  | jq '.data.result[0]'
# Expected shape: { "metric": {...}, "histogram": [ &amp;lt;timestamp&amp;gt;, { "count": "...", "sum": "...", "buckets": [...] } ] }
# If you only see "value" or no result, Prometheus is still ingesting classic series only.

# Compare classic and native p99 side by side; expect close, not identical, values
promtool query instant http://localhost:9090 \
  'histogram_quantile(0.99, sum by (job) (rate(http_request_duration_seconds[5m])))'
promtool query instant http://localhost:9090 \
  'histogram_quantile(0.99, sum by (job, le) (rate(http_request_duration_seconds_bucket[5m])))'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then check three more things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Series counts.&lt;/strong&gt; &lt;code&gt;count({job="checkout-api"})&lt;/code&gt; should drop once classic scraping is off, and &lt;code&gt;prometheus_tsdb_head_series&lt;/code&gt; should trend down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scrape health.&lt;/strong&gt; Check &lt;code&gt;up{job="checkout-api"}&lt;/code&gt; and the Prometheus logs for scrape errors after the protocol change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alert parity.&lt;/strong&gt; Run both alert versions in parallel for at least a full alert and SLO evaluation window before deleting the old rule. One daily traffic cycle is not enough for a 28- or 30-day SLO.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Wrap-up&lt;/h2&gt;

&lt;p&gt;Native histograms trade bucket guesswork for automatic resolution and fewer series, but the cost is real:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;client library upgrades&lt;/li&gt;
&lt;li&gt;rewritten PromQL&lt;/li&gt;
&lt;li&gt;larger samples&lt;/li&gt;
&lt;li&gt;a temporary increase in series during dual exposition&lt;/li&gt;
&lt;li&gt;a hard dependency on every backend in your pipeline understanding the format&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run both forms in parallel, migrate one job and its alerts at a time, and keep a classic or custom-bucket histogram where a contract needs an exact boundary. Check the &lt;a href="https://github.com/prometheus/prometheus/releases" rel="noopener noreferrer"&gt;Prometheus release notes&lt;/a&gt; for version-specific details, find more infrastructure guides on &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;, and keep the &lt;a href="https://prometheus.io/docs/" rel="noopener noreferrer"&gt;official Prometheus documentation&lt;/a&gt; open for option names that change between 3.x releases.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/20/what-changed-in-prometheus-3-16-for-production-use/" rel="noopener noreferrer"&gt;What changed in Prometheus 3.16 for production use&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/09/17/alertmanager-routing-fixes-to-cut-prometheus-alert-fatigue/" rel="noopener noreferrer"&gt;Alertmanager Routing Fixes to Cut Prometheus Alert Fatigue&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/09/15/prometheus-and-grafana-docker-compose-setup-that-sticks/" rel="noopener noreferrer"&gt;Prometheus and Grafana Docker Compose Setup That Sticks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>monitoring</category>
      <category>devops</category>
    </item>
    <item>
      <title>Cloudflare Access service tokens for CI jobs to internal apps</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Wed, 25 Nov 2026 08:01:38 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/cloudflare-access-service-tokens-for-ci-jobs-to-internal-apps-4jg</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/cloudflare-access-service-tokens-for-ci-jobs-to-internal-apps-4jg</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/25/cloudflare-access-service-tokens-for-ci-jobs-to-internal-apps" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Your deploy pipeline needs to call an internal admin API that sits behind Cloudflare Access, and the first run ends with an HTML login page where JSON should be. Cloudflare Access service tokens are the documented way to let a non-human client through: a client ID and secret sent as two request headers, matched against a dedicated policy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; create one service token per pipeline and app, add an Access policy with the &lt;em&gt;Service Auth&lt;/em&gt; action that names that specific token, attach it to the application, and send &lt;code&gt;CF-Access-Client-Id&lt;/code&gt; and &lt;code&gt;CF-Access-Client-Secret&lt;/code&gt; from CI secrets. It fits HTTP(S) calls to apps already behind Access. If you need per-user identity or short-lived credentials, a service token is the wrong tool (see the last tip).&lt;/p&gt;

&lt;h2&gt;1. Issue one Cloudflare Access service token per pipeline and app&lt;/h2&gt;



&lt;p&gt;&lt;strong&gt;A shared "ci" token is a shared blast radius, so name tokens after the job and the target.&lt;/strong&gt; If a token leaks, you revoke one thing and the audit log tells you which pipeline it was. The secret is shown only once at creation, so write it to your secret store in the same step.&lt;/p&gt;

&lt;p&gt;Creating a token through the API (the account ID and an API token with Access edit permission are placeholders; check the current schema in the &lt;a href="https://developers.cloudflare.com/cloudflare-one/" rel="noopener noreferrer"&gt;Cloudflare One docs&lt;/a&gt;):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -sS -X POST \
  "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/access/service_tokens" \
  -H "Authorization: Bearer $CF_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"name":"ci-deploy-billing-admin","duration":"8760h"}' \
  | jq '.result | {client_id, client_secret}'   # secret is returned only now
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;2. Write the policy with Service Auth, not Allow&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A token that exists but is not referenced by a Service Auth policy gets you nothing.&lt;/strong&gt; The same is true of a policy that is not attached to an application. In the dashboard, add a policy to the application with the action &lt;em&gt;Service Auth&lt;/em&gt; and an include rule selecting the specific token. Human policies (Allow, with email or IdP rules) will not admit a service token.&lt;/p&gt;

&lt;p&gt;Watch out for the "Any Access Service Token" selector. It admits every token in the account, including ones created later for other teams. Pick the named token instead.&lt;/p&gt;

&lt;p&gt;If you manage Access as code, the shape below is what the Terraform/OpenTofu Cloudflare provider v5 documents. In v5, policies are account-level, reusable objects that take effect only when an application lists them. Field names have shifted between provider majors, so verify against the provider docs before applying.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;resource "cloudflare_zero_trust_access_service_token" "ci" {
  account_id = var.account_id
  name       = "ci-deploy-billing-admin"
  duration   = "8760h"
}

resource "cloudflare_zero_trust_access_policy" "ci" {
  account_id = var.account_id
  name       = "ci-deploy-billing-admin"
  decision   = "non_identity" # the API name for Service Auth
  include = [{
    service_token = { token_id = cloudflare_zero_trust_access_service_token.ci.id }
  }]
}

# The policy only applies once an application references it
resource "cloudflare_zero_trust_access_application" "billing_deploy_api" {
  account_id = var.account_id
  name       = "billing-admin-deploy-api"
  type       = "self_hosted"
  domain     = "admin.internal.example.com/api/deploy"
  policies = [{
    id         = cloudflare_zero_trust_access_policy.ci.id
    precedence = 1
  }]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;3. Prove it works with a with-and-without test&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Always test both the allowed and the denied path.&lt;/strong&gt; A 200 with headers proves little if the app was never protected. Run the same request without headers and confirm it is blocked.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;URL="https://admin.internal.example.com/healthz"

# With the token: expect 200 (or your app's normal status)
curl -s -o /dev/null -w '%{http_code}\n' "$URL" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"

# Without it: expect a redirect to the Access login or a 403
curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' "$URL"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A typical failure is a 302 or 403 even with headers. That usually means one of four things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the policy uses the wrong action;&lt;/li&gt;
&lt;li&gt;it references a different token;&lt;/li&gt;
&lt;li&gt;it is not attached to the application;&lt;/li&gt;
&lt;li&gt;the hostname or path is not covered by the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Access authentication logs in the Zero Trust dashboard show which policy evaluated and why.&lt;/p&gt;

&lt;h2&gt;4. Keep the secret out of logs, forks and shell history&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Store both values as CI secrets and expose them only to jobs that need them.&lt;/strong&gt; In GitHub Actions, store them as environment secrets (not repository secrets) on an environment with deployment branch rules. That way only jobs running from allowed branches can read them. Add required reviewers if you also want a human approval before the job starts.&lt;/p&gt;

&lt;p&gt;For workflows triggered by &lt;code&gt;pull_request&lt;/code&gt; from forks, secrets are not passed by default. &lt;code&gt;pull_request_target&lt;/code&gt; does run with secrets, so do not use it to make a fork test pass.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;jobs:
  smoke:
    runs-on: ubuntu-latest
    environment: production-internal   # environment secrets + branch rules gate access
    steps:
      - name: Call internal API through Access
        env:
          CF_ACCESS_CLIENT_ID: ${{ "{{" }} secrets.CF_ACCESS_CLIENT_ID }}
          CF_ACCESS_CLIENT_SECRET: ${{ "{{" }} secrets.CF_ACCESS_CLIENT_SECRET }}
        run: |
          curl -fsS https://admin.internal.example.com/healthz \
            -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
            -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Watch out for &lt;code&gt;curl -v&lt;/code&gt; and &lt;code&gt;set -x&lt;/code&gt;. Both print request headers, and masking only works on exact string matches in the log output.&lt;/p&gt;

&lt;h2&gt;5. Choose an expiry on purpose and rotate before it bites&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;An expired token fails like a missing one, and the failure often surfaces in the middle of a release.&lt;/strong&gt; Pick a duration that matches your rotation habit. Do not reach for the non-expiring option just to avoid the chore. Cloudflare can send a notification before a service token expires. Make sure it goes to a team alias, not the person who created the token.&lt;/p&gt;

&lt;p&gt;Put the expiry date in the token name or your inventory. Rotate by creating a new token, updating CI, then deleting the old one. The dashboard and API also offer refresh and rotate actions. Their exact behavior, including any grace period for the old secret, has changed over time, so read the current docs before relying on it.&lt;/p&gt;

&lt;h2&gt;6. Treat a service token as a bearer password&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Anyone holding the two headers is the pipeline.&lt;/strong&gt; There is no device posture, no IdP identity and no source IP check attached to it unless you add them. So narrow the policy: add your self-hosted runners' IP range as a &lt;em&gt;Require&lt;/em&gt; rule alongside the Service Auth include, if the egress addresses are stable. A second Include rule would widen access rather than narrow it. GitHub-hosted runner IPs change, so this pairing mostly suits self-hosted runners.&lt;/p&gt;

&lt;p&gt;Also scope the app, not just the token. Create a separate Access application for the CI-facing path (for example &lt;code&gt;/api/deploy/*&lt;/code&gt;) so a leaked token cannot browse the whole admin UI. The cost is more applications and policies to manage, which is worth it for anything that can change production.&lt;/p&gt;

&lt;h2&gt;7. Know when Cloudflare Access service tokens are the wrong fit&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Do not use them when you need to know who acted, or when the client is not speaking HTTP(S) through Access.&lt;/strong&gt; An audit entry says "token ci-deploy-billing-admin", not which engineer triggered the run. Put that context in your CI logs and keep the correlation in your pipeline records.&lt;/p&gt;

&lt;p&gt;For short-lived credentials, per-run identity or non-HTTP protocols, look at Cloudflare Tunnel with WARP or mTLS, or at a different access layer entirely. For SSH-style workloads, see the comparison of &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;Tailscale-based access patterns&lt;/a&gt; elsewhere on this blog. The tradeoff is more client setup in exchange for stronger identity, so choose per workload rather than standardizing on one mechanism.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/10/28/cloudflare-origin-hardening-authenticated-pulls-vs-ip-allowlist/" rel="noopener noreferrer"&gt;Cloudflare Origin Hardening: Authenticated Pulls vs IP Allowlist&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/10/06/cloudflare-tunnel-shows-502-or-inactive-troubleshooting-fixes/" rel="noopener noreferrer"&gt;Cloudflare Tunnel Shows 502 or Inactive? Troubleshooting Fixes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/09/24/when-cloudflare-rate-limit-locks-out-your-own-players/" rel="noopener noreferrer"&gt;When Cloudflare Rate Limit Locks Out Your Own Players&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>Verify cosign signatures at admission in Kubernetes</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Tue, 24 Nov 2026 08:01:59 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/verify-cosign-signatures-at-admission-in-kubernetes-11i6</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/verify-cosign-signatures-at-admission-in-kubernetes-11i6</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/24/verify-cosign-signatures-at-admission-in-kubernetes" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;A team signs every release image in CI, adds a "we sign our images" line to the security questionnaire, and then someone runs &lt;code&gt;kubectl run debug --image=docker.io/random/tool:latest&lt;/code&gt; in production. Nothing stops it, because signing only produces evidence. Something has to check that evidence at the moment a Pod is created. The cluster-side gate is what lets you verify cosign signatures where it matters: at admission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; install an admission controller that understands Sigstore (Kyverno or the Sigstore policy-controller), pin it to your CI identity (issuer plus subject, or a public key), and run it in audit mode first, then enforce. It applies whenever you control what reaches the registry and want to refuse everything else. It does not replace vulnerability scanning, and it adds a new availability dependency to your control plane.&lt;/p&gt;

&lt;h2&gt;What this actually does&lt;/h2&gt;



&lt;p&gt;A cosign signature is a small artifact stored in the registry next to the image, tied to the image's &lt;em&gt;digest&lt;/em&gt;. With keyless signing, it also carries a short-lived certificate from Fulcio that records who signed (an OIDC issuer and a subject such as a GitHub Actions workflow path), plus an entry in the Rekor transparency log.&lt;/p&gt;

&lt;p&gt;At admission, the Kubernetes API server sends the Pod to a validating or mutating webhook. The controller resolves each image reference, fetches the signature from the registry, and checks it cryptographically. It then compares the signer's identity with your policy. In enforce mode, any failed step causes the API server to reject the Pod, so nothing is scheduled. In audit mode, the failure is only recorded.&lt;/p&gt;

&lt;p&gt;The gate has to be an external webhook. &lt;code&gt;ValidatingAdmissionPolicy&lt;/code&gt; uses CEL expressions evaluated in-process and cannot call a registry, so it cannot check signatures by itself. It can complement the webhook (for example, to require digests), but it cannot replace it.&lt;/p&gt;

&lt;p&gt;This protects against an image being swapped or pushed by someone who is not your pipeline. It does not tell you the image is free of vulnerabilities. A correctly signed image from your own CI can still contain a vulnerable library.&lt;/p&gt;

&lt;h2&gt;How people use it wrong&lt;/h2&gt;

&lt;p&gt;The most common failure is a policy that proves too little. A keyless policy with &lt;code&gt;subjectRegExp: ".*"&lt;/code&gt; accepts a signature from &lt;em&gt;anyone&lt;/em&gt; with a Sigstore identity, including an attacker's own GitHub account. A signature is only meaningful when it is bound to &lt;strong&gt;your&lt;/strong&gt; issuer and a narrow subject.&lt;/p&gt;

&lt;p&gt;Other documented pitfalls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Verifying tags, not digests.&lt;/strong&gt; A tag like &lt;code&gt;:1.4&lt;/code&gt; can be repointed after verification. If the controller does not rewrite the Pod to the digest, the kubelet may pull something different from what was checked.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Staying in audit mode forever.&lt;/strong&gt; Reports pile up, nobody reads them, and the cluster is never protected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setting the webhook &lt;code&gt;failurePolicy&lt;/code&gt; to &lt;code&gt;Ignore&lt;/code&gt; to avoid outages.&lt;/strong&gt; That turns every controller crash or timeout into a silent bypass.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Excluding whole namespaces "temporarily".&lt;/strong&gt; A broad exclusion of &lt;code&gt;kube-system&lt;/code&gt; or &lt;code&gt;default&lt;/code&gt; tends to become permanent, and an excluded namespace is an obvious target for anyone trying to get around the policy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signing in CI but pushing mirrors unsigned.&lt;/strong&gt; If pods pull from a mirror registry, the signature has to exist at that location, or the policy has to reference the original.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watch out for:&lt;/strong&gt; a policy that matches only &lt;code&gt;Pod&lt;/code&gt; and misses init containers or ephemeral containers. Check your controller's docs to confirm that all container types are covered for your version.&lt;/p&gt;

&lt;h2&gt;The correct approach&lt;/h2&gt;

&lt;p&gt;First, sign by digest in CI. This example assumes a GitHub Actions job with &lt;code&gt;id-token: write&lt;/code&gt; permission. With that permission, cosign performs keyless signing using the workflow's OIDC token.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Sign the exact digest that was just pushed, never a tag
cosign sign --yes registry.example.com/team/app@sha256:&amp;lt;digest&amp;gt;

# Verify locally with the SAME identity the cluster will enforce
cosign verify registry.example.com/team/app@sha256:&amp;lt;digest&amp;gt; \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  --certificate-identity "https://github.com/example-org/app/.github/workflows/release.yml@refs/heads/main"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;🧪 Lab — try this in your browser&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://tools.kuryzhev.cloud/?utm_source=devto&amp;amp;utm_medium=lab&amp;amp;utm_campaign=verify-cosign-signatures-at-admission-in-kubernetes&amp;amp;input=apiVersion%3A%20kyverno.io%2Fv1%0Akind%3A%20ClusterPolicy%0Ametadata%3A%0A%20%20name%3A%20verify-cosign-signatures%0Aspec%3A%0A%20%20failurePolicy%3A%20Fail%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20a%20broken%20webhook%20must%20not%20become%20a%20bypass%0A%20%20webhookTimeoutSeconds%3A%2015%0A%20%20rules%3A%0A%20%20%20%20-%20name%3A%20require-ci-signature%0A%20%20%20%20%20%20match%3A%0A%20%20%20%20%20%20%20%20any%3A%0A%20%20%20%20%20%20%20%20%20%20-%20resources%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20kinds%3A%20%5B%22Pod%22%5D%0A%20%20%20%20%20%20verifyImages%3A%0A%20%20%20%20%20%20%20%20-%20imageReferences%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20%22registry.example.com%2Fteam%2F%2A%22%0A%20%20%20%20%20%20%20%20%20%20failureAction%3A%20Audit%20%20%20%20%20%23%20switch%20to%20Enforce%20after%20reviewing%20reports%0A%20%20%20%20%20%20%20%20%20%20mutateDigest%3A%20false%20%20%20%20%20%20%23%20must%20be%20false%20in%20Audit%3B%20set%20true%20with%20Enforce%0A%20%20%20%20%20%20%20%20%20%20verifyDigest%3A%20true%0A%20%20%20%20%20%20%20%20%20%20required%3A%20true%0A%20%20%20%20%20%20%20%20%20%20attestors%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20-%20entries%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20-%20keyless%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20issuer%3A%20%22https%3A%2F%2Ftoken.actions.githubusercontent.com%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20subject%3A%20%22https%3A%2F%2Fgithub.com%2Fexample-org%2Fapp%2F.github%2Fworkflows%2Frelease.yml%40refs%2Fheads%2Fmain%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rekor%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20url%3A%20%22https%3A%2F%2Frekor.sigstore.dev%22#k8slint" rel="noopener noreferrer"&gt;Kubernetes Manifest Linter&lt;/a&gt; — Lint multi-document Kubernetes YAML for production readiness and security, with line:col diagnostics, severity grouping, a 0-100 score and fix hints.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the local &lt;code&gt;cosign verify&lt;/code&gt; fails, the cluster policy will fail too, so fix this step first. Then apply a Kyverno policy that uses the same identity.&lt;/p&gt;

&lt;p&gt;Current Kyverno releases deprecate the spec-level &lt;code&gt;validationFailureAction&lt;/code&gt;. They use a per-rule &lt;code&gt;failureAction&lt;/code&gt; field instead, which for image verification sits on each &lt;code&gt;verifyImages&lt;/code&gt; entry. Check the &lt;a href="https://kyverno.io/docs/" rel="noopener noreferrer"&gt;Kyverno documentation&lt;/a&gt; for your installed version.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: verify-cosign-signatures
spec:
  failurePolicy: Fail              # a broken webhook must not become a bypass
  webhookTimeoutSeconds: 15
  rules:
    - name: require-ci-signature
      match:
        any:
          - resources:
              kinds: ["Pod"]
      verifyImages:
        - imageReferences:
            - "registry.example.com/team/*"
          failureAction: Audit     # switch to Enforce after reviewing reports
          mutateDigest: false      # must be false in Audit; set true with Enforce
          verifyDigest: true
          required: true
          attestors:
            - entries:
                - keyless:
                    issuer: "https://token.actions.githubusercontent.com"
                    subject: "https://github.com/example-org/app/.github/workflows/release.yml@refs/heads/main"
                    rekor:
                      url: "https://rekor.sigstore.dev"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To confirm it works, apply the policy in &lt;code&gt;Audit&lt;/code&gt; mode and create a Pod with an unsigned image from the matched registry path. Check the policy reports with &lt;code&gt;kubectl get policyreport -A&lt;/code&gt; and look for a failing result for your rule.&lt;/p&gt;

&lt;p&gt;Once the reports are clean for legitimate workloads, change &lt;code&gt;failureAction&lt;/code&gt; to &lt;code&gt;Enforce&lt;/code&gt;, set &lt;code&gt;mutateDigest: true&lt;/code&gt; so the Pod is rewritten to the verified digest, and repeat the test. The Pod creation should now be rejected with an error from the admission webhook that mentions image verification. The exact message text varies by version.&lt;/p&gt;

&lt;p&gt;Note that &lt;code&gt;imageReferences&lt;/code&gt; covers only your registry path. Images outside it pass untouched. To block everything unsigned, add a separate rule that denies images not matching an allowed registry pattern.&lt;/p&gt;

&lt;h2&gt;Advanced patterns&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Attestations.&lt;/strong&gt; A signature says "this identity vouched for this digest." Attestations (SBOM, SLSA provenance, scan results) say &lt;em&gt;what&lt;/em&gt; was vouched for. Kyverno can check attestation predicates with conditions, for example requiring that provenance names your builder. Newer cosign releases changed the default signature bundle format, so confirm that your controller version understands what your cosign version produces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scoped exceptions.&lt;/strong&gt; Rather than excluding namespaces in the policy, use a &lt;code&gt;PolicyException&lt;/code&gt; resource restricted to a specific policy, rule, and workload. It is reviewable in Git, and removing it restores enforcement. Depending on your Kyverno version and install options, exception support may need to be enabled, and it can be limited to specific namespaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multiple attestors.&lt;/strong&gt; You can require that both the build pipeline &lt;em&gt;and&lt;/em&gt; a release approver (a separate key or identity) have signed. This is useful for regulated environments and costs an extra signing step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Private or air-gapped clusters.&lt;/strong&gt; Public Fulcio and Rekor are external dependencies. If your clusters cannot reach them, run a private Sigstore stack, or use key-based signing with a public key (ideally from a KMS) in the policy. See the &lt;a href="https://docs.sigstore.dev/" rel="noopener noreferrer"&gt;Sigstore documentation&lt;/a&gt; for the trade-offs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Alternative controllers.&lt;/strong&gt; The Sigstore policy-controller offers a &lt;code&gt;ClusterImagePolicy&lt;/code&gt; resource and is a good fit if you want only signature checks. By default it enforces only in namespaces opted in with a label, so check that your namespaces are actually included.&lt;/p&gt;

&lt;p&gt;Kyverno makes more sense if you already use it for other policies. Newer Kyverno releases also provide a CEL-based &lt;code&gt;ImageValidatingPolicy&lt;/code&gt; type alongside &lt;code&gt;ClusterPolicy&lt;/code&gt;. For general background on admission webhooks, see the &lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/" rel="noopener noreferrer"&gt;Kubernetes admission controller docs&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Performance notes&lt;/h2&gt;

&lt;p&gt;Every Pod creation that matches a rule can trigger registry calls: a manifest lookup, a signature fetch, and possibly a transparency log check. That time is added to the API request, and the webhook timeout (at most 30 seconds in Kubernetes) caps it.&lt;/p&gt;

&lt;p&gt;A slow or rate-limited registry makes &lt;code&gt;kubectl apply&lt;/code&gt; and rollouts slow. One possible failure mode is a Deployment scaling up in a burst and exhausting registry rate limits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use digests.&lt;/strong&gt; With &lt;code&gt;mutateDigest&lt;/code&gt; enabled in enforce mode, later checks can hit a cache instead of re-resolving tags. Kyverno has an image verification cache; check its flags in the docs for your release.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the controller with multiple replicas&lt;/strong&gt; and a PodDisruptionBudget. With &lt;code&gt;failurePolicy: Fail&lt;/code&gt;, a down webhook blocks creation of every resource its webhook configuration matches, which is the actual blast radius of this design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep match scopes narrow.&lt;/strong&gt; Matching only the registry paths you own avoids pointless lookups for system images.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch the metrics.&lt;/strong&gt; Kyverno exposes Prometheus metrics for policy results and admission review duration, with names such as &lt;code&gt;kyverno_policy_results_total&lt;/code&gt; and &lt;code&gt;kyverno_admission_review_duration_seconds&lt;/code&gt;. Verify the names in your version. Alert on rising p95 duration and on spikes in rejected requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Watch out for:&lt;/strong&gt; the controller's own images. If the signature check is required for the namespace where Kyverno runs, a restart during a registry outage can deadlock recovery. Exempt that one namespace with a precise exception, and protect it with RBAC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When not to bother:&lt;/strong&gt; a single-team cluster that pulls only from one private registry with tight push permissions gets less from this than a multi-tenant platform. The cost is real: a new critical-path component, policy upkeep, and CI changes. More platform security notes are on &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/21/podgroup-gang-scheduling-in-kubernetes-1-37-for-training-jobs/" rel="noopener noreferrer"&gt;PodGroup Gang Scheduling in Kubernetes 1.37 for Training Jobs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/13/kubernetes-1-37-upgrade-what-changed-for-ops-teams/" rel="noopener noreferrer"&gt;Kubernetes 1.37 upgrade: what changed for ops teams&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/07/kubernetes-dra-extended-resources-gpus-without-device-plugins/" rel="noopener noreferrer"&gt;Kubernetes DRA Extended Resources: GPUs Without Device Plugins&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>Ubuntu 26.04 golden images on Hetzner with cloud-init</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Mon, 23 Nov 2026 08:02:13 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/ubuntu-2604-golden-images-on-hetzner-with-cloud-init-22bc</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/ubuntu-2604-golden-images-on-hetzner-with-cloud-init-22bc</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/23/ubuntu-26-04-golden-images-on-hetzner-with-cloud-init" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;The snapshot your team has cloned for two years was built by hand on Ubuntu 24.04. Nobody remembers which packages went in, the user-data file has grown to 200 lines, and the first reboot of every new server runs a slow &lt;code&gt;apt upgrade&lt;/code&gt;. Ubuntu 26.04 golden images are the cleanest way to reset that, and the timing is right. &lt;a href="https://ubuntu.com/about/release-cycle" rel="noopener noreferrer"&gt;Ubuntu 26.04 LTS was released on 2026-04-23&lt;/a&gt;, and its first point release, 26.04.1, is now out. Historically, the first point release is when Canonical opens LTS-to-LTS upgrades, and many teams wait for it before treating an LTS as safe for fleets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; build a fresh 26.04 snapshot with Packer's &lt;code&gt;hcloud&lt;/code&gt; builder instead of upgrading old snapshots. Bake slow, stable things (packages, hardening, agents) into the image. Leave per-server things (users, keys, hostnames) to cloud-init user-data at first boot. This applies to Hetzner Cloud fleets. If you install from ISO or on dedicated hardware, the autoinstall section below is the relevant path.&lt;/p&gt;

&lt;h2&gt;What changed and who is affected&lt;/h2&gt;

&lt;p&gt;Two mechanisms get confused here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;cloud-init&lt;/strong&gt; configures an already-installed image at boot. This is what Hetzner Cloud uses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Autoinstall&lt;/strong&gt; is the Subiquity installer's unattended mode for installing Ubuntu from ISO. It uses an &lt;code&gt;autoinstall.yaml&lt;/code&gt; with &lt;code&gt;autoinstall: version: 1&lt;/code&gt; and can embed a cloud-init &lt;code&gt;user-data&lt;/code&gt; section.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hetzner Cloud servers start from provider images or your snapshots. Autoinstall therefore matters only if you install from ISO, use a rescue-and-install flow, or run dedicated servers.&lt;/p&gt;

&lt;p&gt;You are affected if any of these is true:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your servers boot from a hand-made 24.04 snapshot that was never cleaned with &lt;code&gt;cloud-init clean&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Your user-data installs packages at every boot, so scaling out is slow and depends on mirror availability.&lt;/li&gt;
&lt;li&gt;Your provisioning scripts assume specific userland behavior, such as sudo flags or GNU coreutils output parsing. Recent Ubuntu releases have moved some core utilities toward Rust implementations. Check the 26.04 release notes against your scripts rather than assuming parity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cost: a snapshot is billed per GB per month, and you will hold at least two (old and new) during the migration. Treat the exact Hetzner image name for 26.04 as something to verify, not assume (see step 1).&lt;/p&gt;

&lt;h2&gt;Before/after config&lt;/h2&gt;

&lt;p&gt;The "before" pattern does everything at boot, on every server. It is slow and non-deterministic because it depends on the mirror state at that moment.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#cloud-config
# BEFORE: everything happens at first boot, on every server
package_update: true
package_upgrade: true
packages: [fail2ban, unattended-upgrades, prometheus-node-exporter]
runcmd:
  - [sh, -c, "curl -fsSL https://example.com/harden.sh | sh"]  # unpinned, unaudited
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;🧪 Lab — try this in your browser&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://tools.kuryzhev.cloud/?utm_source=devto&amp;amp;utm_medium=lab&amp;amp;utm_campaign=ubuntu-26-04-golden-images-on-hetzner-with-cloud-init#eolcountdown" rel="noopener noreferrer"&gt;EOL Countdown&lt;/a&gt; — Check when your Kubernetes, PostgreSQL, Node.js, Ubuntu… versions lose support. Paste command output or add versions — get status, days left and calendar reminders.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The "after" split keeps the slow work in the image and shrinks user-data to identity and secrets. This is the Packer template (HCL2) for the image:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;packer {
  required_plugins {
    hcloud = {
      source  = "github.com/hetznercloud/hcloud"
      version = "&amp;gt;= 1.6.0"   # check the plugin releases for the current version
    }
  }
}

variable "hcloud_token" {
  type      = string
  sensitive = true
}
variable "server_type"  { type = string }   # pick from: hcloud server-type list

locals {
  build_ts = formatdate("YYYYMMDDhhmm", timestamp())
}

source "hcloud" "golden" {
  token         = var.hcloud_token
  image         = "ubuntu-26.04"            # verify: hcloud image list --type system
  location      = "fsn1"
  server_type   = var.server_type
  ssh_username  = "root"
  snapshot_name = "golden-ubuntu-2604-${local.build_ts}"
  snapshot_labels = { role = "golden", os = "ubuntu-26.04" }
}

build {
  sources = ["source.hcloud.golden"]
  provisioner "shell" {
    inline = [
      "cloud-init status --wait",   # let first-boot cloud-init finish before changing things
      "apt-get update &amp;amp;&amp;amp; DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade",
      "DEBIAN_FRONTEND=noninteractive apt-get -y install fail2ban unattended-upgrades prometheus-node-exporter",
      "cloud-init clean --logs --seed",   # re-arm cloud-init for the next boot
      "truncate -s 0 /etc/machine-id",    # avoid duplicate machine IDs across clones
      "rm -f /etc/ssh/ssh_host_*"         # host keys are regenerated on first boot
    ]
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step-by-step migration to Ubuntu 26.04 golden images&lt;/h2&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Confirm the base image.&lt;/strong&gt; Run &lt;code&gt;hcloud image list --type system | grep -i ubuntu&lt;/code&gt; and use the exact name it prints. If 26.04 is missing in your project or location, stop here. Do not upgrade a 24.04 box in place instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Move user-data to identity only.&lt;/strong&gt; Remove package installs and hardening scripts. Keep users, SSH keys, hostname and &lt;code&gt;write_files&lt;/code&gt; for per-environment config.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build.&lt;/strong&gt; Inject the token from your secret store or CI secret as an environment variable, never in the template or on the command line: &lt;code&gt;export PKR_VAR_hcloud_token="&amp;lt;token-from-secret-store&amp;gt;"&lt;/code&gt;. Then run &lt;code&gt;packer init . &amp;amp;&amp;amp; packer build -var "server_type=&amp;lt;type&amp;gt;" .&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validate user-data against the schema&lt;/strong&gt; before using it. Run &lt;code&gt;cloud-init schema --config-file user-data.yaml&lt;/code&gt; on any machine with cloud-init installed. The slim file looks like this:&lt;/li&gt;
&lt;/ol&gt;

&lt;pre&gt;&lt;code&gt;#cloud-config
hostname: web-01
ssh_pwauth: false
users:
  - name: deploy
    groups: [sudo]
    shell: /bin/bash
    sudo: "ALL=(ALL) NOPASSWD:ALL"   # tighten if your policy requires a password
    ssh_authorized_keys:
      - ssh-ed25519 AAAA... deploy@ci
&lt;/code&gt;&lt;/pre&gt;

&lt;ol start="5"&gt;
&lt;li&gt;
&lt;strong&gt;Canary first.&lt;/strong&gt; Point one non-critical server at the new snapshot ID and keep the rest on the old one. Use the same &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;workflow you already use&lt;/a&gt; for fleet changes (Ansible, OpenTofu or Terraform), so the image ID lives in one variable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Widen gradually&lt;/strong&gt; by replacing servers, not upgrading them. Replacement is what makes rollback trivial.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you do need autoinstall for ISO or dedicated installs, keep the same split:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A minimal &lt;code&gt;autoinstall.yaml&lt;/code&gt; for identity, SSH and storage layout.&lt;/li&gt;
&lt;li&gt;Everything else in the embedded &lt;code&gt;user-data&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href="https://canonical-subiquity.readthedocs.io/" rel="noopener noreferrer"&gt;Subiquity documentation&lt;/a&gt; lists the current schema. Field names and defaults are version-dependent.&lt;/p&gt;

&lt;h2&gt;Verify and roll back&lt;/h2&gt;

&lt;p&gt;Create a throwaway server from the new snapshot. Check that cloud-init ran as a first boot, not a replay of the build:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;hcloud server create --name golden-test --type &amp;lt;type&amp;gt; \
  --image &amp;lt;snapshot-id&amp;gt; --ssh-key deploy \
  --user-data-from-file user-data.yaml

ssh deploy@&amp;lt;ip&amp;gt; 'cloud-init status --long; sudo cloud-init schema --system; \
  cat /etc/machine-id; ls /etc/ssh/ssh_host_*; lsb_release -ds'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Expect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;status: done&lt;/code&gt; with no errors.&lt;/li&gt;
&lt;li&gt;A schema validation message saying the config is valid.&lt;/li&gt;
&lt;li&gt;A freshly generated, non-empty machine ID that differs from the build host.&lt;/li&gt;
&lt;li&gt;New SSH host keys.&lt;/li&gt;
&lt;li&gt;An Ubuntu 26.04 description string.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also check &lt;code&gt;/var/log/cloud-init.log&lt;/code&gt; for warnings. To confirm time-to-ready improved, compare &lt;code&gt;cloud-init analyze blame&lt;/code&gt; and &lt;code&gt;systemd-analyze&lt;/code&gt; output with a server on the old image. Record your own numbers; do not trust anyone else's.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rollback&lt;/strong&gt; means replacing servers back onto the previous snapshot ID. That only works if you do not delete the old snapshot. Label it (for example &lt;code&gt;role=golden-previous&lt;/code&gt;) and keep it for at least one full release cycle of your own services. Roll back on a concrete signal:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Failed health checks on canaries.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cloud-init status&lt;/code&gt; reporting &lt;code&gt;error&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A regression in your application's package set.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Gotchas after the switch&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Watch out for a stale machine-id.&lt;/strong&gt; If you skip the &lt;code&gt;truncate&lt;/code&gt; step, clones can share an identity. That can break DHCP leases, log aggregation keyed on machine ID, and some monitoring agents. Check &lt;code&gt;cat /etc/machine-id&lt;/code&gt; on two servers from the same snapshot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Watch out for cloud-init not re-running.&lt;/strong&gt; If the build left state in &lt;code&gt;/var/lib/cloud&lt;/code&gt;, user-data may be silently skipped on new servers. That is why &lt;code&gt;cloud-init clean --logs --seed&lt;/code&gt; is the last provisioning step. Check the flags with &lt;code&gt;cloud-init clean --help&lt;/code&gt; on your installed version.&lt;/p&gt;

&lt;p&gt;Other documented-behavior traps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Do not hardcode &lt;code&gt;datasource_list&lt;/code&gt; in the image&lt;/strong&gt; unless you have a reason. The Hetzner datasource is detected automatically on Hetzner Cloud, and a hardcoded list breaks the same image elsewhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Snapshots age.&lt;/strong&gt; Rebuild on a schedule (weekly or monthly) so &lt;code&gt;unattended-upgrades&lt;/code&gt; is not the only thing patching a months-old base. Known patch state matters more now: since 11 September 2026, the EU Cyber Resilience Act requires manufacturers of products with digital elements to report actively exploited vulnerabilities (24h early warning, 72h notification).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not use this approach for stateful servers&lt;/strong&gt;, such as databases with local disks. Rebuild-and-replace assumes data lives on volumes or elsewhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pin what you download in provisioners with checksums.&lt;/strong&gt; &lt;code&gt;curl | sh&lt;/code&gt; inside a golden image bakes an unaudited script into every future server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For schema details and module options, use the &lt;a href="https://cloudinit.readthedocs.io/" rel="noopener noreferrer"&gt;cloud-init documentation&lt;/a&gt;. For builder settings, use the &lt;a href="https://developer.hashicorp.com/packer" rel="noopener noreferrer"&gt;Packer documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/19/ubuntu-26-04-upgrade-with-ansible-migrate-24-04-fleets-safely/" rel="noopener noreferrer"&gt;Ubuntu 26.04 Upgrade with Ansible: Migrate 24.04 Fleets Safely&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/10/migrate-playbooks-to-ansible-core-2-22-without-breaking-collections/" rel="noopener noreferrer"&gt;Migrate Playbooks to ansible-core 2.22 Without Breaking Collections&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/08/migrate-nvm-pyenv-and-tfenv-to-one-mise-toolchain-file/" rel="noopener noreferrer"&gt;Migrate nvm, pyenv and tfenv to one mise toolchain file&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
    <item>
      <title>k9s incident debugging: shortcuts and plugins that save minutes</title>
      <dc:creator>Oleksandr Kuryzhev</dc:creator>
      <pubDate>Sun, 22 Nov 2026 08:02:19 +0000</pubDate>
      <link>https://dev.to/oleksandr_kuryzhev_42873f/k9s-incident-debugging-shortcuts-and-plugins-that-save-minutes-1gk</link>
      <guid>https://dev.to/oleksandr_kuryzhev_42873f/k9s-incident-debugging-shortcuts-and-plugins-that-save-minutes-1gk</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://kuryzhev.cloud/2026/11/22/k9s-incident-debugging-shortcuts-and-plugins-that-save-minutes" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;The scenario&lt;/h2&gt;

&lt;p&gt;A deploy finishes and the checkout API starts returning 5xx. The on-call engineer types &lt;code&gt;kubectl get pods -n shop&lt;/code&gt;, then &lt;code&gt;kubectl describe&lt;/code&gt;, then &lt;code&gt;kubectl logs --previous&lt;/code&gt;, each with a pod name copied by hand. Every command is fine. The copy-paste between them is where the minutes go. k9s incident debugging removes that loop. You get one terminal view where you filter, drill into the failing pod, read logs and events, and open a shell without retyping names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer:&lt;/strong&gt; start k9s read-only against the right context and namespace, then filter to unhealthy pods with &lt;code&gt;/!Running&lt;/code&gt;. Read previous logs with &lt;code&gt;p&lt;/code&gt; on the pod. Finally, add two small plugins (pod events and an ephemeral debug container) in &lt;code&gt;plugins.yaml&lt;/code&gt;. This applies when you debug interactively on a cluster you already have access to. It does not replace dashboards, alerts or an audit trail.&lt;/p&gt;

&lt;p&gt;Shortcuts below are the documented defaults of recent k9s releases. Key bindings and config keys have shifted between versions, so press &lt;code&gt;?&lt;/code&gt; inside k9s and check the &lt;a href="https://k9scli.io/" rel="noopener noreferrer"&gt;k9s documentation&lt;/a&gt; for your installed version.&lt;/p&gt;

&lt;h2&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;You need k9s and kubectl installed. For example, use &lt;code&gt;brew install k9s&lt;/code&gt; on macOS and Linuxbrew, or the release binaries from the project's GitHub page. Run &lt;code&gt;k9s version&lt;/code&gt; and note the result, because plugin fields vary slightly by version. The cluster can be any maintained Kubernetes release, including 1.37, since ephemeral containers have been stable for a long time.&lt;/p&gt;

&lt;p&gt;RBAC decides what k9s can actually do. Reading pods, logs and events needs &lt;code&gt;get&lt;/code&gt;/&lt;code&gt;list&lt;/code&gt;/&lt;code&gt;watch&lt;/code&gt; on pods, &lt;code&gt;pods/log&lt;/code&gt; and events. The debug plugin needs two more permissions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;patch&lt;/code&gt; on &lt;code&gt;pods/ephemeralcontainers&lt;/code&gt;, because kubectl debug adds the container with a patch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;create&lt;/code&gt; on &lt;code&gt;pods/attach&lt;/code&gt;, so it can attach interactively.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check them before an incident, not during one:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# all should print "yes" for the namespace you debug in
kubectl auth can-i get pods/log -n shop
kubectl auth can-i patch pods/ephemeralcontainers -n shop
kubectl auth can-i create pods/attach -n shop
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Watch out for:&lt;/strong&gt; k9s uses whatever your kubeconfig says. If your shell's current context is production, k9s opens production. Always pass &lt;code&gt;--context&lt;/code&gt; explicitly during an incident.&lt;/p&gt;

&lt;h2&gt;Step 1: Launch read-only and triage with filters&lt;/h2&gt;



&lt;p&gt;Open straight into the pods view of the affected namespace. Use read-only mode so a stray &lt;code&gt;ctrl-d&lt;/code&gt; cannot delete anything:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# --readonly disables edit/delete/shell actions; -c picks the starting resource view
k9s --readonly --context prod-eu -n shop -c pods
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Inside the view, these keys do most of the triage work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; starts a filter. &lt;code&gt;/!Running&lt;/code&gt; is an inverse regex filter that hides healthy pods. That leaves the &lt;code&gt;CrashLoopBackOff&lt;/code&gt;, &lt;code&gt;Error&lt;/code&gt; and &lt;code&gt;Pending&lt;/code&gt; rows.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/-l app=checkout&lt;/code&gt; filters by label. &lt;code&gt;/-f&lt;/code&gt; is a fuzzy match.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:&lt;/code&gt; opens command mode. &lt;code&gt;:deploy&lt;/code&gt;, &lt;code&gt;:events&lt;/code&gt;, &lt;code&gt;:node&lt;/code&gt;, &lt;code&gt;:ns&lt;/code&gt; and &lt;code&gt;:ctx&lt;/code&gt; switch resource types, namespaces and contexts.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;:xray deploy&lt;/code&gt; shows a deployment's tree down to ReplicaSets and pods. &lt;code&gt;:pulse&lt;/code&gt; gives a cluster-wide health overview.&lt;/li&gt;
&lt;li&gt;Column sort shortcuts, for example by CPU or memory, are listed in the key hints. &lt;code&gt;ctrl-w&lt;/code&gt; toggles wide mode, which adds extra columns such as readiness gates and nominated node.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Press &lt;code&gt;d&lt;/code&gt; for describe on a selected pod. The Events section at the bottom usually names the cause: a failed image pull, a failing probe, or &lt;code&gt;OOMKilled&lt;/code&gt; in the last state. Press &lt;code&gt;y&lt;/code&gt; for the YAML if you need the exact probe or resource limits.&lt;/p&gt;

&lt;h2&gt;Step 2: Read logs for the failing container&lt;/h2&gt;

&lt;p&gt;Press &lt;code&gt;l&lt;/code&gt; on a pod to open its logs. In a multi-container pod, press Enter on the pod to list its containers, then press &lt;code&gt;l&lt;/code&gt; on the one you want.&lt;/p&gt;

&lt;p&gt;A crash-looping container is the typical case where the current log is empty or only a few seconds old. Press &lt;code&gt;p&lt;/code&gt; on the pod or container row instead of &lt;code&gt;l&lt;/code&gt;. That opens the previous container instance's logs, which show the output from just before the crash.&lt;/p&gt;

&lt;p&gt;Other log-view keys worth memorizing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The number keys change the time window. In current releases, &lt;code&gt;0&lt;/code&gt; is tail, &lt;code&gt;1&lt;/code&gt; is head, and &lt;code&gt;2&lt;/code&gt; to &lt;code&gt;6&lt;/code&gt; cover 1m to 1h. Confirm the mapping in the hint bar.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;t&lt;/code&gt; toggles timestamps and &lt;code&gt;w&lt;/code&gt; toggles line wrap.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;s&lt;/code&gt; toggles autoscroll and &lt;code&gt;f&lt;/code&gt; goes fullscreen.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; filters log lines with a regex such as &lt;code&gt;/error|panic|timeout&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The default log buffer can be too small for chatty services. Tune it in the k9s &lt;code&gt;config.yaml&lt;/code&gt;. The path is often &lt;code&gt;~/.config/k9s/config.yaml&lt;/code&gt;; run &lt;code&gt;k9s info&lt;/code&gt; to see the exact path on your machine:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;k9s:
  logger:
    tail: 200          # lines loaded when the view opens
    buffer: 5000       # lines kept in memory
    sinceSeconds: 300  # -1 means "all available"; 300 keeps the first view fast
    textWrap: false
    showTime: true
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Watch out for:&lt;/strong&gt; a larger buffer and a long time window mean more memory and more API server log traffic per open view. Keep &lt;code&gt;sinceSeconds&lt;/code&gt; small and widen it with the number keys only when needed.&lt;/p&gt;

&lt;h2&gt;Step 3: Add plugins for events and a debug shell&lt;/h2&gt;

&lt;p&gt;Plugins bind a key to a shell command. They expose context as variables such as &lt;code&gt;$CONTEXT&lt;/code&gt;, &lt;code&gt;$NAMESPACE&lt;/code&gt;, &lt;code&gt;$NAME&lt;/code&gt;, &lt;code&gt;$POD&lt;/code&gt; and &lt;code&gt;$KUBECONFIG&lt;/code&gt;. In the containers scope, &lt;code&gt;$NAME&lt;/code&gt; is the container and &lt;code&gt;$POD&lt;/code&gt; is its pod. Plugins live in &lt;code&gt;plugins.yaml&lt;/code&gt; in the same config directory. This file adds a per-pod event list and an ephemeral debug container:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;plugins:
  pod-events:
    shortCut: Shift-E            # check for clashes with built-in keys via "?"
    description: Events for pod
    scopes:
      - pods
    command: bash
    background: false
    args:
      - -c
      - "kubectl --context $CONTEXT -n $NAMESPACE events --for pod/$NAME | less -R"
  debug-container:
    shortCut: Shift-D
    description: Debug with ephemeral container
    dangerous: true              # hidden/blocked in --readonly mode
    confirm: true                # asks before running
    scopes:
      - containers
    command: bash
    background: false
    args:
      - -c
      - "kubectl --context $CONTEXT -n $NAMESPACE debug -it $POD --target=$NAME --image=nicolaka/netshoot:latest -- bash"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The debug plugin follows the documented &lt;a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/" rel="noopener noreferrer"&gt;kubectl debug workflow&lt;/a&gt;. It attaches an ephemeral container that targets the selected container's process namespace, where the container runtime supports it. The pod's network namespace is shared as well. That gives you &lt;code&gt;dig&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt; and &lt;code&gt;ss&lt;/code&gt; next to a distroless container that has no shell of its own.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Costs and limits:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An ephemeral container cannot be removed from a pod. It disappears only when the pod is replaced.&lt;/li&gt;
&lt;li&gt;The image is pulled from a public registry by default. That fails on air-gapped clusters or behind strict admission policies.&lt;/li&gt;
&lt;li&gt;If either applies to you, mirror a debug image internally. Pin it by tag or digest rather than &lt;code&gt;latest&lt;/code&gt;, and change &lt;code&gt;--image&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Do not use this on a pod you must keep pristine for forensics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Step 4: Save your triage views as hotkeys and aliases&lt;/h2&gt;

&lt;p&gt;The first minutes of an incident often go to the same few views. Put them on keys in &lt;code&gt;hotkeys.yaml&lt;/code&gt; and give them short names in &lt;code&gt;aliases.yaml&lt;/code&gt;, both in the k9s config directory:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# hotkeys.yaml
hotKeys:
  shift-0:
    shortCut: Shift-0
    description: Pods
    command: pods
  shift-1:
    shortCut: Shift-1
    description: Events
    command: events

# aliases.yaml
aliases:
  dep: apps/v1/deployments   # type ":dep" instead of ":deploy"
  cj: batch/v1/cronjobs
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A shell alias keeps the safe launch one word away. Add this to &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# usage: k9sro prod-eu shop
k9sro() { k9s --readonly --context "$1" -n "${2:-default}" -c pods; }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Start read-only by default and drop the flag only for the specific action that needs it. Read-only protects against slips, but it is not an access control: anyone with the kubeconfig can still run kubectl directly. Real restrictions belong in RBAC. For more day-to-day tooling write-ups, see &lt;a href="https://kuryzhev.cloud/" rel="noopener noreferrer"&gt;kuryzhev.cloud&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Verify and test&lt;/h2&gt;

&lt;p&gt;Run these checks in a non-production namespace before you need them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;k9s info&lt;/code&gt; prints the config, plugin and log directories. Confirm that &lt;code&gt;plugins.yaml&lt;/code&gt;, &lt;code&gt;hotkeys.yaml&lt;/code&gt; and &lt;code&gt;aliases.yaml&lt;/code&gt; sit in the listed config directory.&lt;/li&gt;
&lt;li&gt;Start &lt;code&gt;k9s --context staging -n default -c pods&lt;/code&gt;, select a pod, press &lt;code&gt;Enter&lt;/code&gt; to reach its containers, and look at the hint bar. &lt;code&gt;Shift-D&lt;/code&gt; should appear there. Go back and select a pod row; &lt;code&gt;Shift-E&lt;/code&gt; should appear as well.&lt;/li&gt;
&lt;li&gt;If a key is missing, the usual causes are a YAML indentation error, a wrong &lt;code&gt;scopes&lt;/code&gt; value, or a clash with a built-in binding. k9s writes details to its log file, whose path &lt;code&gt;k9s info&lt;/code&gt; also shows.&lt;/li&gt;
&lt;li&gt;Press &lt;code&gt;Shift-E&lt;/code&gt; on a pod. You should get a table of events with columns such as LAST SEEN, TYPE, REASON and MESSAGE, in a pager you leave with &lt;code&gt;q&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Start k9s with &lt;code&gt;--readonly&lt;/code&gt; and confirm the debug plugin is blocked. Then start without the flag and confirm it asks for confirmation before attaching.&lt;/li&gt;
&lt;li&gt;Deploy a throwaway pod with a bad image or a failing command, then practice the sequence: &lt;code&gt;/!Running&lt;/code&gt;, &lt;code&gt;d&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, then &lt;code&gt;p&lt;/code&gt; for previous logs. The goal is to do it without touching the mouse or retyping a pod name.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the debug shell fails with a forbidden error, the earlier &lt;code&gt;kubectl auth can-i patch pods/ephemeralcontainers&lt;/code&gt; and &lt;code&gt;create pods/attach&lt;/code&gt; checks would have said so. Fix the namespaced Role rather than widening it to cluster scope.&lt;/p&gt;

&lt;h2&gt;Where this leaves you&lt;/h2&gt;

&lt;p&gt;None of this is magic. k9s is a faster front end for the same API calls, and its value during an incident is fewer keystrokes and fewer wrong-pod mistakes. Keep three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the read-only launcher alias,&lt;/li&gt;
&lt;li&gt;two or three plugins you actually trust,&lt;/li&gt;
&lt;li&gt;an RBAC role that grants only what the on-call needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Skip plugins that mutate cluster state unless they carry &lt;code&gt;dangerous&lt;/code&gt; and &lt;code&gt;confirm&lt;/code&gt;. For repeatable evidence, post-incident review or anything that needs an audit trail, rely on your logging stack and API server audit logs. Treat k9s as the interactive tool that gets you to the cause sooner.&lt;/p&gt;

&lt;h2&gt;Related&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/07/kubernetes-dra-extended-resources-gpus-without-device-plugins/" rel="noopener noreferrer"&gt;Kubernetes DRA Extended Resources: GPUs Without Device Plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/21/podgroup-gang-scheduling-in-kubernetes-1-37-for-training-jobs/" rel="noopener noreferrer"&gt;PodGroup Gang Scheduling in Kubernetes 1.37 for Training Jobs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kuryzhev.cloud/2026/11/16/hetzner-opentofu-cluster-vs-aws-eks-for-small-teams/" rel="noopener noreferrer"&gt;Hetzner OpenTofu Cluster vs AWS EKS for Small Teams&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devops</category>
    </item>
  </channel>
</rss>
