Kubernetes YAML Networking/ClusterIP Service YAML

Expose Pods internally in the cluster.

Section: Services

ClusterIP Service YAML

yaml
yaml
apiVersion: v1
kind: Service
metadata:
  name: api
spec:
  selector:
    app: api
  ports:
    - name: http
      port: 80
      targetPort: http
  type: ClusterIP

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
NodePort Service YAML
Expose the service on each node's IP.
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.