Commit a01d3392 authored by Janet Kuo's avatar Janet Kuo

Update tutorial about kubectl expose

parent 8524d392
...@@ -63,17 +63,22 @@ now run `docker ps` you should see nginx running. You may need to wait a few mi ...@@ -63,17 +63,22 @@ now run `docker ps` you should see nginx running. You may need to wait a few mi
kubectl expose rc nginx --port=80 kubectl expose rc nginx --port=80
``` ```
This should print: Run the following command to obtain the IP of this service we just created. There are two IPs, the first one is internal (CLUSTER_IP), and the second one is the external load-balanced IP.
```console ```sh
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE kubectl get svc nginx
nginx 10.179.240.1 <none> 80/TCP run=nginx 8d ```
Alternatively, you can obtain only the first IP (CLUSTER_IP) by running:
```sh
kubectl get svc nginx --template={{.spec.clusterIP}}
``` ```
Hit the webserver: Hit the webserver with the first IP (CLUSTER_IP):
```sh ```sh
curl <insert-ip-from-above-here> curl <insert-cluster-ip-here>
``` ```
Note that you will need run this curl command on your boot2docker VM if you are running on OS X. Note that you will need run this curl command on your boot2docker VM if you are running on OS X.
......
...@@ -178,23 +178,22 @@ Now run `docker ps` you should see nginx running. You may need to wait a few mi ...@@ -178,23 +178,22 @@ Now run `docker ps` you should see nginx running. You may need to wait a few mi
kubectl expose rc nginx --port=80 kubectl expose rc nginx --port=80
``` ```
This should print: Run the following command to obtain the IP of this service we just created. There are two IPs, the first one is internal (CLUSTER_IP), and the second one is the external load-balanced IP.
```console ```sh
NAME LABELS SELECTOR IP(S) PORT(S) kubectl get svc nginx
nginx run=nginx run=nginx 80/TCP
``` ```
If `IP(S)` is blank run the following command to obtain it. Know issue [#10836](https://github.com/kubernetes/kubernetes/issues/10836) Alternatively, you can obtain only the first IP (CLUSTER_IP) by running:
```sh ```sh
kubectl get svc nginx kubectl get svc nginx --template={{.spec.clusterIP}}
``` ```
Hit the webserver: Hit the webserver with the first IP (CLUSTER_IP):
```sh ```sh
curl <insert-ip-from-above-here> curl <insert-cluster-ip-here>
``` ```
Note that you will need run this curl command on your boot2docker VM if you are running on OS X. Note that you will need run this curl command on your boot2docker VM if you are running on OS X.
......
...@@ -209,8 +209,7 @@ walk-through - you can use your own `Service`'s details here. ...@@ -209,8 +209,7 @@ walk-through - you can use your own `Service`'s details here.
```console ```console
$ kubectl expose rc hostnames --port=80 --target-port=9376 $ kubectl expose rc hostnames --port=80 --target-port=9376
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE service "hostnames" exposed
hostnames 10.0.0.1 <none> 80/TCP run=hostnames 1h
``` ```
And read it back, just to be sure: And read it back, just to be sure:
......
...@@ -82,8 +82,7 @@ If load balancers are not supported (e.g.: on Vagrant), we can expose php-apache ...@@ -82,8 +82,7 @@ If load balancers are not supported (e.g.: on Vagrant), we can expose php-apache
```console ```console
$ kubectl expose rc php-apache --port=80 --type=ClusterIP $ kubectl expose rc php-apache --port=80 --type=ClusterIP
NAME LABELS SELECTOR IP(S) PORT(S) service "php-apache" exposed
php-apache run=php-apache run=php-apache 80/TCP
$ kubectl cluster-info | grep master $ kubectl cluster-info | grep master
Kubernetes master is running at https://146.148.6.215 Kubernetes master is running at https://146.148.6.215
......
...@@ -76,8 +76,7 @@ Through integration with some cloud providers (for example Google Compute Engine ...@@ -76,8 +76,7 @@ Through integration with some cloud providers (for example Google Compute Engine
```console ```console
$ kubectl expose rc my-nginx --port=80 --type=LoadBalancer $ kubectl expose rc my-nginx --port=80 --type=LoadBalancer
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE service "my-nginx" exposed
my-nginx 10.179.240.1 <none> 80/TCP run=nginx 8d
``` ```
To find the public IP address assigned to your application, execute: To find the public IP address assigned to your application, execute:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment