Migrate deprecated k0rdent serviceSpec fields
org.openrewrite.kubernetes.k0rdent.MigrateDeprecatedServiceSpecFieldsArtifactorg.openrewrite.recipe:rewrite-kubernetesMove the fields k0rdent deprecated on spec.serviceSpec into the spec.serviceSpec.provider.config blob that supersedes them, on ClusterDeployment and MultiClusterService. The nine that move are syncMode, templateResourceRefs, policyRefs, driftIgnore, driftExclusions, priority, stopOnConflict, reload and continueOnError, plus createNamespace and replace on each service's helmOptions, which move into helmOptions.installOptions.
reload is renamed to reloader on the way, because that is the key the state management provider unmarshals; a hand migration that keeps the old spelling produces a manifest the apiserver accepts and the controller ignores.
Fields are left where they are, and reported in a data table, when the move would change what the resource does: the document renders through Helm, so what is written is not what is applied; provider.name or provider.config is already set, in which case the controller is already ignoring the deprecated fields and moving them would switch settings on; installOptions already declares a different value; or the resource is declared against k0rdent.mirantis.com/v1alpha1, whose schema has no provider field at all, so the apiserver would prune whatever was written there.
The provider.name case is the subtle one. StateManagementProviderConfigFromServiceSpec folds the deprecated fields into a config blob only when neither provider.name nor provider.config is set; name it, and every deprecated field is discarded. Moving them into provider.config would hand a named provider a syncMode, priority or reloader it is not acting on today.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.kubernetes.k0rdent.MigrateDeprecatedServiceSpecFieldsIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-kubernetes:RELEASEOptions
| Name | Type | Description |
|---|---|---|
fileMatcher | String | Matching files will be modified. This is a glob expression. e.g. **/*-multiclusterservice.yaml |
Data tables
Structured output this recipe can produce.
- Deprecated k0rdent `serviceSpec` fieldsEvery deprecated `serviceSpec` field found, where it was moved to, and for the ones that were left in place, why.
org.openrewrite.kubernetes.table.DeprecatedServiceSpecFields - 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