Skip to main content

Kustomize

Playbook

Mission Control integrates with Kustomize to simplify configuration management through GitOps-native playbooks.

Quick Start

Prerequisites
  • Mission Control SaaS or Self-Hosted installed

Kustomize integration works with Flux GitOps. Ensure Flux is configured to manage your Kustomizations before using these playbooks.


Playbook

Use cases:

  • Create Deployments, HelmReleases, and Namespaces through guided playbooks
  • Modify existing resources via Kustomize patches without editing YAML manually
  • Scale replicas or update resource limits across environments
  • Commit changes back to Git repositories through Flux GitOps workflows
  • Generate pull requests for review before applying changes

Automate Kustomize operations through GitOps-native playbooks that create pull requests for all changes:

Resource Creation

Create new resources within Flux-managed Kustomizations:

PlaybookDescription
Create DeploymentAdd a new Deployment with configurable image, CPU, and memory settings
Create HelmReleaseAdd a HelmRelease to a Kustomization for Helm chart management
Create KustomizationCreate a new Flux Kustomization pointing to a path in your repository
Create NamespaceAdd a namespace managed by an existing Kustomization

Resource Modification

Modify existing resources through Kustomize patches:

PlaybookDescription
Edit KustomizationModify Kustomization settings like interval, path, or source reference
Scale ResourcesAdjust replica counts for Deployments via Kustomize patches
Update ResourcesModify CPU and memory requests/limits

Example: Create Deployment

This playbook creates a Deployment manifest and updates the Kustomization to include it, then opens a pull request for review:

kustomize-create-deployment.yaml
---
# Source: mission-control-playbooks-flux/templates/create-helmrelease.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/playbook.schema.json
---
# Source: mission-control-playbooks-flux/templates/debug.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/playbook.schema.json
---
# Source: mission-control-playbooks-flux/templates/create-deployment.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/playbook.schema.json
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: kustomize-create-deployment
spec:
title: Create Deployment
icon: k8s-deployment
category: Flux
description: Creates a Deployment in a GitOps managed namespace by submitting a Git PR
parameters:
- name: name
label: Name
required: true
- name: image
label: Container Image
required: true
- name: cpu_request
label: CPU
properties:
colSpan: 3
type: millicores
default: '100m'
required: true
- name: cpu_limit
properties:
colSpan: 3
label: Limit
type: millicores
- name: memory_request
label: Memory
properties:
colSpan: 3
type: bytes
default: '100Mi'
required: true
- name: memory_limit
label: Memory Limit
properties:
colSpan: 3
type: bytes
configs:
# deployments can only be created in namespaces managed by flux
- labelSelector: 'kustomize.toolkit.fluxcd.io/name'
types:
- Kubernetes::Namespace
actions:
- name: "Create manifest"
gitops:
commit:
author: $(.user.name)
email: $(.user.email | default "" )
message: "chore: create deployment $(.params.name)"
files:
- path: "$(.git.dir)/deploy-$(.params.name).yaml"
content: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: $(.params.name)
namespace: $(.config.name)
annotations:
"mission-control/playbook": $(.playbook.name)
"mission-control/run": $(.run.id)
"mission-control/createdBy": $(.user.name)
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: $(.params.name)
template:
metadata:
labels:
app.kubernetes.io/name: $(.params.name)
spec:
containers:
- name: $(.params.name)
image: $(.params.image)
resources:
limits:
memory: $(.params.memory_limit | default "")
cpu: $(.params.cpu_limit | default "")
requests:
cpu: $(.params.cpu_request)
memory: $(.params.memory_request)
patches:
- path: "$(.git.kustomize.file)"
yq: '.resources += "deploy-$(.params.name).yaml"'
pr:
title: Create namespace $(.params.name)
repo:
connection: connection://mission-control/github
type: github
url: $(.git.git.url)
branch: "deploy/create-deploy-$(.params.name)"
base: $(.git.git.branch)

The playbook:

  1. Accepts parameters for name, image, and resource limits
  2. Generates a Deployment manifest in the repository
  3. Patches the kustomization.yaml to include the new resource
  4. Creates a pull request with the changes

Next Steps