1. Exec vào pod.
kubectl exec --stdin --tty prometheus-prometheus-grafana-stack-k-prometheus-0 -n monitoring sh
2. Check listen port
kubectl exec <pod name here> -- netstat -tulpn | grep "search string"
3. Fix lỗi command permission denied trong pod.
Nếu bạ thực hiện 1 lệnh nhưng gặp lỗi trả về như dưới.
$ kubectl exec prometheus-prometheus-grafana-stack-k-prometheus-0 -n monitoring -- ping prometheus-prometheus-grafana-stack-k-prometheus-0
PING prometheus-prometheus-grafana-stack-k-prometheus-0 (10.244.194.100): 56 data bytes
ping: permission denied (are you root?)
command terminated with exit code 1
Cách mình sử dụng là check listen port thay cho icmp
$ kubectl exec prometheus-prometheus-grafana-stack-k-prometheus-0 -n monitoring -- netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 :::9090 :::* LISTEN 1/prometheus
tcp 0 0 :::8080 :::* LISTEN -
Hoặc sử dụng telnet.
$ kubectl exec prometheus-prometheus-grafana-stack-k-prometheus-0 -n monitoring -- telnet 8.8.8.8 443
Connected to 8.8.8.8