LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

kubectl-expose

creates a service for a resource

TLDR

Expose deployment
$ kubectl expose deployment [name] --port=[80]
copy
Expose with type
$ kubectl expose deployment [name] --port=[80] --type=[LoadBalancer]
copy
Expose pod
$ kubectl expose pod [pod-name] --port=[8080] --target-port=[80]
copy
Expose with name
$ kubectl expose deployment [name] --port=[80] --name=[service-name]
copy
Expose NodePort
$ kubectl expose deployment [name] --port=[80] --type=[NodePort]
copy

SYNOPSIS

kubectl expose [options] resource name

DESCRIPTION

kubectl expose creates a Kubernetes Service that provides stable network access to a set of pods managed by a deployment, replica set, pod, or other resource. It automatically generates the service configuration by inspecting the target resource's labels and port definitions, creating a selector-based service without requiring a manual manifest.The command supports four service types: ClusterIP (default) for internal cluster access, NodePort for exposing the service on each node's IP at a static port, LoadBalancer for provisioning an external load balancer through the cloud provider, and ExternalName for mapping to a DNS name. The `--port` flag sets the service's listening port while `--target-port` specifies the container port to forward traffic to.This approach is convenient for quick service creation during development or prototyping. For production environments, defining services declaratively in manifest files alongside the workload definitions provides better reproducibility and version control.

PARAMETERS

RESOURCE

Resource type to expose.
NAME
Resource name.
--port PORT
Service port.
--target-port PORT
Container port.
--type TYPE
Service type (ClusterIP, NodePort, LoadBalancer).
--name NAME
Service name.
--help
Display help information.

INSTALL

sudo apt install kubectl
copy
sudo pacman -S kubectl
copy
sudo apk add kubectl
copy
brew install kubectl
copy
nix profile install nixpkgs#kubectl
copy

CAVEATS

Subcommand of kubectl. Service type affects accessibility. Consider using manifests.

HISTORY

kubectl expose provides quick service creation for Kubernetes workload networking.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid