diff --git a/content/en/docs/tutorials/k8s201.md b/content/en/docs/tutorials/k8s201.md index 2628f90b28..7c41d8864b 100644 --- a/content/en/docs/tutorials/k8s201.md +++ b/content/en/docs/tutorials/k8s201.md @@ -3,20 +3,35 @@ reviewers: - janetkuo - mikedanese title: Kubernetes 201 +content_template: templates/tutorial --- -{{< toc >}} -## Labels, Deployments, Services and Health Checking +{{% capture overview %}} + +For Kubernetes 201, we will pick up where 101 left off and cover some slightly more advanced topics in Kubernetes, related to application productionization, Deployment and scaling. If you went through [Kubernetes 101](/docs/tutorials/k8s101/), you learned about kubectl, Pods, Volumes, and multiple containers. -For Kubernetes 201, we will pick up where 101 left off and cover some slightly more advanced topics in Kubernetes, related to application productionization, Deployment and -scaling. -{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} +{{% /capture %}} -In order for the kubectl usage examples to work, make sure you have an examples directory locally, either from [a release](https://github.com/kubernetes/kubernetes/releases) or [the source](https://github.com/kubernetes/kubernetes). +{{% capture objectives %}} +* Add labels to the Pod. +* Manage a Deployment. +* Manage a Service. +* What is the health checking. + +{{% /capture %}} + +{{% capture prerequisites %}} + +* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}} +* In order for the kubectl usage examples to work, make sure you have an examples directory locally, either from [a release](https://github.com/kubernetes/kubernetes/releases) or [the source](https://github.com/kubernetes/kubernetes). + +{{% /capture %}} + +{{% capture lessoncontent %}} ## Labels @@ -140,14 +155,23 @@ On most providers, the service IPs are not externally accessible. The easiest wa Provided the service IP is accessible, you should be able to access its http endpoint with wget on the exposed port: ```shell +export SERVICE_IP=$(kubectl get service nginx-service -o go-template='{{.spec.clusterIP}}') +export SERVICE_PORT=$(kubectl get service nginx-service -o go-template='{{(index .spec.ports 0).port}}') +``` -$ export SERVICE_IP=$(kubectl get service nginx-service -o go-template='{{.spec.clusterIP}}') -$ export SERVICE_PORT=$(kubectl get service nginx-service -o go-template='{{(index .spec.ports 0).port}}') -$ echo "$SERVICE_IP:$SERVICE_PORT" -$ kubectl run busybox --generator=run-pod/v1 --image=busybox --restart=Never --tty -i --env "SERVICE_IP=$SERVICE_IP" --env "SERVICE_PORT=$SERVICE_PORT" +Check `$SERVICE_IP` and `$SERVICE_PORT`: + +```shell +echo "$SERVICE_IP:$SERVICE_PORT" +``` + +Then, create a busybox Pod: +```shell +kubectl run busybox --generator=run-pod/v1 --image=busybox --restart=Never --tty -i --env "SERVICE_IP=$SERVICE_IP" --env "SERVICE_PORT=$SERVICE_PORT" u@busybox$ wget -qO- http://$SERVICE_IP:$SERVICE_PORT # Run in the busybox container u@busybox$ exit # Exit the busybox container -$ kubectl delete pod busybox # Clean up the pod we created with "kubectl run" + +kubectl delete pod busybox # Clean up the pod we created with "kubectl run" ``` @@ -233,7 +257,10 @@ And here is an example config for a Pod with a TCP Socket health check For more information about health checking, see [Container Probes](/docs/user-guide/pod-states/#container-probes). +{{% /capture %}} -## What's Next? +{{% capture whatsnext %}} For a complete application see the [guestbook example](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/guestbook/). + +{{% /capture %}}