Write page templates and canonical examples.

Conflicts:
	_data/tasks.yml
	_data/tutorials.yml
	docs/tasks/access-kubernetes-api/http-proxy-access-api.md
	docs/tasks/index.md
	docs/tutorials/index.md
This commit is contained in:
steveperry-53
2016-09-23 15:40:21 -07:00
parent 51add3e397
commit 822d59b5e4
23 changed files with 1254 additions and 37 deletions
+16
View File
@@ -0,0 +1,16 @@
---
---
The Tutorials section of the Kubernetes documentation is a work in progress.
#### Stateless Applications
* [Running a Stateless Application Using a Deployment](/docs/tutorials/stateless-application/run-stateless-application-deployment/)
* [Exposing an External IP Address Using a Service](/docs/tutorials/stateless-application/expose-external-ip-address-service/)
### What's next
If you would like to write a tutorial, see
[Using Page Templates](/docs/contribute/page-templates/)
for information about the tutorial page type and the tutorial template.
@@ -0,0 +1,16 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.8 # Update the version of nginx from 1.7.9 to 1.8
ports:
- containerPort: 80
@@ -0,0 +1,19 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2 # tells deployment to run 2 pods matching the template
template: # create pods using pod definition in this template
metadata:
# unlike pod-nginx.yaml, the name is not included in the meta data as a unique name is
# generated from the deployment name
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
Contact GitHub API Training Shop Blog About
@@ -0,0 +1,146 @@
---
---
{% capture overview %}
This page shows how to create a Kubernetes Service object that external
clients can use to access an application running in a cluster. The
Service exposes a stable IP address and provides load balancing for
an application that has two running instances.
{% endcapture %}
{% capture prerequisites %}
* Install [kubectl](http://kubernetes.io/docs/user-guide/prereqs).
* Create a Kubernetes cluster, including a running Kubernetes
API server. One way to create a new cluster is to use
[Minikube](/docs/getting-started-guides/minikube).
* Configure `kubectl` to communicate with your Kubernetes API server. This
configuration is done automatically if you use Minikube.
{% endcapture %}
{% capture objectives %}
* Run two instances of a Hello World application.
* Create a Service object that exposes an external IP address.
* Use the Service object to access the running application.
{% endcapture %}
{% capture lessoncontent %}
### Creating a service for an application running in two pods
1. Run a Hello World application in your cluster:
kubectl run hello-world --replicas=2 --labels="run=load-balancer-example" --image=gcr.io/google-samples/node-hello:1.0 --port=8080
The preceding command creates a
[Deployment](/docs/user-guide/deployments/)
object and an associated
[ReplicaSet](/docs/user-guide/replicasets/)
object. The ReplicaSet has two
[Pods](/docs/user-guide/pods/),
each of which runs the Hello World application.
1. Display information about the Deployment:
kubectl get deployments hello-world
kubectl describe deployments hello-world
1. Display information about the ReplicaSet:
kubectl get replicasets hello-world
kubectl describe replicasets hello-world
1. List the pods that are running the Hello World application:
kubectl get pods --selector="run=load-balancer-example"
The output is similar to this:
NAME READY STATUS RESTARTS AGE
hello-world-2189936611-8fyp0 1/1 Running 0 6m
hello-world-2189936611-9isq8 1/1 Running 0 6m
1. Create a Service object that exposes the deployment:
kubectl expose deployment hello-world --type="LoadBalancer" --name="example-service"
1. Display the IP addresses for your service:
kubectl get services example-service
The output shows the internal IP address and the external IP address of
your service. If the external IP address shows as `<pending>`, repeat the
command.
Note: If you are using Minikube, you don't get an external IP address. The
external IP address remains in the pending state.
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
example-service 10.0.0.160 <pending> 8080/TCP 40s
1. Use your service to access the Hello World application:
curl <your-external-ip-address>:8080
where `<your-external-ip-address>` is the external IP address of your
service.
The output is a hello message from the application:
Hello Kubernetes!
Note: If you are using Minikube, enter these commands:
kubectl cluster-info
kubectl describe services example-service
The output displays the IP address of your Minikube node and the NodePort
value for your service. Enter this command to access the Hello World
application:
curl <minikube-node-ip-address>:<service-node-port>
where `<minikube-node-ip-address>` us the IP address of your Minikube node,
and `<service-node-port>` is the NodePort value for your service.
### Using a service configuration file
As an alternative to using `kubectl expose`, you can use a
[service configuration file](/docs/user-guide/services/operations)
to create a Service.
{% endcapture %}
{% capture cleanup %}
To delete the Service, enter this command:
kubectl delete services example-service
To delete the Deployment, the ReplicaSet, and the Pods that are running
the Hello World application, enter this command:
kubectl delete deployment hello-world
{% endcapture %}
{% capture whatsnext %}
Learn more about
[connecting applications with services](/docs/user-guide/connecting-applications/).
{% endcapture %}
{% include templates/tutorial.md %}
@@ -0,0 +1,114 @@
---
---
{% capture overview %}
This page shows how to run an application using a Kubernetes Deployment object.
{% endcapture %}
{% capture objectives %}
* Create an nginx deployment.
* Use kubectl to list information about the deployment.
* Update the deployment.
{% endcapture %}
{% capture prerequisites %}
* To do this tutorial, you need a Kubernetes cluster, including a running
Kubernetes API server. You can use an existing cluster, or you can create a
new cluster. One way to create a new cluster is to use
[Minikube](/docs/getting-started-guides/minikube).
* You also need to have `kubectl` installed on your local machine, and `kubectl`
must be configured to communicate with your Kubernetes API server. This
configuration is done automatically if you use Minikube.
{% endcapture %}
{% capture lessoncontent %}
### Creating and exploring an nginx deployment
You can run an application by creating a Kubernetes Deployment object, and you
can describe a Deployment in a YAML file. For example, this YAML file describes
a Deployment that runs the nginx:1.7.9 Docker image:
{% include code.html language="yaml" file="deployment.yaml" ghlink="/docs/tutorials/stateless-application/deployment.yaml" %}
1. Create a Deployment based on the YAML file:
export REPO=https://raw.githubusercontent.com/kubernetes/kubernetes.github.io/master
kubectl create -f $REPO/docs/tutorials/stateless-application/deployment.yaml
1. Display information about the Deployment:
kubectl describe deployment nginx-deployment
user@computer:~/kubernetes.github.io$ kubectl describe deployment nginx-deployment
Name: nginx-deployment
Namespace: default
CreationTimestamp: Tue, 30 Aug 2016 18:11:37 -0700
Labels: app=nginx
Selector: app=nginx
Replicas: 2 updated | 2 total | 2 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 1 max unavailable, 1 max surge
OldReplicaSets: <none>
NewReplicaSet: nginx-deployment-1771418926 (2/2 replicas created)
No events.
1. List the pods created by the deployment:
kubectl get pods -l app=nginx
NAME READY STATUS RESTARTS AGE
nginx-deployment-1771418926-7o5ns 1/1 Running 0 16h
nginx-deployment-1771418926-r18az 1/1 Running 0 16h
1. Display information about a pod:
kubectl display pod <pod-name>
where `<pod-name>` is the name of one of your pods.
### Updating the deployment
You can update the deployment by applying a new YAML file. This YAML file
specifies that the deployment should be updated to use nginx 1.8.
{% include code.html language="yaml" file="deployment-update.yaml" ghlink="/docs/tutorials/stateless-application/deployment-update.yaml" %}
1. Apply the new YAML file:
kubectl apply -f $REPO/docs/tutorials/stateless-application/deployment-update.yaml
1. Watch the deployment create pods with new names and delete the old pods:
kubectl get pods -l app=nginx
### Deleting a deployment
Delete the deployment by name:
kubectl delete deployment nginx-deployment
{% endcapture %}
{% capture whatsnext %}
* Learn more about [Deployment objects](/docs/user-guide/deployments/).
* Learn more about [Deploying applications](/docs/user-guide/deploying-applications/)
{% endcapture %}
{% include templates/tutorial.md %}