Kubernetes Service YAML Builder

Generate a K8s Service manifest for ClusterIP, NodePort, or LoadBalancer

Builds a Kubernetes Service YAML with selector, port definitions, and service type configuration for exposing deployments internally or externally as ClusterIP, NodePort, or LoadBalancer.

What is the difference between port and targetPort?

The port is the port the Service listens on inside the cluster. The targetPort is the port on the pod that traffic is forwarded to. They are often the same but can differ.

Kubernetes Service YAML Builder

A Kubernetes Service provides a stable network endpoint for a set of pods. Because pods are ephemeral and their IPs change, a Service gives them a single virtual IP and DNS name. This builder generates a valid Service manifest for the three common types so you can expose a deployment without hand-writing YAML.

How it works

A Service uses a selector to find pods by their labels, then forwards traffic from its port to each pod’s targetPort. The type field controls reachability:

  • ClusterIP — internal-only virtual IP (default).
  • NodePort — opens a static port (30000–32767) on every node, layered on top of a ClusterIP.
  • LoadBalancer — provisions an external cloud load balancer, layered on top of NodePort.

The builder assembles apiVersion: v1, kind: Service, metadata, and the spec block from your inputs. For TCP and UDP you set the protocol. For NodePort you can pin a nodePort value within the allowed range.

Tips and example

Keep selectors specific (for example app: web plus tier: frontend) so the Service only targets the intended pods. The selector must exactly match the labels in your Deployment’s spec.template.metadata.labels. After generating, apply with:

kubectl apply -f service.yaml
kubectl get svc my-service

For a LoadBalancer, watch EXTERNAL-IP with kubectl get svc -w until the cloud provider assigns an address.