← All recipes
Moderne licensed

Change k0rdent template version

Recipe IDorg.openrewrite.kubernetes.k0rdent.ChangeTemplateVersionArtifactorg.openrewrite.recipe:rewrite-kubernetes

Move a k0rdent ClusterTemplate, ProviderTemplate or ServiceTemplate to a new chart version, taking its name and everything that points at that name along with it. k0rdent encodes the chart version in the template's metadata.name, so a version bump renames the resource: aws-standalone-cp-1-0-42 becomes aws-standalone-cp-1-0-43. That name is referenced from ClusterDeployment.spec.template, from services[].template on a ClusterDeployment or MultiClusterService, from Release.spec.kcm.template, spec.regional.template, spec.capi.template and spec.providers[].template, from spec.core.kcm.template, spec.core.capi.template and spec.providers[].template on a Management or Region, and from the supportedTemplates of a ClusterTemplateChain or ServiceTemplateChain. All of them move together here, along with any file whose name encodes the template name, because a rename that misses one of them leaves a reference the controller cannot resolve. A template in a file that renders through a template engine is reported and left alone, and so are its referrers: its name is whatever the engine produces, so nothing can be moved without stranding the rest. This changes the template's own spec.helm.chartSpec.version too, but not the chart it points at. Run org.openrewrite.kubernetes.helm.ChangeChartVersion alongside it to move the chart's own Chart.yaml, the charts that depend on it, and any Flux HelmRelease.

Single recipeProprietary

Usage

You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.kubernetes.k0rdent.ChangeTemplateVersion --recipe-option "chart=aws-standalone-cp" --recipe-option "newVersion=1.0.43"

If the recipe isn’t available locally, install it with:

mod config recipes jar install org.openrewrite.recipe:rewrite-kubernetes:RELEASE

Options

NameTypeDescription
chartrequiredStringThe chart the template wraps, as written in its spec.helm.chartSpec.chart.
e.g. aws-standalone-cp
oldVersionStringThe version being replaced. When omitted, whatever version the template currently declares is used.
e.g. 1.0.42
newVersionrequiredStringThe new chart version. Must be an exact semantic version.
e.g. 1.0.43

Data tables

Structured output this recipe can produce.

  • k0rdent template name changesThe template resource that was renamed, every reference that moved with it, and the templates that were left alone.org.openrewrite.kubernetes.table.TemplateNameChanges
  • Source files that had resultsSource files that were modified by the recipe run.org.openrewrite.table.SourcesFileResults
  • Source files that had search resultsSearch results that were found during the recipe run.org.openrewrite.table.SearchResults
  • Source files that errored on a recipeThe details of all errors produced by a recipe run.org.openrewrite.table.SourcesFileErrors
  • Recipe performanceStatistics used in analyzing the performance of recipes.org.openrewrite.table.RecipeRunStats