apply template (#9734)
This commit is contained in:
@@ -3,20 +3,35 @@ reviewers:
|
|||||||
- janetkuo
|
- janetkuo
|
||||||
- mikedanese
|
- mikedanese
|
||||||
title: Kubernetes 201
|
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.
|
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
|
## 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:
|
Provided the service IP is accessible, you should be able to access its http endpoint with wget on the exposed port:
|
||||||
|
|
||||||
```shell
|
```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}}')
|
Check `$SERVICE_IP` and `$SERVICE_PORT`:
|
||||||
$ export SERVICE_PORT=$(kubectl get service nginx-service -o go-template='{{(index .spec.ports 0).port}}')
|
|
||||||
$ echo "$SERVICE_IP:$SERVICE_PORT"
|
```shell
|
||||||
$ kubectl run busybox --generator=run-pod/v1 --image=busybox --restart=Never --tty -i --env "SERVICE_IP=$SERVICE_IP" --env "SERVICE_PORT=$SERVICE_PORT"
|
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$ wget -qO- http://$SERVICE_IP:$SERVICE_PORT # Run in the busybox container
|
||||||
u@busybox$ exit # Exit 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).
|
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/).
|
For a complete application see the [guestbook example](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/guestbook/).
|
||||||
|
|
||||||
|
{{% /capture %}}
|
||||||
|
|||||||
Reference in New Issue
Block a user