Skip to content

Commit c431b28

Browse files
mtaufenk8s-ci-robot
authored andcommitted
update kubeletconfig docs for v1.10, beta (#7561)
1 parent fae89c5 commit c431b28

File tree

2 files changed

+85
-90
lines changed

2 files changed

+85
-90
lines changed

docs/tasks/administer-cluster/kubelet-config-file.md

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ title: Set Kubelet parameters via a config file
66
---
77

88
{% capture overview %}
9-
{% include feature-state-alpha.md %}
9+
{% include feature-state-beta.md %}
1010

11-
As of Kubernetes 1.8, a subset of the Kubelet's configuration parameters may be
12-
set via an on-disk config file, as a substitute for command-line flags. In the
13-
future, most of the existing command-line flags will be deprecated in favor of
14-
providing parameters via a config file, which simplifies node deployment.
11+
A subset of the Kubelet's configuration parameters may be
12+
set via an on-disk config file, as a substitute for command-line flags.
13+
This functionality is considered beta in v1.10.
14+
15+
Providing parameters via a config file is the recommended approach because
16+
it simplifies node deployment and configuration management.
1517

1618
{% endcapture %}
1719

1820
{% capture prerequisites %}
1921

20-
- A v1.8 or higher Kubelet binary must be installed.
22+
- A v1.10 or higher Kubelet binary must be installed for beta functionality.
2123

2224
{% endcapture %}
2325

@@ -27,24 +29,42 @@ providing parameters via a config file, which simplifies node deployment.
2729

2830
The subset of the Kubelet's configuration that can be configured via a file
2931
is defined by the `KubeletConfiguration` struct
30-
[here (v1alpha1)](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/apis/kubeletconfig/v1alpha1/types.go).
32+
[here (v1beta1)](https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/apis/kubeletconfig/v1beta1/types.go).
33+
3134
The configuration file must be a JSON or YAML representation of the parameters
32-
in this struct. Note that this structure, and thus the config file API,
33-
is still considered alpha and is not subject to stability guarantees.
35+
in this struct. Make sure the Kubelet has read permissions on the file.
36+
37+
Here is an example of what this file might look like:
38+
```
39+
kind: KubeletConfiguration
40+
apiVersion: kubelet.config.k8s.io/v1beta1
41+
evictionHard:
42+
memory.available: "200Mi"
43+
```
3444

35-
Create a file named `kubelet` in its own directory and make sure the directory
36-
and file are both readable by the Kubelet. You should write your intended
37-
Kubelet configuration in this `kubelet` file.
45+
In the example, the Kubelet is configured to evict Pods when available memory drops below 200Mi.
46+
All other Kubelet configuration values are left at their built-in defaults, unless overridden
47+
by flags. Command line flags which target the same value as a config file will override that value.
3848

3949
For a trick to generate a configuration file from a live node, see
4050
[Reconfigure a Node's Kubelet in a Live Cluster](/docs/tasks/administer-cluster/reconfigure-kubelet).
4151

4252
## Start a Kubelet process configured via the config file
4353

44-
Start the Kubelet with the `--init-config-dir` flag set to the location of the directory
45-
containing the `kubelet` file. The Kubelet will then load the parameters defined
46-
by `KubeletConfiguration` from the `kubelet` file, rather than from their
47-
associated command-line flags.
54+
Start the Kubelet with the `--config` flag set to the path of the Kubelet's config file.
55+
The Kubelet will then load its config from this file.
56+
57+
Note that command line flags which target the same value as a config file will override that value.
58+
This helps ensure backwards compatibility with the command-line API.
59+
60+
Note that relative file paths in the Kubelet config file are resolved relative to the
61+
location of the Kubelet config file, whereas relative paths in command line flags are resolved
62+
relative to the Kubelet's current working directory.
63+
64+
Note that some default values differ between command-line flags and the Kubelet config file.
65+
If `--config` is provided and the values are not specified via the command line, the
66+
defaults for the `KubeletConfiguration` version apply.
67+
In the above example, this version is `kubelet.config.k8s.io/v1beta1`.
4868

4969
{% endcapture %}
5070

@@ -53,16 +73,8 @@ associated command-line flags.
5373
## Relationship to Dynamic Kubelet Config
5474

5575
If you are using the [Dynamic Kubelet Configuration](/docs/tasks/administer-cluster/reconfigure-kubelet)
56-
feature, the configuration provided via `--init-config-dir` will be considered
57-
the "last known good" configuration by the automatic rollback mechanism.
58-
59-
Note that the layout of the files in the `--init-config-dir` mirrors the layout
60-
of data in the ConfigMaps used for Dynamic Kubelet Config; the file names are
61-
the same as the keys of the ConfigMap, and the file contents are JSON or YAML
62-
representations of the same structures. Today, the only pair is
63-
`kubelet:KubeletConfiguration`, though more may emerge in the future.
64-
See [Reconfigure a Node's Kubelet in a Live Cluster](/docs/tasks/administer-cluster/reconfigure-kubelet)
65-
for more information.
76+
feature, the combination of configuration provided via `--config` and any flags which override these values
77+
is considered the default "last known good" configuration by the automatic rollback mechanism.
6678

6779
{% endcapture %}
6880

docs/tasks/administer-cluster/reconfigure-kubelet.md

Lines changed: 47 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ Kubelet's configuration.
4545
3. Update the Kubelet's correspoinding Node object to use this ConfigMap.
4646

4747
Each Kubelet watches a configuration reference on its respective Node object.
48-
When this reference changes, the Kubelet downloads the new configuration and
49-
exits. For the feature to work correctly, you must be running a process manager
48+
When this reference changes, the Kubelet downloads the new configuration,
49+
updates a local reference to refer to the file, and exits.
50+
For the feature to work correctly, you must be running a process manager
5051
(like systemd) which will restart the Kubelet when it exits. When the Kubelet is
5152
restarted, it will begin using the new configuration.
5253

53-
The new configuration completely overrides the old configuration; unspecified
54-
fields in the new configuration will receive their canonical default values.
55-
Some CLI flags do not have an associated configuration field, and will not be
56-
affected by the new configuration. These fields are defined by the KubeletFlags
57-
structure, [here](https://github.com/kubernetes/kubernetes/blob/master/cmd/kubelet/app/options/options.go).
54+
The new configuration completely overrides configuration provided by `--config`,
55+
and is overridden by command-line flags. Unspecified values in the new configuration
56+
will receive default values appropriate to the configuration version
57+
(e.g. `kubelet.config.k8s.io/v1beta1`), unless overridden by flags.
5858

59-
The status of the Node's Kubelet configuration is reported via the `ConfigOK`
59+
The status of the Node's Kubelet configuration is reported via the `KubeletConfigOK`
6060
condition in the Node status. Once you have updated a Node to use the new
6161
ConfigMap, you can observe this condition to confirm that the Node is using the
6262
intended configuration. A table describing the possible conditions can be found
@@ -95,13 +95,13 @@ and you will simply edit a copy of this file (which, as a best practice, should
9595
live in version control) while creating the first Kubelet ConfigMap. Today,
9696
however, the Kubelet is still bootstrapped with command-line flags. Fortunately,
9797
there is a dirty trick you can use to generate a config file containing a Node's
98-
current configuration. The trick involves hitting the Kubelet server's `configz`
98+
current configuration. The trick involves accessing the Kubelet server's `configz`
9999
endpoint via the kubectl proxy. This endpoint, in its current implementation, is
100100
intended to be used only as a debugging aid, which is part of why this is a
101-
dirty trick. There is ongoing work to improve the endpoint, and in the future
102-
this will be a less "dirty" operation. This trick also requires the `jq` command
103-
to be installed on your machine, for unpacking and editing the JSON response
104-
from the endpoint.
101+
dirty trick. The endpoint may be improved in the future, but until then
102+
it should not be relied on for production scenarios.
103+
This trick also requires the `jq` command to be installed on your machine,
104+
for unpacking and editing the JSON response from the endpoint.
105105

106106
Do the following to generate the file:
107107

@@ -112,12 +112,12 @@ configz endpoint:
112112

113113
```
114114
$ export NODE_NAME=the-name-of-the-node-you-are-reconfiguring
115-
$ curl -sSL http://localhost:8001/api/v1/proxy/nodes/${NODE_NAME}/configz | jq '.kubeletconfig|.kind="KubeletConfiguration"|.apiVersion="kubeletconfig/v1alpha1"' > kubelet_configz_${NODE_NAME}
115+
$ curl -sSL http://localhost:8001/api/v1/proxy/nodes/${NODE_NAME}/configz | jq '.kubeletconfig|.kind="KubeletConfiguration"|.apiVersion="kubelet.config.k8s.io/v1beta1"' > kubelet_configz_${NODE_NAME}
116116
```
117117

118118
Note that we have to manually add the `kind` and `apiVersion` to the downloaded
119119
object, as these are not reported by the configz endpoint. This is one of the
120-
limitations of the endpoint that is planned to be fixed in the future.
120+
limitations of the endpoint.
121121

122122
### Edit the configuration file
123123

@@ -209,29 +209,29 @@ Be sure to specify all three of `name`, `namespace`, and `uid`.
209209
### Observe that the Node begins using the new configuration
210210

211211
Retrieve the Node with `kubectl get node ${NODE_NAME} -o yaml`, and look for the
212-
`ConfigOK` condition in `status.conditions`. You should see the message
212+
`KubeletConfigOK` condition in `status.conditions`. You should see the message
213213
`Using current (UID: CONFIG_MAP_UID)` when the Kubelet starts using the new
214214
configuration.
215215

216216
For convenience, you can use the following command (using `jq`) to filter down
217-
to the `ConfigOK` condition:
217+
to the `KubeletConfigOK` condition:
218218

219219
```
220-
$ kubectl get no ${NODE_NAME} -o json | jq '.status.conditions|map(select(.type=="ConfigOK"))'
220+
$ kubectl get no ${NODE_NAME} -o json | jq '.status.conditions|map(select(.type=="KubeletConfigOK"))'
221221
[
222222
{
223223
"lastHeartbeatTime": "2017-09-20T18:08:29Z",
224224
"lastTransitionTime": "2017-09-20T18:08:17Z",
225-
"message": "using current (UID: \"2ebc8d1a-9e2a-11e7-a8dd-42010a800006\")",
225+
"message": "using current: /api/v1/namespaces/kube-system/configmaps/my-node-config-gkt4c2m4b2",
226226
"reason": "passing all checks",
227227
"status": "True",
228-
"type": "ConfigOK"
228+
"type": "KubeletConfigOK"
229229
}
230230
]
231231
```
232232

233233
If something goes wrong, you may see one of several different error conditions,
234-
detailed in the Table of ConfigOK Conditions, below. When this happens, you
234+
detailed in the table of KubeletConfigOK conditions, below. When this happens, you
235235
should check the Kubelet's log for more details.
236236

237237
### Edit the configuration file again
@@ -282,16 +282,16 @@ the following, with `name` and `uid` substituted as necessary:
282282
```
283283
configSource:
284284
configMapRef:
285-
name: NEW_CONFIG_MAP_NAME
285+
name: ${NEW_CONFIG_MAP_NAME}
286286
namespace: kube-system
287-
uid: NEW_CONFIG_MAP_UID
287+
uid: ${NEW_CONFIG_MAP_UID}
288288
```
289289

290290
### Observe that the Kubelet is using the new configuration
291291

292292
Once more, retrieve the Node with `kubectl get node ${NODE_NAME} -o yaml`, and
293-
look for the `ConfigOK` condition in `status.conditions`. You should the message
294-
`Using current (UID: NEW_CONFIG_MAP_UID)` when the Kubelet starts using the
293+
look for the `KubeletConfigOK` condition in `status.conditions`. You should see the message
294+
`using current: /api/v1/namespaces/kube-system/configmaps/${NEW_CONFIG_MAP_NAME}` when the Kubelet starts using the
295295
new configuration.
296296

297297
### Deauthorize your Node fom reading the old ConfigMap
@@ -327,9 +327,8 @@ remove the `spec.configSource` subfield.
327327

328328
### Observe that the Node is using its local default configuration
329329

330-
After removing this subfield, you should eventually observe that the ConfigOK
331-
condition's message reverts to either `using current (default)` or
332-
`using current (init)`, depending on how the Node was provisioned.
330+
After removing this subfield, you should eventually observe that the KubeletConfigOK
331+
condition's message reverts to `using current: local`.
333332

334333
### Deauthorize your Node fom reading the old ConfigMap
335334

@@ -366,9 +365,9 @@ Here is an example command that uses `kubectl patch`:
366365
kubectl patch node ${NODE_NAME} -p "{\"spec\":{\"configSource\":{\"configMapRef\":{\"name\":\"${CONFIG_MAP_NAME}\",\"namespace\":\"kube-system\",\"uid\":\"${CONFIG_MAP_UID}\"}}}}"
367366
```
368367

369-
## Understanding ConfigOK Conditions
368+
## Understanding KubeletConfigOK Conditions
370369

371-
The following table describes several of the `ConfigOK` Node conditions you
370+
The following table describes several of the `KubeletConfigOK` Node conditions you
372371
might encounter in a cluster that has Dynamic Kubelet Config enabled. If you
373372
observe a condition with `status=False`, you should check the Kubelet log for
374373
more error details by searching for the message or reason text.
@@ -383,49 +382,33 @@ more error details by searching for the message or reason text.
383382
<th>Status</th>
384383
</tr>
385384
<tr>
386-
<td><p>using current (default)</p></td>
387-
<td><p>current is set to the local default, and no init config was provided</p></td>
385+
<td><p>using current: local</p></td>
386+
<td><p>when the config source is nil, the Kubelet uses its local config</p></td>
388387
<td><p>True</p></td>
389388
</tr>
390389
<tr>
391-
<td><p>using current (init)</p></td>
392-
<td><p>current is set to the local default, and an init config was provided</p></td>
393-
<td><p>True</p></td>
394-
</tr>
395-
<tr>
396-
<td><p>using current (UID: CURRENT_CONFIG_MAP_UID)</p></td>
390+
<td><p>using current: /api/v1/namespaces/${CURRENT_CONFIG_MAP_NAMESPACE}/configmaps/${CURRENT_CONFIG_MAP_NAME}</p></td>
397391
<td><p>passing all checks</p></td>
398392
<td><p>True</p></td>
399393
</tr>
400394
<tr>
401-
<td><p>using last-known-good (default)</p></td>
402-
<td>
403-
<ul>
404-
<li>failed to load current (UID: CURRENT_CONFIG_MAP_UID)</li>
405-
<li>failed to parse current (UID: CURRENT_CONFIG_MAP_UID)</li>
406-
<li>failed to validate current (UID: CURRENT_CONFIG_MAP_UID)</li>
407-
</ul>
408-
</td>
409-
<td><p>False</p></td>
410-
</tr>
411-
<tr>
412-
<td><p>using last-known-good (init)</p></td>
395+
<td><p>using last-known-good: local</p></td>
413396
<td>
414397
<ul>
415-
<li>failed to load current (UID: CURRENT_CONFIG_MAP_UID)</li>
416-
<li>failed to parse current (UID: CURRENT_CONFIG_MAP_UID)</li>
417-
<li>failed to validate current (UID: CURRENT_CONFIG_MAP_UID)</li>
398+
<li>failed to load current: /api/v1/namespaces/${CURRENT_CONFIG_MAP_NAMESPACE}/configmaps/${CURRENT_CONFIG_MAP_NAME}</li>
399+
<li>failed to parse current: /api/v1/namespaces/${CURRENT_CONFIG_MAP_NAMESPACE}/configmaps/${CURRENT_CONFIG_MAP_NAME}</li>
400+
<li>failed to validate current: /api/v1/namespaces/${CURRENT_CONFIG_MAP_NAMESPACE}/configmaps/${CURRENT_CONFIG_MAP_NAME}</li>
418401
</ul>
419402
</td>
420403
<td><p>False</p></td>
421404
</tr>
422405
<tr>
423-
<td><p>using last-known-good (UID: LAST_KNOWN_GOOD_CONFIG_MAP_UID)</p></td>
406+
<td><p>using last-known-good: /api/v1/namespaces/${LAST_KNOWN_GOOD_CONFIG_MAP_NAMESPACE}/configmaps/${LAST_KNOWN_GOOD_CONFIG_MAP_NAME}</p></td>
424407
<td>
425408
<ul>
426-
<li>failed to load current (UID: CURRENT_CONFIG_MAP_UID)</li>
427-
<li>failed to parse current (UID: CURRENT_CONFIG_MAP_UID)</li>
428-
<li>failed to validate current (UID: CURRENT_CONFIG_MAP_UID)</li>
409+
<li>failed to load current: /api/v1/namespaces/${CURRENT_CONFIG_MAP_NAMESPACE}/configmaps/${CURRENT_CONFIG_MAP_NAME}</li>
410+
<li>failed to parse current: /api/v1/namespaces/${CURRENT_CONFIG_MAP_NAMESPACE}/configmaps/${CURRENT_CONFIG_MAP_NAME}</li>
411+
<li>failed to validate current: /api/v1/namespaces/${CURRENT_CONFIG_MAP_NAMESPACE}/configmaps/${CURRENT_CONFIG_MAP_NAME}</li>
429412
</ul>
430413
</td>
431414
<td><p>False</p></td>
@@ -451,15 +434,15 @@ more error details by searching for the message or reason text.
451434
<p>failed to sync, reason:</p>
452435
<ul>
453436
<li>failed to read Node from informer object cache</li>
454-
<li>failed to reset to local (default or init) config</li>
437+
<li>failed to reset to local config</li>
455438
<li>invalid NodeConfigSource, exactly one subfield must be non-nil, but all were nil</li>
456439
<li>invalid ObjectReference, all of UID, Name, and Namespace must be specified</li>
457-
<li>invalid ObjectReference, UID SOME_UID does not match UID of downloaded ConfigMap SOME_OTHER_UID</li>
458-
<li>failed to determine whether object with UID SOME_UID was already checkpointed</li>
459-
<li>failed to download ConfigMap with name SOME_NAME from namespace SOME_NAMESPACE</li>
460-
<li>failed to save config checkpoint for object with UID SOME_UID</li>
461-
<li>failed to set current config checkpoint to default</li>
462-
<li>failed to set current config checkpoint to object with UID SOME_UID</li>
440+
<li>invalid ConfigSource.ConfigMapRef.UID: ${UID} does not match ${API_PATH}.UID: ${UID_OF_CONFIG_MAP_AT_API_PATH}</li>
441+
<li>failed to determine whether object ${API_PATH} with UID ${UID} was already checkpointed</li>
442+
<li>failed to download ConfigMap with name ${NAME} from namespace ${NAMESPACE}</li>
443+
<li>failed to save config checkpoint for object ${API_PATH} with UID ${UID}</li>
444+
<li>failed to set current config checkpoint to local config</li>
445+
<li>failed to set current config checkpoint to object ${API_PATH} with UID ${UID}</li>
463446
</ul>
464447
</td>
465448
<td><p>False</p></td>

0 commit comments

Comments
 (0)