karmafun¶
karmafun is a
kustomize plugin
and a kustomize build wrapper providing a set of KRM Functions that perform
in-place transformations on Kubernetes resource files.
Why karmafun?¶
kustomize fn run enables in-place transformation of KRM resources — perfect
for making structural changes to a GitOps repository without adding extra
nesting layers. Unfortunately, kustomize's built-in transformers and generators
are not available to kustomize fn run, which requires an external container
or exec binary.
karmafun fills that gap by providing:
- All kustomize builtin transformers and generators as KRM functions.
- Additional generators:
GitConfigMapGenerator,KustomizationGenerator,SopsGenerator,KCLGenerator. - Additional transformers:
RemoveTransformer,KCLTransformer, and an extendedReplacementTransformerwith structured-content support. - A
karmafun buildcommand extendingkustomize buildwith Go template rendering and SOPS-encrypted secrets.
Quick start¶
1. Install¶
See Installation for other methods.
2. Write a function config¶
# functions/fn-change-repo.yaml
apiVersion: builtin
kind: PatchTransformer
metadata:
name: fn-change-repo
annotations:
config.karmafun.dev/cleanup: "true"
config.kubernetes.io/function: |
exec:
path: karmafun
patch: |-
- op: replace
path: /spec/source/repoURL
value: https://github.com/myname/autocloud.git
- op: replace
path: /spec/source/targetRevision
value: feature/experiment
target:
group: argoproj.io
version: v1alpha1
kind: Application
annotationSelector: "autocloud/local-application=true"
3. Run¶
The config.karmafun.dev/cleanup: "true" annotation removes kustomize's
internal tracking annotations from the output (see
Annotations).