apply template (#9733)
parent
ba7332ee71
commit
3cdc80dbc0
|
|
@ -3,17 +3,32 @@ reviewers:
|
|||
- eparis
|
||||
- mikedanese
|
||||
title: Kubernetes 101
|
||||
content_template: templates/tutorial
|
||||
---
|
||||
|
||||
{{< toc >}}
|
||||
|
||||
## Kubectl CLI and Pods
|
||||
{{% capture overview %}}
|
||||
|
||||
For Kubernetes 101, we will cover kubectl, Pods, Volumes, and multiple containers.
|
||||
|
||||
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||
{{% /capture %}}
|
||||
|
||||
In order for the kubectl usage examples to work, make sure you have an example directory locally, either from [a release](https://github.com/kubernetes/kubernetes/releases) or the latest `.yaml` files located [here](https://github.com/kubernetes/website/tree/master/content/en/docs/tutorials).
|
||||
{{% capture objectives %}}
|
||||
|
||||
* What is `kubectl`.
|
||||
* Manage a Pod.
|
||||
* Create and mount a volume.
|
||||
* Create multiple containers in a Pod.
|
||||
|
||||
{{% /capture %}}
|
||||
|
||||
{{% capture prerequisites %}}
|
||||
|
||||
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||
* In order for the kubectl usage examples to work, make sure you have an example directory locally, either from [a release](https://github.com/kubernetes/kubernetes/releases) or the latest `.yaml` files located [here](https://github.com/kubernetes/website/tree/master/content/en/docs/tutorials).
|
||||
|
||||
{{% /capture %}}
|
||||
|
||||
{{% capture lessoncontent %}}
|
||||
|
||||
## Kubectl CLI
|
||||
|
||||
|
|
@ -46,13 +61,13 @@ For more information, see [Kubernetes Design Documents and Proposals](https://gi
|
|||
Create a Pod containing an nginx server ([simple-pod.yaml](/examples/pods/simple-pod.yaml)):
|
||||
|
||||
```shell
|
||||
$ kubectl create -f https://k8s.io/examples/pods/simple-pod.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/simple-pod.yaml
|
||||
```
|
||||
|
||||
List all Pods:
|
||||
|
||||
```shell
|
||||
$ kubectl get pods
|
||||
kubectl get pods
|
||||
```
|
||||
|
||||
On most providers, the Pod IPs are not externally accessible. The easiest way to test that the pod is working is to create a busybox Pod and exec commands on it remotely. For more information, see [Get a Shell to a Running Container](/docs/tasks/debug-application-cluster/get-shell-running-container/).
|
||||
|
|
@ -60,17 +75,19 @@ On most providers, the Pod IPs are not externally accessible. The easiest way to
|
|||
If the IP of the Pod is accessible, you can access its http endpoint with wget on port 80:
|
||||
|
||||
```shell
|
||||
$ kubectl run busybox --image=busybox --restart=Never --tty -i --generator=run-pod/v1 --env "POD_IP=$(kubectl get pod nginx -o go-template='{{.status.podIP}}')"
|
||||
kubectl run busybox --image=busybox --restart=Never --tty -i --generator=run-pod/v1 --env "POD_IP=$(kubectl get pod nginx -o go-template='{{.status.podIP}}')"
|
||||
u@busybox$ wget -qO- http://$POD_IP # 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"
|
||||
```
|
||||
|
||||
```shell
|
||||
kubectl delete pod busybox # Clean up the pod we created with "kubectl run"
|
||||
```
|
||||
|
||||
To delete a Pod named nginx:
|
||||
|
||||
```shell
|
||||
$ kubectl delete pod nginx
|
||||
kubectl delete pod nginx
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -119,8 +136,9 @@ For more information, see [Volumes](/docs/concepts/storage/volumes/).
|
|||
|
||||
#### Multiple Containers
|
||||
|
||||
_Note:
|
||||
The examples below are syntactically correct, but some of the images (e.g. kubernetes/git-monitor) don't exist yet. We're working on turning these into working examples._
|
||||
{{< note >}}
|
||||
**Note:** The examples below are syntactically correct, but some of the images (e.g. kubernetes/git-monitor) don't exist yet. We're working on turning these into working examples.
|
||||
{{< /note >}}
|
||||
|
||||
|
||||
However, often you want to have two different containers that work together. An example of this would be a web server, and a helper job that polls a git repository for new updates:
|
||||
|
|
@ -155,8 +173,11 @@ Note that we have also added a Volume here. In this case, the Volume is mounted
|
|||
|
||||
Finally, we have also introduced an environment variable to the `git-monitor` container, which allows us to parameterize that container with the particular git repository that we want to track.
|
||||
|
||||
{{% /capture %}}
|
||||
|
||||
## What's Next?
|
||||
{{% capture whatsnext %}}
|
||||
|
||||
Continue on to [Kubernetes 201](/docs/tutorials/k8s201/) or
|
||||
for a complete application see the [guestbook example](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/guestbook/)
|
||||
|
||||
{{% /capture %}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue