kustomize-basics

$npx mdskill add TheBushidoCollective/han/kustomize-basics

Customizes Kubernetes configurations using Kustomize overlays and patches without templates.

  • Helps with customizing Kubernetes deployments for different environments like development and production.
  • Integrates with Kustomize tooling and relies on YAML files for configuration management.
  • Decides based on structured directories and kustomization.yaml files to apply patches and overlays.
  • Presents results through generated YAML configurations and command-line build outputs.

SKILL.md

.github/skills/kustomize-basicsView on GitHub ↗
---
name: kustomize-basics
user-invocable: false
description: Use when customizing Kubernetes configurations without templates using Kustomize overlays and patches.
allowed-tools: []
---

# Kustomize Basics

Kubernetes configuration customization without templates.

## Basic Structure

```
app/
├── base/
│   ├── kustomization.yaml
│   ├── deployment.yaml
│   └── service.yaml
└── overlays/
    ├── development/
    │   └── kustomization.yaml
    └── production/
        └── kustomization.yaml
```

## Base Kustomization

```yaml
# base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - deployment.yaml
  - service.yaml

commonLabels:
  app: myapp
  
namePrefix: myapp-

images:
  - name: myapp
    newTag: v1.0.0
```

## Overlay Kustomization

```yaml
# overlays/production/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
  - ../../base

replicas:
  - name: myapp-deployment
    count: 5

images:
  - name: myapp
    newTag: v2.0.0

patches:
  - patch: |-
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: myapp-deployment
      spec:
        template:
          spec:
            containers:
            - name: myapp
              resources:
                limits:
                  memory: "1Gi"
                  cpu: "1000m"
```

## Common Commands

```bash
# Build kustomization
kustomize build base/

# Build overlay
kustomize build overlays/production/

# Apply with kubectl
kubectl apply -k overlays/production/

# Diff before apply
kubectl diff -k overlays/production/
```

## Transformers

### Common Labels

```yaml
commonLabels:
  app: myapp
  environment: production
```

### Name Prefix/Suffix

```yaml
namePrefix: prod-
nameSuffix: -v2
```

### Namespace

```yaml
namespace: production
```

### Config Map Generator

```yaml
configMapGenerator:
  - name: app-config
    files:
      - config.properties
    literals:
      - LOG_LEVEL=info
```

### Secret Generator

```yaml
secretGenerator:
  - name: app-secrets
    literals:
      - password=secret123
```

## Best Practices

### Use Bases for Common Configuration

Keep common configuration in base and environment-specific in overlays.

### Strategic Merge Patches

```yaml
patches:
  - path: patch-deployment.yaml
```

### JSON Patches

```yaml
patchesJson6902:
  - target:
      group: apps
      version: v1
      kind: Deployment
      name: myapp
    patch: |-
      - op: replace
        path: /spec/replicas
        value: 3
```

More from TheBushidoCollective/han

SkillDescription
absinthe-resolversUse when implementing GraphQL resolvers with Absinthe. Covers resolver patterns, dataloader integration, batching, and error handling.
absinthe-schemaUse when designing GraphQL schemas with Absinthe. Covers type definitions, interfaces, unions, enums, and schema organization patterns.
absinthe-subscriptionsUse when implementing real-time GraphQL subscriptions with Absinthe. Covers Phoenix channels, PubSub, and subscription patterns.
act-docker-setupUse when configuring Docker environments for act, selecting runner images, managing container resources, or troubleshooting Docker-related issues with local GitHub Actions testing.
act-local-testingUse when testing GitHub Actions workflows locally with act. Covers act CLI usage, Docker configuration, debugging workflows, and troubleshooting common issues when running workflows on your local machine.
act-workflow-syntaxUse when creating or modifying GitHub Actions workflow files. Provides guidance on workflow syntax, triggers, jobs, steps, and expressions for creating valid GitHub Actions workflows that can be tested locally with act.
ameba-configurationUse when configuring Ameba rules and settings for Crystal projects including .ameba.yml setup, rule management, severity levels, and code quality enforcement.
ameba-custom-rulesUse when creating custom Ameba rules for Crystal code analysis including rule development, AST traversal, issue reporting, and rule testing.
ameba-integrationUse when integrating Ameba into development workflows including CI/CD pipelines, pre-commit hooks, GitHub Actions, and automated code review processes.
analyze-performanceAnalyze performance metrics and identify slow transactions in Sentry