Skip to content

Kubernetes & OpenShift: Network & DNS

Kubernetes & OpenShift commands for network & dns (tags: #network #dns #http).

Index
2 items

Kubernetes: List services and their endpoints

Safe

Services with type, cluster IP, external IP, ports and selector, then the pod IPs actually behind each one.

kubectl get svc -n <namespace> -o wide && kubectl get endpointslices -n <namespace>
What each part does
  1. kubectl get svclist services (svc is the short name)
  2. -n <namespace>in this namespace; -A for all
  3. -o wideadd the SELECTOR column: the pod labels the service routes to
  4. &&then, if that worked
  5. kubectl get endpointslicesthe ready pod IPs:ports behind each service (kubectl get ep on older clusters)
Example
$ kubectl get svc -n shop -o wide
NAME   TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE   SELECTOR
api    ClusterIP   10.96.120.15   <none>        80/TCP    3d    app=api

My note No endpoints? The selector matches no ready pods: compare SELECTOR with kubectl get po --show-labels, and check readiness probes.

Also known as: kubectl get svc · kubectl get services · list services · service has no endpoints · kubectl get ep

Kubernetes: Port-forward to a service

Safe

Reach a ClusterIP service from your laptop on localhost:<local-port>.

kubectl port-forward svc/<service> <local-port>:<remote-port> -n <namespace>
What each part does
  1. kubectl port-forwardtunnel a local port to a pod through the API server
  2. svc/<service>pick a pod behind this service
  3. <local-port>:<remote-port>listen locally on the first, forward to the second
  4. -n <namespace>namespace of the service
Example
$ kubectl port-forward svc/prometheus-operated 9090:9090 -n monitoring
# then open http://localhost:9090

Also known as: port forward · kubectl port-forward · prometheus ui · grafana ui

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…