Ameausoone / discover-kustomize

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discover Kustomize

Run the prez

Install demoit, then run demoit.

What is it ?

kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is.

This tool is sponsored by sig-cli (KEP), and inspired by DAM.

  • Generate Kubernetes resources file
  • Pure-yaml
  • Template-free
  • Kustomize "understands" kubernetes
  • "Overlay"

Links

Usage

Cli

tldr

tldr kustomize

Create

kustomize create --resources deployment.yaml,service.yaml
# OR 
kustomize create --autodetect
# Then
kustomize build . 
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - configMap.yaml
  - deployment.yaml
  - service.yaml

Apply

# Generate with kubectl 
kubectl apply -k . --dry-run -o yaml
# but
kustomize build . | kubectl apply -f - 

kubectl integration (BUT)

Since [v1.14][kubectl announcement] the kustomize build system has been included in kubectl.

kubectl version kustomize version
v1.16.0 v2.0.3
v1.15.x v2.0.3
v1.14.x v2.0.3

Features

Prefix,Suffix

kustomize edit set nameprefix acme-
namePrefix: acme-
diff -u <(kustomize build ../iso/base) <(kustomize build .)

Annotation,Labels

kustomize edit add annotation "application:front"
kustomize edit add label "env:dev"
commonAnnotations:
  application: front
commonLabels:
  env: dev
diff -u <(kustomize build ../iso/base) <(kustomize build .)

ConfigmapGenerator

kustomize edit add configmap my-configmap --from-literal=db_host=localhost
configMapGenerator:
- literals:
  - db_host=localhost
  name: my-configmap
kustomize build . | grep my-configmap 
# Then add a literal and run
kustomize build . | grep my-configmap 

Image

kustomize edit set image nginx:1.16
images:
- name: nginx
  newTag: 1.16
kustomize build . | grep nginx 

Overlays and merge

cd iso
diff -u <(kustomize build base) <(kustomize build overlays/staging)
diff -u <(kustomize build overlays/staging) <(kustomize build overlays/production)

Remote targets

cd remoteTargets
kustomize build .

Integration

Skaffold

cd skaffold
skaffold dev

Github Actions

name: staging

on:
  push:
    paths:
      - 'staging/*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Get kubeconfig file from GKE
        uses: machine-learning-apps/gke-kubeconfig@master
        with:
          application_credentials: ${{ secrets.APPLICATION_CREDENTIALS }}
          project_id: ${{ secrets.PROJECT_ID }}
          location_zone: ${{ secrets.LOCATION_ZONE }}
          cluster_name: ${{ secrets.CLUSTER_NAME }}
      - name: Kubernetes toolset
        uses: stefanprodan/kube-tools@v1.0.0
        env:
          KUBECONFIG: '/github/workspace/.kube/config'
        with:
          kubectl: 1.16.2
          kustomize: 3.2.3
          command: |
            kustomize build staging | kubectl apply --dry-run -o yaml -f -
            kustomize build staging | kubectl apply -f -

IntelliJ

Plugin Jetbrains Kubernetes

About


Languages

Language:JavaScript 61.5%Language:CSS 25.7%Language:HTML 12.5%Language:Go 0.1%Language:Dockerfile 0.1%