use the expose command to expose the nginx service
This commit is contained in:
@@ -11,14 +11,20 @@ This guide will help you get oriented to Kubernetes and running your first conta
|
|||||||
Once your application is packaged into a container and pushed to an image registry, you're ready to deploy it to Kubernetes.
|
Once your application is packaged into a container and pushed to an image registry, you're ready to deploy it to Kubernetes.
|
||||||
Through integration with some cloud providers (for example Google Compute Engine and AWS EC2), Kubernetes also enables you to request it to provision a public IP address for your application.
|
Through integration with some cloud providers (for example Google Compute Engine and AWS EC2), Kubernetes also enables you to request it to provision a public IP address for your application.
|
||||||
|
|
||||||
For example, [nginx](http://wiki.nginx.org/Main) is a popular HTTP server, with a [pre-built container on Docker hub](https://registry.hub.docker.com/_/nginx/). The [`kubectl run`](/docs/user-guide/kubectl/kubectl_run) command below will create two nginx replicas, listening on port 80, and a public IP address for your application.
|
For example, [nginx](http://wiki.nginx.org/Main) is a popular HTTP server, with a [pre-built container on Docker hub](https://registry.hub.docker.com/_/nginx/). The [`kubectl run`](/docs/user-guide/kubectl/kubectl_run) commands below will create two nginx replicas, listening on port 80, and a public IP address for your application.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ kubectl run my-nginx --image=nginx --replicas=2 --port=80 --expose --service-overrides='{ "spec": { "type": "LoadBalancer" } }'
|
$ kubectl run my-nginx --image=nginx --replicas=2 --port=80
|
||||||
service "my-nginx" created
|
|
||||||
deployment "my-nginx" created
|
deployment "my-nginx" created
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To expose your service to the public internet, run:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ kubectl expose rc my-nginx --target-port=80 --type=LoadBalancer
|
||||||
|
service "my-nginx" exposed
|
||||||
|
```
|
||||||
|
|
||||||
You can see that they are running by:
|
You can see that they are running by:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -33,7 +39,7 @@ Kubernetes will ensure that your application keeps running, by automatically res
|
|||||||
To find the public IP address assigned to your application, execute:
|
To find the public IP address assigned to your application, execute:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ kubectl get service/my-nginx
|
$ kubectl get service my-nginx
|
||||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) AGE
|
NAME CLUSTER_IP EXTERNAL_IP PORT(S) AGE
|
||||||
my-nginx 10.179.240.1 25.1.2.3 80/TCP 8s
|
my-nginx 10.179.240.1 25.1.2.3 80/TCP 8s
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user