Skip to main content

Management Tips

Free Up Disk Space

Port Forwarding

  • Usage: kubectl port forward TYPE/NAME [LOCAL_PORT:]REMOTE_PORT 
  • LOCAL_PORT is the port on your local machine running kubectl
  • REMOTE_PORT is the port on the target pod or service in the Kubernetes cluster
# For a service
kubectl port forward svc/my-service 8080:80

# For a deployment
kubectl port forward deploy/my-deployment 8080:80

K8s Cluster Monitoring

Kube-Prometheus-Stack

A set of Kubernetes manifests, Grafana dashboards, and Prometheus rules for monitoring Kubernetes clusters

kubectl create ns monitoring
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo list
helm repo update
helm install prometheus-stack prometheus-community/kube-prometheus-stack -n monitoring

Get Grafana 'admin' user password by running:

kubectl --namespace monitoring get secrets prometheus-stack-grafana -o jsonpath="{.data.admin-password}" | base64 -d ; echo

Access Grafana local instance:

export POD_NAME=$(kubectl --namespace monitoring get pod -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=prometheus-stack" -oname)
kubectl --namespace monitoring port-forward $POD_NAME 3000

Get your grafana admin user password by running:

kubectl get secret --namespace monitoring -l app.kubernetes.io/component=admin-secret -o jsonpath="{.items[0].data.admin-password}" | base64 --decode ; echo