k8s查找已使用port

k8s查找已使用port

Scroll Down
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
for i in $(kubectl get ns | awk '{print $1}'|grep -v NAME)
do
kubectl get svc -n $i|grep -o -E ':[0-9]*'|awk -F ':' '{print $2}'
done