Replace RC with Deployments

This commit is contained in:
Janet Kuo
2016-03-21 16:10:20 -07:00
parent 1972537aef
commit 7077aac069
4 changed files with 75 additions and 83 deletions
+17 -26
View File
@@ -6,44 +6,36 @@ This guide will help you get oriented to Kubernetes and running your first conta
* TOC
{:toc}
## Launching a simple application
## Launching a simple application, and exposing it to the Internet
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.
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.
```shell
$ kubectl run my-nginx --image=nginx --replicas=2 --port=80
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
my-nginx my-nginx nginx run=my-nginx 2
$ kubectl run my-nginx --image=nginx --replicas=2 --port=80 --expose --service-overrides='{ "spec": { "type": "LoadBalancer" } }'
service "my-nginx" created
deployment "my-nginx" created
```
You can see that they are running by:
```shell
$ kubectl get po
NAME READY STATUS RESTARTS AGE
my-nginx-l8n3i 1/1 Running 0 29m
my-nginx-q7jo3 1/1 Running 0 29m
NAME READY STATUS RESTARTS AGE
my-nginx-3800858182-h9v8d 1/1 Running 0 1m
my-nginx-3800858182-wqafx 1/1 Running 0 1m
```
Kubernetes will ensure that your application keeps running, by automatically restarting containers that fail, spreading containers across nodes, and recreating containers on new nodes when nodes fail.
## Exposing your application to the Internet
Through integration with some cloud providers (for example Google Compute Engine and AWS EC2), Kubernetes enables you to request that it provision a public IP address for your application. To do this run:
```shell
$ kubectl expose rc my-nginx --port=80 --type=LoadBalancer
service "my-nginx" exposed
```
To find the public IP address assigned to your application, execute:
```shell
$ kubectl get svc my-nginx
NAME CLUSTER_IP EXTERNAL_IP PORT(S) SELECTOR AGE
my-nginx 10.179.240.1 25.1.2.3 80/TCP run=nginx 8d
$ 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
```
You may need to wait for a minute or two for the external ip address to be provisioned.
@@ -51,7 +43,7 @@ You may need to wait for a minute or two for the external ip address to be provi
In order to access your nginx landing page, you also have to make sure that traffic from external IPs is allowed. Do this by opening a [firewall to allow traffic on port 80](/docs/user-guide/services-firewalls).
If you're running on AWS, Kubernetes creates an ELB for you. ELBs use host
names, not IPs, so you will have to do `kubectl describe svc my-nginx` and look
names, not IPs, so you will have to do `kubectl describe service/my-nginx` and look
for the `LoadBalancer Ingress` host name. Traffic from external IPs is allowed
automatically.
@@ -60,12 +52,11 @@ automatically.
To kill the application and delete its containers and public IP address, do:
```shell
$ kubectl delete rc my-nginx
replicationcontrollers/my-nginx
$ kubectl delete svc my-nginx
services/my-nginx
$ kubectl delete deployment,service my-nginx
deployment "my-nginx" deleted
service "my-nginx" deleted
```
## What's next?
[Learn about how to configure common container parameters, such as commands and environment variables.](/docs/user-guide/configuring-containers)
[Learn about how to configure common container parameters, such as commands and environment variables.](/docs/user-guide/configuring-containers)