Skip to content

Commit f7689cb

Browse files
authored
Merge pull request #37210 from tengqm/tweak-overview
Tweak line wrapping for configuration overview page
2 parents 3f86f44 + 2e131a5 commit f7689cb

File tree

1 file changed

+86
-33
lines changed

1 file changed

+86
-33
lines changed

content/en/docs/concepts/configuration/overview.md

Lines changed: 86 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,132 @@ weight: 10
77
---
88

99
<!-- overview -->
10-
This document highlights and consolidates configuration best practices that are introduced throughout the user guide, Getting Started documentation, and examples.
11-
12-
This is a living document. If you think of something that is not on this list but might be useful to others, please don't hesitate to file an issue or submit a PR.
10+
This document highlights and consolidates configuration best practices that are introduced
11+
throughout the user guide, Getting Started documentation, and examples.
1312

13+
This is a living document. If you think of something that is not on this list but might be useful
14+
to others, please don't hesitate to file an issue or submit a PR.
1415

1516
<!-- body -->
1617
## General Configuration Tips
1718

1819
- When defining configurations, specify the latest stable API version.
1920

20-
- Configuration files should be stored in version control before being pushed to the cluster. This allows you to quickly roll back a configuration change if necessary. It also aids cluster re-creation and restoration.
21+
- Configuration files should be stored in version control before being pushed to the cluster. This
22+
allows you to quickly roll back a configuration change if necessary. It also aids cluster
23+
re-creation and restoration.
2124

22-
- Write your configuration files using YAML rather than JSON. Though these formats can be used interchangeably in almost all scenarios, YAML tends to be more user-friendly.
25+
- Write your configuration files using YAML rather than JSON. Though these formats can be used
26+
interchangeably in almost all scenarios, YAML tends to be more user-friendly.
2327

24-
- Group related objects into a single file whenever it makes sense. One file is often easier to manage than several. See the [guestbook-all-in-one.yaml](https://github.com/kubernetes/examples/tree/master/guestbook/all-in-one/guestbook-all-in-one.yaml) file as an example of this syntax.
28+
- Group related objects into a single file whenever it makes sense. One file is often easier to
29+
manage than several. See the
30+
[guestbook-all-in-one.yaml](https://github.com/kubernetes/examples/tree/master/guestbook/all-in-one/guestbook-all-in-one.yaml)
31+
file as an example of this syntax.
2532

26-
- Note also that many `kubectl` commands can be called on a directory. For example, you can call `kubectl apply` on a directory of config files.
33+
- Note also that many `kubectl` commands can be called on a directory. For example, you can call
34+
`kubectl apply` on a directory of config files.
2735

2836
- Don't specify default values unnecessarily: simple, minimal configuration will make errors less likely.
2937

3038
- Put object descriptions in annotations, to allow better introspection.
3139

32-
3340
## "Naked" Pods versus ReplicaSets, Deployments, and Jobs {#naked-pods-vs-replicasets-deployments-and-jobs}
3441

35-
- Don't use naked Pods (that is, Pods not bound to a [ReplicaSet](/docs/concepts/workloads/controllers/replicaset/) or [Deployment](/docs/concepts/workloads/controllers/deployment/)) if you can avoid it. Naked Pods will not be rescheduled in the event of a node failure.
36-
37-
A Deployment, which both creates a ReplicaSet to ensure that the desired number of Pods is always available, and specifies a strategy to replace Pods (such as [RollingUpdate](/docs/concepts/workloads/controllers/deployment/#rolling-update-deployment)), is almost always preferable to creating Pods directly, except for some explicit [`restartPolicy: Never`](/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy) scenarios. A [Job](/docs/concepts/workloads/controllers/job/) may also be appropriate.
42+
- Don't use naked Pods (that is, Pods not bound to a [ReplicaSet](/docs/concepts/workloads/controllers/replicaset/) or
43+
[Deployment](/docs/concepts/workloads/controllers/deployment/)) if you can avoid it. Naked Pods
44+
will not be rescheduled in the event of a node failure.
3845

46+
A Deployment, which both creates a ReplicaSet to ensure that the desired number of Pods is
47+
always available, and specifies a strategy to replace Pods (such as
48+
[RollingUpdate](/docs/concepts/workloads/controllers/deployment/#rolling-update-deployment)), is
49+
almost always preferable to creating Pods directly, except for some explicit
50+
[`restartPolicy: Never`](/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy) scenarios.
51+
A [Job](/docs/concepts/workloads/controllers/job/) may also be appropriate.
3952

4053
## Services
4154

42-
- Create a [Service](/docs/concepts/services-networking/service/) before its corresponding backend workloads (Deployments or ReplicaSets), and before any workloads that need to access it. When Kubernetes starts a container, it provides environment variables pointing to all the Services which were running when the container was started. For example, if a Service named `foo` exists, all containers will get the following variables in their initial environment:
55+
- Create a [Service](/docs/concepts/services-networking/service/) before its corresponding backend
56+
workloads (Deployments or ReplicaSets), and before any workloads that need to access it.
57+
When Kubernetes starts a container, it provides environment variables pointing to all the Services
58+
which were running when the container was started. For example, if a Service named `foo` exists,
59+
all containers will get the following variables in their initial environment:
4360

4461
```shell
4562
FOO_SERVICE_HOST=<the host the Service is running on>
4663
FOO_SERVICE_PORT=<the port the Service is running on>
4764
```
4865

49-
*This does imply an ordering requirement* - any `Service` that a `Pod` wants to access must be created before the `Pod` itself, or else the environment variables will not be populated. DNS does not have this restriction.
66+
*This does imply an ordering requirement* - any `Service` that a `Pod` wants to access must be
67+
created before the `Pod` itself, or else the environment variables will not be populated.
68+
DNS does not have this restriction.
5069

51-
- An optional (though strongly recommended) [cluster add-on](/docs/concepts/cluster-administration/addons/) is a DNS server. The
52-
DNS server watches the Kubernetes API for new `Services` and creates a set of DNS records for each. If DNS has been enabled throughout the cluster then all `Pods` should be able to do name resolution of `Services` automatically.
70+
- An optional (though strongly recommended) [cluster add-on](/docs/concepts/cluster-administration/addons/)
71+
is a DNS server. The DNS server watches the Kubernetes API for new `Services` and creates a set
72+
of DNS records for each. If DNS has been enabled throughout the cluster then all `Pods` should be
73+
able to do name resolution of `Services` automatically.
5374

54-
- Don't specify a `hostPort` for a Pod unless it is absolutely necessary. When you bind a Pod to a `hostPort`, it limits the number of places the Pod can be scheduled, because each <`hostIP`, `hostPort`, `protocol`> combination must be unique. If you don't specify the `hostIP` and `protocol` explicitly, Kubernetes will use `0.0.0.0` as the default `hostIP` and `TCP` as the default `protocol`.
75+
- Don't specify a `hostPort` for a Pod unless it is absolutely necessary. When you bind a Pod to a
76+
`hostPort`, it limits the number of places the Pod can be scheduled, because each <`hostIP`,
77+
`hostPort`, `protocol`> combination must be unique. If you don't specify the `hostIP` and
78+
`protocol` explicitly, Kubernetes will use `0.0.0.0` as the default `hostIP` and `TCP` as the
79+
default `protocol`.
5580

56-
If you only need access to the port for debugging purposes, you can use the [apiserver proxy](/docs/tasks/access-application-cluster/access-cluster/#manually-constructing-apiserver-proxy-urls) or [`kubectl port-forward`](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/).
81+
If you only need access to the port for debugging purposes, you can use the
82+
[apiserver proxy](/docs/tasks/access-application-cluster/access-cluster/#manually-constructing-apiserver-proxy-urls)
83+
or [`kubectl port-forward`](/docs/tasks/access-application-cluster/port-forward-access-application-cluster/).
5784

58-
If you explicitly need to expose a Pod's port on the node, consider using a [NodePort](/docs/concepts/services-networking/service/#type-nodeport) Service before resorting to `hostPort`.
85+
If you explicitly need to expose a Pod's port on the node, consider using a
86+
[NodePort](/docs/concepts/services-networking/service/#type-nodeport) Service before resorting to
87+
`hostPort`.
5988

6089
- Avoid using `hostNetwork`, for the same reasons as `hostPort`.
6190

62-
- Use [headless Services](/docs/concepts/services-networking/service/#headless-services) (which have a `ClusterIP` of `None`) for service discovery when you don't need `kube-proxy` load balancing.
91+
- Use [headless Services](/docs/concepts/services-networking/service/#headless-services)
92+
(which have a `ClusterIP` of `None`) for service discovery when you don't need `kube-proxy`
93+
load balancing.
6394

6495
## Using Labels
6596

66-
- Define and use [labels](/docs/concepts/overview/working-with-objects/labels/) that identify __semantic attributes__ of your application or Deployment, such as `{ app.kubernetes.io/name: MyApp, tier: frontend, phase: test, deployment: v3 }`. You can use these labels to select the appropriate Pods for other resources; for example, a Service that selects all `tier: frontend` Pods, or all `phase: test` components of `app.kubernetes.io/name: MyApp`. See the [guestbook](https://github.com/kubernetes/examples/tree/master/guestbook/) app for examples of this approach.
67-
68-
A Service can be made to span multiple Deployments by omitting release-specific labels from its selector. When you need to update a running service without downtime, use a [Deployment](/docs/concepts/workloads/controllers/deployment/).
69-
70-
A desired state of an object is described by a Deployment, and if changes to that spec are _applied_, the deployment controller changes the actual state to the desired state at a controlled rate.
71-
72-
- Use the [Kubernetes common labels](/docs/concepts/overview/working-with-objects/common-labels/) for common use cases. These standardized labels enrich the metadata in a way that allows tools, including `kubectl` and [dashboard](/docs/tasks/access-application-cluster/web-ui-dashboard), to work in an interoperable way.
73-
74-
- You can manipulate labels for debugging. Because Kubernetes controllers (such as ReplicaSet) and Services match to Pods using selector labels, removing the relevant labels from a Pod will stop it from being considered by a controller or from being served traffic by a Service. If you remove the labels of an existing Pod, its controller will create a new Pod to take its place. This is a useful way to debug a previously "live" Pod in a "quarantine" environment. To interactively remove or add labels, use [`kubectl label`](/docs/reference/generated/kubectl/kubectl-commands#label).
97+
- Define and use [labels](/docs/concepts/overview/working-with-objects/labels/) that identify
98+
__semantic attributes__ of your application or Deployment, such as `{ app.kubernetes.io/name:
99+
MyApp, tier: frontend, phase: test, deployment: v3 }`. You can use these labels to select the
100+
appropriate Pods for other resources; for example, a Service that selects all `tier: frontend`
101+
Pods, or all `phase: test` components of `app.kubernetes.io/name: MyApp`.
102+
See the [guestbook](https://github.com/kubernetes/examples/tree/master/guestbook/) app
103+
for examples of this approach.
104+
105+
A Service can be made to span multiple Deployments by omitting release-specific labels from its
106+
selector. When you need to update a running service without downtime, use a
107+
[Deployment](/docs/concepts/workloads/controllers/deployment/).
108+
109+
A desired state of an object is described by a Deployment, and if changes to that spec are
110+
_applied_, the deployment controller changes the actual state to the desired state at a controlled
111+
rate.
112+
113+
- Use the [Kubernetes common labels](/docs/concepts/overview/working-with-objects/common-labels/)
114+
for common use cases. These standardized labels enrich the metadata in a way that allows tools,
115+
including `kubectl` and [dashboard](/docs/tasks/access-application-cluster/web-ui-dashboard), to
116+
work in an interoperable way.
117+
118+
- You can manipulate labels for debugging. Because Kubernetes controllers (such as ReplicaSet) and
119+
Services match to Pods using selector labels, removing the relevant labels from a Pod will stop
120+
it from being considered by a controller or from being served traffic by a Service. If you remove
121+
the labels of an existing Pod, its controller will create a new Pod to take its place. This is a
122+
useful way to debug a previously "live" Pod in a "quarantine" environment. To interactively remove
123+
or add labels, use [`kubectl label`](/docs/reference/generated/kubectl/kubectl-commands#label).
75124

76125
## Using kubectl
77126

78-
- Use `kubectl apply -f <directory>`. This looks for Kubernetes configuration in all `.yaml`, `.yml`, and `.json` files in `<directory>` and passes it to `apply`.
79-
80-
- Use label selectors for `get` and `delete` operations instead of specific object names. See the sections on [label selectors](/docs/concepts/overview/working-with-objects/labels/#label-selectors) and [using labels effectively](/docs/concepts/cluster-administration/manage-deployment/#using-labels-effectively).
81-
82-
- Use `kubectl create deployment` and `kubectl expose` to quickly create single-container Deployments and Services. See [Use a Service to Access an Application in a Cluster](/docs/tasks/access-application-cluster/service-access-application-cluster/) for an example.
127+
- Use `kubectl apply -f <directory>`. This looks for Kubernetes configuration in all `.yaml`,
128+
`.yml`, and `.json` files in `<directory>` and passes it to `apply`.
83129

130+
- Use label selectors for `get` and `delete` operations instead of specific object names. See the
131+
sections on [label selectors](/docs/concepts/overview/working-with-objects/labels/#label-selectors)
132+
and [using labels effectively](/docs/concepts/cluster-administration/manage-deployment/#using-labels-effectively).
84133

134+
- Use `kubectl create deployment` and `kubectl expose` to quickly create single-container
135+
Deployments and Services.
136+
See [Use a Service to Access an Application in a Cluster](/docs/tasks/access-application-cluster/service-access-application-cluster/)
137+
for an example.
85138

0 commit comments

Comments
 (0)