Skip to content

Instantly share code, notes, and snippets.

View karlkfi's full-sized avatar

Karl Isenberg karlkfi

View GitHub Profile
@karlkfi
karlkfi / assign-kube-system-node-selector.yaml
Created August 15, 2024 22:55
Use Gatekeeper mutating webhooks to auto-assign Pods from a namespace to a specific node pool
apiVersion: mutations.gatekeeper.sh/v1
kind: Assign
metadata:
name: kube-system-node-selector
spec:
applyTo:
- groups: [""]
kinds: ["Pod"]
versions: ["v1"]
match:
@karlkfi
karlkfi / count-k8s-objects.sh
Last active January 16, 2025 01:31
count-k8s-objects.sh - Count the number of Kubernetes objects in a directory and error if there are too many
#!/bin/bash
# This script recursively counts the number of Kubernetes objects in YAML and JSON files within a directory.
# It uses `yq` to parse YAML and JSON, prints the object count for each file,
# and also prints the total count for each directory. It errors if the total object count exceeds 2000.
# It skips directories that start with "."
set -euo pipefail
# --- Configuration ---