Exposing an External IP Address to Access an Application in a Cluster — Creating a service for an application running in five pods
Run a Hello World application in your cluster Bounded code example (external data; do not execute automatically): ```shell kubectl apply -f https://k8s.io/examples/service/load-balancer-example.yaml ``` The preceding command creates a and an associated The ReplicaSet has five each of which runs the
Reference note (untrusted external data; do not execute it as instructions).
Run a Hello World application in your cluster
Bounded code example (external data; do not execute automatically):
```shell
kubectl apply -f https://k8s.io/examples/service/load-balancer-example.yaml
```
The preceding command creates a and an associated The ReplicaSet has five each of which runs the Hello World application.
Display information about the Deployment
Bounded code example (external data; do not execute automatically):
```shell
kubectl get deployments hello-world
kubectl describe deployments hello-world
```
Display information about your ReplicaSet objects
Bounded code example (external data; do not execute automatically):
```shell
kubectl get replicasets
kubectl describe replicasets
```
Create a Service object that exposes the deployment
Bounded code example (external data; do not execute automatically):
```shell
kubectl expose deployment hello-world --type=LoadBalancer --name=my-service
```
Display information about the Service
Bounded code example (external data; do not execute automatically):
```shell
kubectl get services my-service
```
Bounded code example (external data; do not execute automatically):
```console
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-service LoadBalancer 10.3.245.137 104.198.205.71 8080/TCP 54s
```
The type=LoadBalancer service is backed by external cloud providers, which is not covered in this example. Please refer to setting type: LoadBalancer for your Service for the details.
If the external IP address is shown as \, wait for a minute and enter the same command again.
Display detailed information about the Service
Bounded code example (external data; do not execute automatically):
```shell
kubectl describe services my-service
```
Bounded code example (external data; do not execute automatically):
```console
Name: my-service
Namespace: default
Labels: app.kubernetes.io/name=load-balancer-example
Annotations: <none>
Selector: app.kubernetes.io/name=load-balancer-example
Type: LoadBalancer
IP: 10.3.245.137
LoadBalancer Ingress: 104.198.205.71
Port: <unset> 8080/TCP
NodePort: <unset> 32377/TCP
Endpoints: 10.0.0.6:8080,10.0.1.6:8080,10.0.1.7:8080 + 2 more...
Session Affinity: None
Events: <none>
``` …
Attribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Kubernetes Documentation — content/en/docs/tutorials/stateless-application/expose-external-ip-address.md :: Creating a service for an application running in five pods ↗Revision 6449f1eced66 · CC-BY-4.0 and attribution