Kubernetes YAML Networking/NodePort Service YAML

Expose the service on each node's IP.

Section: Services

NodePort Service YAML

yaml
yaml
apiVersion: v1
kind: Service
metadata:
  name: api-nodeport
spec:
  selector:
    app: api
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30080
  type: NodePort

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Services
ClusterIP Service YAML
Expose Pods internally in the cluster.
OpenIn sheetyamlsame section
LoadBalancer Service YAML
Request external load balancing from the platform.
OpenIn sheetyamlsame section
Headless Service YAML
Expose individual Pod DNS records for stateful apps.
OpenIn sheetyamlsame section
Basic Ingress YAML
Route traffic by host and path.
Default deny ingress policy
Block incoming traffic until explicitly allowed.
Enable TLS on Ingress
Terminate HTTPS with a Secret-backed certificate.