Commands.app

kubectl expose

Networking

Expose resource as service

Options & Flags
Available options for this command
--port

Service port

--target-port

Container port

--type

Service type (ClusterIP, NodePort, LoadBalancer)

Examples
Common usage examples

Create ClusterIP service

kubectl expose deployment myapp --port=80

Create LoadBalancer service

kubectl expose deployment myapp --port=80 --type=LoadBalancer

Expose with port mapping

kubectl expose pod mypod --port=80 --target-port=8080
Notes
  • Creates a service for the resource
Related Commands
You might also find these useful