convoy docs
Search

Release mutations

The fields, types, admission rules and subresource of the Release mutation pipeline.

mutations is a top-level field of a Release, next to spec. It is an ordered list. convoy runs it after rendering, and before it calculates the renderRef. For the behavior, see Mutations.

PathRelease.mutations
List typeatomic: a write replaces the full list
Subresourcereleases/mutations (GET, PUT, PATCH)
Changes metadata.generationNo

Example#

A celTransform mutation that reads its CEL expression from a ConfigMap:

yaml
mutations:
  - type: celTransform
    target: { group: apps, version: v1, kind: Deployment }
    from: { kind: ConfigMap, name: mutation-cel-transform, path: transform.cel }
mutations/configmap-cel-transform.yaml
# celTransform content sourced from a ConfigMap.
#
# The CEL expression returns a map overlay that is RFC7386-merged onto each
# matched object. Available variables:
#   cluster -> the target Cluster's name (cluster.name) + its Spec.Metadata keys
#              (e.g. cluster.region)
#   self    -> the Release's name / namespace / labels / annotations
#   object  -> the object being mutated
#
#   mutations:
#     - type: celTransform
#       target: { group: apps, version: v1, kind: Deployment }
#       from: { kind: ConfigMap, name: mutation-cel-transform, path: transform.cel }
#   from.name and from.path may themselves be templated with {.cluster,.self}
#   (release-level only, no .object), e.g. name: "{{ .cluster.name }}-transform".
apiVersion: v1
kind: ConfigMap
metadata:
  name: mutation-cel-transform
  namespace: default
data:
  transform.cel: |
    {
      "metadata": {
        "labels": {"convoy.kumodo.io/release": self.name},
        "annotations": {"convoy.kumodo.io/region": cluster.region}
      }
    }

Types#

typeRequired contentWhat it does
jsonPatchpatches: RFC 6902 operationsApplies the operations to each matching object. convoy executes the patch as a Go template per object.
strategicMergePatchinline or fromMerges each document into each matching object as a strategic merge patch. Built-in kinds only.
goTemplateinline or fromExecutes each document as a Go template per object, and merges the result as an RFC 7386 merge patch.
celTransforminline or fromEvaluates each document as a CEL expression per object. The result map is merged as an RFC 7386 merge patch.
syncWavewaveStrategySets the convoy.kumodo.io/sync-* annotations on each matching object.

Fields of a mutation#

FieldMeaning
targetSelects objects by group, version, kind, name and namespace. An empty field matches all values. Without target, the mutation matches all objects.
inlineA list of strings. Each string is one document: a template, a patch or a CEL expression.
fromReads one more document from another object. kind is GitRepository, ConfigMap or Secret. path is the file path in the repository, or the data key. ref selects the Git branch, tag or commit.
patchesThe operations of a jsonPatch mutation.
waveStrategyThe wave, strategy and timeout of a syncWave mutation.

Template and CEL context#

NameValue
clusterThe spec.metadata keys of the target Cluster, and cluster.name
selfThe name, namespace, labels and annotations of the Release
objectThe object, as the previous mutation left it

Go templates use missingkey=zero and have no Sprig functions. from.name and from.path are also Go templates, with cluster and self only.

Admission rules#

  • type is jsonPatch, strategicMergePatch, goTemplate, celTransform or syncWave.
  • jsonPatch has at least one patch. Each patch has an op (add, remove, replace, move, copy or test) and a path.
  • strategicMergePatch, goTemplate and celTransform have inline or from.
  • syncWave has waveStrategy. strategy, if set, is waitForApplied, waitForHealthy or waitForHealthyWithTimeout.
  • from.namespace is empty or the namespace of the Release.

Admission does not parse templates, compile CEL or check from.kind. These errors show only at render time, as Applied=False with reason DeployFailed or Unsupported.

Subresource and CLI#

A write to releases/mutations changes only mutations, and requests a reconcile. Kubernetes RBAC controls releases/mutations separately from the Release.

sh
kubectl convoy release mutations get podinfo
kubectl convoy release mutations set podinfo -f mutations.yaml
kubectl convoy release mutations add podinfo -f extra.yaml

Fields#

FieldTypeDescription
mutations[]ReleaseMutationlist type: atomic
mutations[].fromReleaseMutationFromSpecFrom is the source of the mutation.
mutations[].from.kind requiredstringKind is the kind of the source.
mutations[].from.name requiredstringName is the name of the source.
mutations[].from.namespacestringNamespace is the namespace of the source.
mutations[].from.path requiredstringPath is the path to the mutation within the source.
mutations[].from.refReleaseGitRepositoryRefSpecRef is the reference for GitRepository used as a mutation source.
mutations[].from.ref.branchstringBranch is the branch to track in the Git repository.
mutations[].from.ref.commitstringCommit is the commit to track in the Git repository.
mutations[].from.ref.semverstringSemver is the tag-based semantic version expression to track in the Git repository.
mutations[].from.ref.tagstringTag is the tag to track in the Git repository.
mutations[].inline[]stringlist type: atomicInline is the inline mutation.
mutations[].patches[]ReleaseMutationPatchSpeclist type: atomicPatches is the list of JSON patches to apply to the release.
mutations[].patches[].fromstringFrom is the path to the field within the release to copy or move from. Applicable only for move and copy operations.
mutations[].patches[].op requiredstringOp is the JSON patch operation.
  • add is the add JSON patch operation.
  • copy is the copy JSON patch operation.
  • move is the move JSON patch operation.
  • remove is the remove JSON patch operation.
  • replace is the replace JSON patch operation.
  • test is the test JSON patch operation.
mutations[].patches[].path requiredstringPath is the path to the field within the release to patch.
mutations[].patches[].valueJSONValue is the value to patch.
mutations[].target requiredReleaseMutationTargetTarget define mutation target.
mutations[].target.group requiredstringGroup defines the API group of the target.
mutations[].target.kind requiredstringKind defines the kind of the target.
mutations[].target.namestringName defines the name of the target.
mutations[].target.namespacestringNamespace defines the namespace of the target.
mutations[].target.version requiredstringVersion defines the API version of the target.
mutations[].type requiredstringType is the type of the mutation.
  • celTransform is the mutation type that uses CEL as mutation source.
  • goTemplate is the mutation type that uses Go template as mutation source.
  • jsonPatch is the mutation type that uses JSON patch as mutation source.
  • strategicMergePatch is the mutation type that uses Strategic merge patch as mutation source.
  • syncWave is a special mutation type which is used to set the sync-related annotations on the rendered resources. These annotations could still be set using other mutation types, but it's typos-prone approach which is hard to debug. Dedicated mutation type in opposite provides the validated, targeted and typed way to produce those annotations.
mutations[].waveStrategyReleaseWaveStrategySpecWaveStrategy is the sync-wave configuration applied as annotations to the defined target. Only applicable for "syncWave" mutation type.
mutations[].waveStrategy.strategy requiredstringStrategy is the wave strategy.
  • waitForApplied is the wave strategy that waits for all resources to be applied.
  • waitForHealthy is the wave strategy that waits for all resources to be healthy.
  • waitForHealthyWithTimeout is the wave strategy that waits for all resources to be healthy with a timeout.
mutations[].waveStrategy.timeoutDurationTimeout is the timeout for the wave strategy. If not set, controller will wait indefinitely.
mutations[].waveStrategy.wave requiredintegerWave is the wave number.

In the code

convoy v0.9.0