Logo

Personal Ops Runbook

Personal runbook covering infrastructure operations for Cloud, Kubernetes, OpenStack, and Ceph environments. Includes deployment and teardown procedures, node management, cluster monitoring setup, and incident response workflows compiled from day-to-day operational work. Intended strictly for personal reference — configurations and scripts are environment-specific and not guaranteed to work as-is elsewhere.

[Kubernetes] Lệnh Kubernetes hay quên


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