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.
|
||||
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
|
||||
$ kubectl run my-nginx --image=nginx --replicas=2 --port=80 --expose --service-overrides='{ "spec": { "type": "LoadBalancer" } }'
|
||||
service "my-nginx" created
|
||||
$ kubectl run my-nginx --image=nginx --replicas=2 --port=80
|
||||
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:
|
||||
|
||||
```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:
|
||||
|
||||
```shell
|
||||
$ kubectl get service/my-nginx
|
||||
$ kubectl get service my-nginx
|
||||
NAME CLUSTER_IP EXTERNAL_IP PORT(S) AGE
|
||||
my-nginx 10.179.240.1 25.1.2.3 80/TCP 8s
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user