Skip to content

Commit

Permalink
Tune links in tasks section (2/2)
Browse files Browse the repository at this point in the history
  • Loading branch information
tengqm committed Aug 8, 2020
1 parent 6644648 commit 92ae1a9
Show file tree
Hide file tree
Showing 29 changed files with 379 additions and 372 deletions.
Expand Up @@ -8,9 +8,6 @@ content_type: concept

This topic discusses multiple ways to interact with clusters.




<!-- body -->

## Accessing for the first time with kubectl
Expand All @@ -29,8 +26,9 @@ Check the location and credentials that kubectl knows about with this command:
kubectl config view
```

Many of the [examples](/docs/user-guide/kubectl-cheatsheet) provide an introduction to using
kubectl and complete documentation is found in the [kubectl manual](/docs/user-guide/kubectl-overview).
Many of the [examples](/docs/reference/kubectl/cheatsheet/) provide an introduction to using
kubectl and complete documentation is found in the
[kubectl manual](/docs/reference/kubectl/overview/).

## Directly accessing the REST API

Expand Down Expand Up @@ -165,7 +163,7 @@ client libraries.
* To get the library, run the following command: `go get k8s.io/client-go@kubernetes-<kubernetes-version-number>`, see [INSTALL.md](https://github.com/kubernetes/client-go/blob/master/INSTALL.md#for-the-casual-user) for detailed installation instructions. See [https://github.com/kubernetes/client-go](https://github.com/kubernetes/client-go#compatibility-matrix) to see which versions are supported.
* Write an application atop of the client-go clients. Note that client-go defines its own API objects, so if needed, please import API definitions from client-go rather than from the main repository, e.g., `import "k8s.io/client-go/kubernetes"` is correct.

The Go client can use the same [kubeconfig file](/docs/concepts/cluster-administration/authenticate-across-clusters-kubeconfig/)
The Go client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
as the kubectl CLI does to locate and authenticate to the apiserver. See this [example](https://git.k8s.io/client-go/examples/out-of-cluster-client-configuration/main.go).

If the application is deployed as a Pod in the cluster, please refer to the [next section](#accessing-the-api-from-a-pod).
Expand All @@ -174,7 +172,7 @@ If the application is deployed as a Pod in the cluster, please refer to the [nex

To use [Python client](https://github.com/kubernetes-client/python), run the following command: `pip install kubernetes`. See [Python Client Library page](https://github.com/kubernetes-client/python) for more installation options.

The Python client can use the same [kubeconfig file](/docs/concepts/cluster-administration/authenticate-across-clusters-kubeconfig/)
The Python client can use the same [kubeconfig file](/docs/concepts/configuration/organize-cluster-access-kubeconfig/)
as the kubectl CLI does to locate and authenticate to the apiserver. See this [example](https://github.com/kubernetes-client/python/tree/master/examples).

### Other languages
Expand Down Expand Up @@ -219,7 +217,9 @@ In each case, the credentials of the pod are used to communicate securely with t

The previous section was about connecting the Kubernetes API server. This section is about
connecting to other services running on Kubernetes cluster. In Kubernetes, the
[nodes](/docs/admin/node), [pods](/docs/user-guide/pods) and [services](/docs/user-guide/services) all have
[nodes](/docs/concepts/architecture/nodes/),
[pods](/docs/concepts/workloads/pods/) and
[services](/docs/concepts/services-networking/service/) all have
their own IPs. In many cases, the node IPs, pod IPs, and some service IPs on a cluster will not be
routable, so they will not be reachable from a machine outside the cluster,
such as your desktop machine.
Expand All @@ -230,7 +230,7 @@ You have several options for connecting to nodes, pods and services from outside

- Access services through public IPs.
- Use a service with type `NodePort` or `LoadBalancer` to make the service reachable outside
the cluster. See the [services](/docs/user-guide/services) and
the cluster. See the [services](/docs/concepts/services-networking/service/) and
[kubectl expose](/docs/reference/generated/kubectl/kubectl-commands/#expose) documentation.
- Depending on your cluster environment, this may just expose the service to your corporate network,
or it may expose it to the internet. Think about whether the service being exposed is secure.
Expand Down
Expand Up @@ -7,19 +7,14 @@ weight: 110
<!-- overview -->

This page shows how to use a Volume to communicate between two Containers running
in the same Pod. See also how to allow processes to communicate by [sharing process namespace](/docs/tasks/configure-pod-container/share-process-namespace/) between containers.



in the same Pod. See also how to allow processes to communicate by
[sharing process namespace](/docs/tasks/configure-pod-container/share-process-namespace/)
between containers.

## {{% heading "prerequisites" %}}


{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}




<!-- steps -->

## Creating a Pod that runs two Containers
Expand Down Expand Up @@ -103,14 +98,15 @@ The output is similar to this:
Recall that the debian Container created the `index.html` file in the nginx root
directory. Use `curl` to send a GET request to the nginx server:

root@two-containers:/# curl localhost
```
root@two-containers:/# curl localhost
```

The output shows that nginx serves a web page written by the debian container:

Hello from the debian container



```
Hello from the debian container
```

<!-- discussion -->

Expand All @@ -128,28 +124,18 @@ The Volume in this exercise provides a way for Containers to communicate during
the life of the Pod. If the Pod is deleted and recreated, any data stored in
the shared Volume is lost.




## {{% heading "whatsnext" %}}


* Learn more about
[patterns for composite containers](https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns).
* Learn more about [patterns for composite containers](https://kubernetes.io/blog/2015/06/the-distributed-system-toolkit-patterns).

* Learn about
[composite containers for modular architecture](http://www.slideshare.net/Docker/slideshare-burns).
* Learn about [composite containers for modular architecture](https://www.slideshare.net/Docker/slideshare-burns).

* See
[Configuring a Pod to Use a Volume for Storage](/docs/tasks/configure-pod-container/configure-volume-storage/).
* See [Configuring a Pod to Use a Volume for Storage](/docs/tasks/configure-pod-container/configure-volume-storage/).

* See [Configure a Pod to share process namespace between containers in a Pod](/docs/tasks/configure-pod-container/share-process-namespace/)

* See [Volume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#volume-v1-core).

* See [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core).





Expand Up @@ -11,33 +11,21 @@ microservice. The backend microservice is a hello greeter. The
frontend and backend are connected using a Kubernetes
{{< glossary_tooltip term_id="service" >}} object.




## {{% heading "objectives" %}}


* Create and run a microservice using a {{< glossary_tooltip term_id="deployment" >}} object.
* Route traffic to the backend using a frontend.
* Use a Service object to connect the frontend application to the
backend application.




## {{% heading "prerequisites" %}}

{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}

* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}

* This task uses
[Services with external load balancers](/docs/tasks/access-application-cluster/create-external-load-balancer/), which
require a supported environment. If your environment does not
support this, you can use a Service of type
[NodePort](/docs/concepts/services-networking/service/#nodeport) instead.



This task uses
[Services with external load balancers](/docs/tasks/access-application-cluster/create-external-load-balancer/), which
require a supported environment. If your environment does not support this, you can use a Service of type
[NodePort](/docs/concepts/services-networking/service/#nodeport) instead.

<!-- lessoncontent -->

Expand Down Expand Up @@ -153,8 +141,8 @@ service/frontend created
```

{{< note >}}
The nginx configuration is baked into the [container
image](/examples/service/access/Dockerfile). A better way to do this would
The nginx configuration is baked into the
[container image](/examples/service/access/Dockerfile). A better way to do this would
be to use a
[ConfigMap](/docs/tasks/configure-pod-container/configure-pod-configmap/),
so that you can change the configuration more easily.
Expand Down Expand Up @@ -203,27 +191,22 @@ The output shows the message generated by the backend:
{"message":"Hello"}
```



## {{% heading "cleanup" %}}


To delete the Services, enter this command:

kubectl delete services frontend hello
```shell
kubectl delete services frontend hello
```

To delete the Deployments, the ReplicaSets and the Pods that are running the backend and frontend applications, enter this command:

kubectl delete deployment frontend hello


```shell
kubectl delete deployment frontend hello
```

## {{% heading "whatsnext" %}}


* Learn more about [Services](/docs/concepts/services-networking/service/)
* Learn more about [ConfigMaps](/docs/tasks/configure-pod-container/configure-pod-configmap/)




Expand Up @@ -9,15 +9,10 @@ weight: 100
This page shows how to use kubectl to list all of the Container images
for Pods running in a cluster.



## {{% heading "prerequisites" %}}


{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}



<!-- steps -->

In this exercise you will use kubectl to fetch all of the Pods
Expand All @@ -30,14 +25,14 @@ of Containers for each.
- Format the output to include only the list of Container image names
using `-o jsonpath={..image}`. This will recursively parse out the
`image` field from the returned json.
- See the [jsonpath reference](/docs/user-guide/jsonpath/)
- See the [jsonpath reference](/docs/reference/kubectl/jsonpath/)
for further information on how to use jsonpath.
- Format the output using standard tools: `tr`, `sort`, `uniq`
- Use `tr` to replace spaces with newlines
- Use `sort` to sort the results
- Use `uniq` to aggregate image counts

```sh
```shell
kubectl get pods --all-namespaces -o jsonpath="{..image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
Expand All @@ -52,7 +47,7 @@ field within the Pod. This ensures the correct field is retrieved
even when the field name is repeated,
e.g. many fields are called `name` within a given item:

```sh
```shell
kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}"
```

Expand All @@ -74,7 +69,7 @@ Pod is returned instead of a list of items.
The formatting can be controlled further by using the `range` operation to
iterate over elements individually.

```sh
```shell
kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |\
sort
```
Expand All @@ -84,7 +79,7 @@ sort
To target only Pods matching a specific label, use the -l flag. The
following matches only Pods with labels matching `app=nginx`.

```sh
```shell
kubectl get pods --all-namespaces -o=jsonpath="{..image}" -l app=nginx
```

Expand All @@ -93,7 +88,7 @@ kubectl get pods --all-namespaces -o=jsonpath="{..image}" -l app=nginx
To target only pods in a specific namespace, use the namespace flag. The
following matches only Pods in the `kube-system` namespace.

```sh
```shell
kubectl get pods --namespace kube-system -o jsonpath="{..image}"
```

Expand All @@ -102,27 +97,14 @@ kubectl get pods --namespace kube-system -o jsonpath="{..image}"
As an alternative to jsonpath, Kubectl supports using [go-templates](https://golang.org/pkg/text/template/)
for formatting the output:


```sh
```shell
kubectl get pods --all-namespaces -o go-template --template="{{range .items}}{{range .spec.containers}}{{.image}} {{end}}{{end}}"
```





<!-- discussion -->



## {{% heading "whatsnext" %}}


### Reference

* [Jsonpath](/docs/user-guide/jsonpath/) reference guide
* [Jsonpath](/docs/reference/kubectl/jsonpath/) reference guide
* [Go template](https://golang.org/pkg/text/template/) reference guide




0 comments on commit 92ae1a9

Please sign in to comment.