Skip to content

Instantly share code, notes, and snippets.

@mrsimonemms
Created July 2, 2024 14:10
Show Gist options
  • Save mrsimonemms/52fd78af32626f162851d0e24f4065e8 to your computer and use it in GitHub Desktop.
Save mrsimonemms/52fd78af32626f162851d0e24f4065e8 to your computer and use it in GitHub Desktop.
Extract Kubernetes TLS secrets to YAML
#!/bin/bash
# Extract secrets from all namespaces
kubectl get secrets -A --field-selector=type=kubernetes.io/tls -o json | jq -r '.items[]' | yq -p=json
# Extract secrets from a single namespace
kubectl get secrets -n default --field-selector=type=kubernetes.io/tls -o json | jq -r '.items[]' | yq -p=json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment