-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcap_kub.sh
More file actions
18 lines (14 loc) · 840 Bytes
/
cap_kub.sh
File metadata and controls
18 lines (14 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
# Loop over all pods in all namespaces
kubectl get pods --all-namespaces -o json | jq -r '.items[] | .metadata.namespace + " " + .metadata.name + " " + (.spec.containers[].name)' | while read line; do
# Extract the namespace, pod name, and container name
namespace=$(echo $line | cut -d' ' -f1)
pod=$(echo $line | cut -d' ' -f2)
container=$(echo $line | cut -d' ' -f3)
# Print information about the pod/container being processed
echo "Running capsh --print for namespace $namespace, pod $pod, container $container..."
# Execute capsh --print inside the container with a shell (new kubectl exec syntax)
kubectl exec $pod -n $namespace -c $container -- capsh --print
# Add a separator for readability
echo "------------------------------------------------------------"
done