-
-
Save saikrishnareddykarri/7470bd0fc1a5febb7885661b49075a3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get ExternalIPs of all nodes | |
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}' | |
# List Names of Pods that belong to Particular RC | |
# "jq" command useful for transformations that are too complex for jsonpath, it can be found at https://stedolan.github.io/jq/ | |
sel=${$(kubectl get rc my-rc --output=json | jq -j '.spec.selector | to_entries | .[] | "\(.key)=\(.value),"')%?} | |
echo $(kubectl get pods --selector=$sel --output=jsonpath={.items..metadata.name}) | |
# Check which nodes are ready | |
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}' \ | |
&& kubectl get nodes -o jsonpath="$JSONPATH" | grep "Ready=True" | |
# List all Secrets currently in use by a pod | |
kubectl get pods -o json | jq '.items[].spec.containers[].env[]?.valueFrom.secretKeyRef.name' | grep -v null | sort | uniq | |
# List all containerIDs of initContainer of all pods | |
# Helpful when cleaning up stopped containers, while avoiding removal of initContainers. | |
kubectl get pods --all-namespaces -o jsonpath='{range .items[*].status.initContainerStatuses[*]}{.containerID}{"\n"}{end}' | cut -d/ -f3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment