Skip to content

Instantly share code, notes, and snippets.

@marcosborges
Last active February 3, 2021 12:57
Show Gist options
  • Save marcosborges/85e7db30cc62ed5c7696815e29c27a85 to your computer and use it in GitHub Desktop.
Save marcosborges/85e7db30cc62ed5c7696815e29c27a85 to your computer and use it in GitHub Desktop.
Kubectl e Jq
#!/bin/bash
# Lista de deployments que tem o nome inicado com:
kubectl get deployments -n [NAMESPACE] -o json | jq '.items[].metadata.name|startswith("[DEPLOYMENT_NAME]")'
# Lista de deployments que contem em seu nome o termo:
kubectl get deployments -n [NAMESPACE] -o json | jq '.items[].metadata.name|contains("[DEPLOYMENT_NAME]")'
# Lista de deployments que satisfaça o REGEX:
kubectl get deployments -n [NAMESPACE] -o json | jq '.items[].metadata.name|test("[DEPLOYMENT_NAME]-([0-9a-zA-Z]{7})")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment