Description

The kubernetes crawler looks recursively for every .yaml and .yml file from a root directory, and updates the container images declared in any Kubernetes pod specification it recognises.

Multi-document YAML files are supported, and each document is addressed by index in the generated manifest.

This crawler is enabled by default, so it can be used either automatically by running updatecli diff from a directory containing the files to update, or by providing a manifest. The automatic discovery behavior can be tuned by providing a YAML manifest with a kubernetes crawler in top-level directive autodiscovery as explained in the "Autodiscovery" page.

Supported resources

Images are read from containers and initContainers at any of these locations:

  • spec.containers / spec.initContainers - bare Pod

  • spec.template.spec.… - Deployment, DaemonSet, StatefulSet, Job, and anything else built on a pod template

  • spec.jobTemplate.spec.template.spec.… - CronJob

Matching is structural: apiVersion and kind are not checked, so any document exposing one of those paths is processed.

Generated manifests

Each image produces a dockerimage source for the latest tag and a yaml target that rewrites the image reference in place. When digest pinning is enabled, a dockerdigest source is added and the digest is written alongside the tag.

digest defaults to true. Set digest: false to track the tag only.

Authentication

Use auths to reach private registries, keyed by registry URL without a scheme, accepting either a token or a username/password pair. When it is empty Updatecli falls back to the ambient OCI credentials, such as those written by docker login.

Version filtering

If unspecified, the version filter defaults to kind semver with pattern *.

The pattern is then narrowed per image using the tag currently in the file: an image on 3.18 is filtered with >=3.18, and a tagfilter regex derived from the shape of that tag is added so unrelated tag conventions are not considered.

More details on the "Version Filtering" page.

Limitations

  • Kustomize images: transformers in a kustomization.yaml are not supported. Plain Kubernetes manifests living inside a kustomize tree are picked up normally, because they carry a standard pod specification.

  • files patterns are matched against the file name only, not against the path. Use .yaml, not manifests/.yaml.

  • An image whose value contains a template expression, such as "{{ .Values.image.repository }}:{{ .Values.image.tag }}", cannot be resolved to a tag. A digest-only manifest is generated for it, which is rarely actionable (use ignore to exclude these).

Manifest

Parameters

NameTypeDescriptionRequired
authsobject

“auths” defines the registry credentials, keyed by registry host without scheme.

remark:

  • when empty, Updatecli uses the local OCI credentials, such as the Docker ones.

example:

auths:
  "ghcr.io":
    token: "xxx"
  "index.docker.io":
    username: "admin"
    password: "password"
    passwordstring

“password” defines the container registry password used for authentication.

default: credentials are retrieved from the local environment, such as ~/.docker/config.json.

remark:

  • “password” requires “username”.
  • “token” cannot be combined with both “username” and “password”.
    tokenstring

“token” defines the container registry bearer token used for authentication.

default: credentials are retrieved from the local environment, such as ~/.docker/config.json.

remark:

  • “token” cannot be combined with both “username” and “password”.
    usernamestring

“username” defines the container registry username used for authentication.

default: credentials are retrieved from the local environment, such as ~/.docker/config.json.

remark:

  • “username” requires “password”.
  • “token” cannot be combined with both “username” and “password”.
digestboolean

“digest” defines whether the generated manifests pin the image digest in addition to the tag.

default: true

filesarray

“files” defines the file name patterns the crawler searches for.

The pattern syntax is:

    pattern:
        { term }
    term:
        '*'         matches any sequence of non-Separator characters
        '?'         matches any single non-Separator character
        '[' [ '^' ] { character-range } ']'
                    character class (must be non-empty)
        c           matches character c (c != '*', '?', '\\', '[')
        '\\' c      matches character c

character-range:
        c           matches character c (c != '\\', '-', ']')
        '\\' c      matches character c
        lo '-' hi   matches character c for lo <= c <= hi

default:

- "*.yaml"
- "*.yml"

remark:

  • the pattern is matched against the file name only, not against its path.
  • the pattern must match the whole name, not just a substring.
  • on Windows, escaping is disabled and \\ is treated as a path separator.
ignorearray

“ignore” defines rules to exclude matching container images from the autodiscovery.

remark:

  • a container image is ignored when it matches at least one rule.
    imagesarray

“images” defines the container image names to match.

remark:

  • an image matches when its name equals one of the values.
    pathstring

“path” defines a Kubernetes file path pattern.

remark:

  • the pattern must match the whole path, not just a substring.
  • the pattern follows the Go filepath.Match syntax, such as “*” or “?”.
onlyarray

“only” defines rules to restrict the autodiscovery to matching container images.

remark:

  • a container image is kept only when it matches at least one rule.
    imagesarray

“images” defines the container image names to match.

remark:

  • an image matches when its name equals one of the values.
    pathstring

“path” defines a Kubernetes file path pattern.

remark:

  • the pattern must match the whole path, not just a substring.
  • the pattern follows the Go filepath.Match syntax, such as “*” or “?”.
rootdirstring

“rootdir” defines the directory where the crawler starts searching for Kubernetes files.

default: the scm directory when “scmid” is set, otherwise the directory relative paths resolve from, by default the working directory.

remark:

  • a relative path is resolved from the default directory.
  • an absolute path is used as is, instead of the scm directory.
versionfilterobject

“versionfilter” defines the version filter used by the generated manifests.

default: kind “semver” with pattern “>=”, combined with a tag filter derived from the current tag.

remark:

  • with kind “semver”, “pattern” accepts:
    • “prerelease”: the latest prerelease of the current version.
    • “patch”: patch updates only.
    • “minor”: patch and minor updates.
    • “minoronly”: minor updates only.
    • “major”: patch, minor and major updates.
    • “majoronly”: major updates only.
    • a version constraint, such as “>= 1.0.0”.
  • with kind “regex”, “pattern” accepts a regular expression.
  • more examples at https://www.updatecli.io/docs/core/versionfilter/

example:

versionfilter:
  kind: semver
  pattern: minor
    kindstring

“kind” defines the versioning scheme used to select a version.

default: latest

remark:

  • accepted values are “latest”, “semver”, “regex”, “regex/semver”, “time”, “regex/time”, “lex” and “pep440”.
  • “latest” returns the last version of the list.
  • “lex” sorts the versions lexicographically and returns the last one.
  • “pep440” follows https://peps.python.org/pep-0440/

example:

  • kind: semver
    patternstring

“pattern” defines the version pattern, according to “kind”.

default:

  • latest: “latest”
  • semver and pep440: “*”
  • regex: “.*”
  • time and regex/time: “2006-01-02”

remark:

  • for “latest”, “latest” returns the last version, any other value must match a version exactly.
  • for “semver” and “regex/semver”, it is a semantic versioning constraint.
  • for “pep440”, it is a pep440 version specifier.
  • for “regex”, it is a regular expression.
  • for “time” and “regex/time”, it is a Go date layout.
  • ignored by “lex”.

example:

  • pattern: ~1.2
  • pattern: “>=1.0.0 <2.0.0”
  • pattern: ^v\d+.\d+.\d+$
    regexstring

“regex” defines the regular expression extracting the version from each entry.

remark:

  • only used by the kinds “regex/semver” and “regex/time”.
  • the value of the first capture group is used as the version.

example:

  • regex: ^v(\d+.\d+.\d+)$
    replaceallobject

“replaceall” applies a regular expression replacement to each version before filtering.

remark:

  • only used by the kinds “regex”, “regex/semver” and “regex/time”.
  • the replacement runs before “pattern” or “regex” is evaluated.

example:

replaceall:
  pattern: "_"
  replacement: "."

turns “curl-8_15_0” into “curl-8.15.0”.

        patternstring

“pattern” defines the regular expression matching the text to replace.

example:

  • pattern: “_”
        replacementstring

“replacement” defines the text replacing each match of “pattern”.

remark:

  • capture groups can be referenced with $1, $2, and so on.

example:

  • replacement: “.”
    strictboolean

“strict” enforces strict semantic versioning rules when parsing versions.

default: false

remark:

  • only used by the kinds “semver” and “regex/semver”.
⚠ This table is generated from the Updatecli codebase and may contain inaccurate data. Feel free to report them on github.com/updatecli/updatecli

Example

# updatecli.d/default.yaml
name: "Kubernetes autodiscovery"
scms:
  default:
    kind: git 
    spec:
      url: "https://github.com/jenkins-infra/release.git"
      branch: master
autodiscovery:
  scmid: default
  crawlers:
    kubernetes:
      digest: true
      versionfilter:
        kind: semver
        pattern: minoronly
      ## To ignore specific path
      #ignore:
      #  - images:
      #      - "mcr.microsoft.com/dotnet/framework/sdk"
      only:
        - images:
            - "mcr.microsoft.com/dotnet/framework/sdk"