concept

Service types and ports

A Service supplies a stable access abstraction. port is the client-facing port; targetPort identifies the backend listener. Exposure depends on type and implementation.

Formal Syntax & Structure

kubernetes syntaxkubernetes
Service types and ports

Working Example

Example Snippetkubernetes
apiVersion: v1kind: Servicemetadata:  name: api  namespace: book-labspec:  type: ClusterIP  selector:    app: api  ports:    - name: http      protocol: TCP      port: 80      targetPort: 8080
Kubernetes Reference