Transform Manifests
pipeline.yaml
can include multiple
filters to transform the manifests:
-
skip
can remove unwanted fields, values or entire resources -
starlark
enables advanced transformations via Python-like Starlark-go scripts
The following example uses kustomize
source to convert previously generated manifests from Helm Chart to Kustomize
components, and also removing the sidecar
container with its' ConfigMap - e.g.
the sidecar
was injected by a controller and should not be included in the
manifests.
source:
kustomize:
path: '../run-gen-helm/overlays/${CLUSTER}'
clusters:
- alias: dev
matchNames: { include: [ 'dev-*' ] }
- alias: prod
matchNames: { include: [ 'prod-*' ] }
filters:
- skip:
resources:
- kind: ConfigMap
- skip:
fields:
- spec.template.spec.containers[name=sidecar]
output:
kustomizeComponents: {}
As a result only the image version is different between the cluster manifests:
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-app
namespace: ktl-examples
spec:
template:
spec:
containers:
- name: demo-app
image: demo-app:v2
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-app
namespace: ktl-examples
spec:
template:
spec:
containers:
- name: demo-app
image: demo-app:v1
And only dev
and prod
components are generated:
components
├── all-clusters
│ ├── ktl-examples
│ │ ├── demo-app-deployment.yaml
│ │ └── demo-app-service.yaml
│ └── kustomization.yaml
├── dev
│ ├── ktl-examples
│ │ └── demo-app-deployment.yaml
│ └── kustomization.yaml
└── prod
├── ktl-examples
│ └── demo-app-deployment.yaml
└── kustomization.yaml