Debian Codegraph @

ansible_collections/kubernetes/core/docs/kubernetes.core.k8s_taint_module.rst

raw
1 .. _kubernetes.core.k8s_taint_module:
2
3
4 *************************
5 kubernetes.core.k8s_taint
6 *************************
7
8 **Taint a node in a Kubernetes/OpenShift cluster**
9
10
11 Version added: 2.3.0
12
13 .. contents::
14 :local:
15 :depth: 1
16
17
18 Synopsis
19 --------
20 - Taint allows a node to refuse Pod to be scheduled unless that Pod has a matching toleration.
21 - Untaint will remove taints from nodes as needed.
22
23
24
25 Requirements
26 ------------
27 The below requirements are needed on the host that executes this module.
28
29 - python >= 3.9
30 - kubernetes >= 24.2.0
31
32
33 Parameters
34 ----------
35
36 .. raw:: html
37
38 <table border=0 cellpadding=0 class="documentation-table">
39 <tr>
40 <th colspan="2">Parameter</th>
41 <th>Choices/<font color="blue">Defaults</font></th>
42 <th width="100%">Comments</th>
43 </tr>
44 <tr>
45 <td colspan="2">
46 <div class="ansibleOptionAnchor" id="parameter-"></div>
47 <b>api_key</b>
48 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
49 <div style="font-size: small">
50 <span style="color: purple">string</span>
51 </div>
52 </td>
53 <td>
54 </td>
55 <td>
56 <div>Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.</div>
57 </td>
58 </tr>
59 <tr>
60 <td colspan="2">
61 <div class="ansibleOptionAnchor" id="parameter-"></div>
62 <b>ca_cert</b>
63 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
64 <div style="font-size: small">
65 <span style="color: purple">path</span>
66 </div>
67 </td>
68 <td>
69 </td>
70 <td>
71 <div>Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.</div>
72 <div style="font-size: small; color: darkgreen"><br/>aliases: ssl_ca_cert</div>
73 </td>
74 </tr>
75 <tr>
76 <td colspan="2">
77 <div class="ansibleOptionAnchor" id="parameter-"></div>
78 <b>client_cert</b>
79 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
80 <div style="font-size: small">
81 <span style="color: purple">path</span>
82 </div>
83 </td>
84 <td>
85 </td>
86 <td>
87 <div>Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.</div>
88 <div style="font-size: small; color: darkgreen"><br/>aliases: cert_file</div>
89 </td>
90 </tr>
91 <tr>
92 <td colspan="2">
93 <div class="ansibleOptionAnchor" id="parameter-"></div>
94 <b>client_key</b>
95 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
96 <div style="font-size: small">
97 <span style="color: purple">path</span>
98 </div>
99 </td>
100 <td>
101 </td>
102 <td>
103 <div>Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.</div>
104 <div style="font-size: small; color: darkgreen"><br/>aliases: key_file</div>
105 </td>
106 </tr>
107 <tr>
108 <td colspan="2">
109 <div class="ansibleOptionAnchor" id="parameter-"></div>
110 <b>context</b>
111 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
112 <div style="font-size: small">
113 <span style="color: purple">string</span>
114 </div>
115 </td>
116 <td>
117 </td>
118 <td>
119 <div>The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.</div>
120 </td>
121 </tr>
122 <tr>
123 <td colspan="2">
124 <div class="ansibleOptionAnchor" id="parameter-"></div>
125 <b>host</b>
126 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
127 <div style="font-size: small">
128 <span style="color: purple">string</span>
129 </div>
130 </td>
131 <td>
132 </td>
133 <td>
134 <div>Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.</div>
135 </td>
136 </tr>
137 <tr>
138 <td colspan="2">
139 <div class="ansibleOptionAnchor" id="parameter-"></div>
140 <b>impersonate_groups</b>
141 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
142 <div style="font-size: small">
143 <span style="color: purple">list</span>
144 / <span style="color: purple">elements=string</span>
145 </div>
146 <div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
147 </td>
148 <td>
149 </td>
150 <td>
151 <div>Group(s) to impersonate for the operation.</div>
152 <div>Can also be specified via K8S_AUTH_IMPERSONATE_GROUPS environment. Example: Group1,Group2</div>
153 </td>
154 </tr>
155 <tr>
156 <td colspan="2">
157 <div class="ansibleOptionAnchor" id="parameter-"></div>
158 <b>impersonate_user</b>
159 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
160 <div style="font-size: small">
161 <span style="color: purple">string</span>
162 </div>
163 <div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
164 </td>
165 <td>
166 </td>
167 <td>
168 <div>Username to impersonate for the operation.</div>
169 <div>Can also be specified via K8S_AUTH_IMPERSONATE_USER environment.</div>
170 </td>
171 </tr>
172 <tr>
173 <td colspan="2">
174 <div class="ansibleOptionAnchor" id="parameter-"></div>
175 <b>kubeconfig</b>
176 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
177 <div style="font-size: small">
178 <span style="color: purple">raw</span>
179 </div>
180 </td>
181 <td>
182 </td>
183 <td>
184 <div>Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the Kubernetes client will attempt to load the default configuration file from <em>~/.kube/config</em>. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.</div>
185 <div>Multiple Kubernetes config file can be provided using separator &#x27;;&#x27; for Windows platform or &#x27;:&#x27; for others platforms.</div>
186 <div>The kubernetes configuration can be provided as dictionary. This feature requires a python kubernetes client version &gt;= 17.17.0. Added in version 2.2.0.</div>
187 </td>
188 </tr>
189 <tr>
190 <td colspan="2">
191 <div class="ansibleOptionAnchor" id="parameter-"></div>
192 <b>name</b>
193 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
194 <div style="font-size: small">
195 <span style="color: purple">string</span>
196 / <span style="color: red">required</span>
197 </div>
198 </td>
199 <td>
200 </td>
201 <td>
202 <div>The name of the node.</div>
203 </td>
204 </tr>
205 <tr>
206 <td colspan="2">
207 <div class="ansibleOptionAnchor" id="parameter-"></div>
208 <b>no_proxy</b>
209 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
210 <div style="font-size: small">
211 <span style="color: purple">string</span>
212 </div>
213 <div style="font-style: italic; font-size: small; color: darkgreen">added in 2.3.0</div>
214 </td>
215 <td>
216 </td>
217 <td>
218 <div>The comma separated list of hosts/domains/IP/CIDR that shouldn&#x27;t go through proxy. Can also be specified via K8S_AUTH_NO_PROXY environment variable.</div>
219 <div>Please note that this module does not pick up typical proxy settings from the environment (e.g. NO_PROXY).</div>
220 <div>This feature requires kubernetes&gt;=19.15.0. When kubernetes library is less than 19.15.0, it fails even no_proxy set in correct.</div>
221 <div>example value is &quot;localhost,.local,.example.com,127.0.0.1,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16&quot;</div>
222 </td>
223 </tr>
224 <tr>
225 <td colspan="2">
226 <div class="ansibleOptionAnchor" id="parameter-"></div>
227 <b>password</b>
228 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
229 <div style="font-size: small">
230 <span style="color: purple">string</span>
231 </div>
232 </td>
233 <td>
234 </td>
235 <td>
236 <div>Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.</div>
237 <div>Please read the description of the <code>username</code> option for a discussion of when this option is applicable.</div>
238 </td>
239 </tr>
240 <tr>
241 <td colspan="2">
242 <div class="ansibleOptionAnchor" id="parameter-"></div>
243 <b>persist_config</b>
244 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
245 <div style="font-size: small">
246 <span style="color: purple">boolean</span>
247 </div>
248 </td>
249 <td>
250 <ul style="margin: 0; padding: 0"><b>Choices:</b>
251 <li>no</li>
252 <li>yes</li>
253 </ul>
254 </td>
255 <td>
256 <div>Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.</div>
257 <div>When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.</div>
258 <div>Default to false.</div>
259 <div>Please note that the current version of the k8s python client library does not support setting this flag to True yet.</div>
260 <div>The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169</div>
261 </td>
262 </tr>
263 <tr>
264 <td colspan="2">
265 <div class="ansibleOptionAnchor" id="parameter-"></div>
266 <b>proxy</b>
267 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
268 <div style="font-size: small">
269 <span style="color: purple">string</span>
270 </div>
271 </td>
272 <td>
273 </td>
274 <td>
275 <div>The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.</div>
276 <div>Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).</div>
277 </td>
278 </tr>
279 <tr>
280 <td colspan="2">
281 <div class="ansibleOptionAnchor" id="parameter-"></div>
282 <b>proxy_headers</b>
283 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
284 <div style="font-size: small">
285 <span style="color: purple">dictionary</span>
286 </div>
287 <div style="font-style: italic; font-size: small; color: darkgreen">added in 2.0.0</div>
288 </td>
289 <td>
290 </td>
291 <td>
292 <div>The Header used for the HTTP proxy.</div>
293 <div>Documentation can be found here <a href='https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers'>https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html?highlight=proxy_headers#urllib3.util.make_headers</a>.</div>
294 </td>
295 </tr>
296 <tr>
297 <td class="elbow-placeholder"></td>
298 <td colspan="1">
299 <div class="ansibleOptionAnchor" id="parameter-"></div>
300 <b>basic_auth</b>
301 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
302 <div style="font-size: small">
303 <span style="color: purple">string</span>
304 </div>
305 </td>
306 <td>
307 </td>
308 <td>
309 <div>Colon-separated username:password for basic authentication header.</div>
310 <div>Can also be specified via K8S_AUTH_PROXY_HEADERS_BASIC_AUTH environment.</div>
311 </td>
312 </tr>
313 <tr>
314 <td class="elbow-placeholder"></td>
315 <td colspan="1">
316 <div class="ansibleOptionAnchor" id="parameter-"></div>
317 <b>proxy_basic_auth</b>
318 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
319 <div style="font-size: small">
320 <span style="color: purple">string</span>
321 </div>
322 </td>
323 <td>
324 </td>
325 <td>
326 <div>Colon-separated username:password for proxy basic authentication header.</div>
327 <div>Can also be specified via K8S_AUTH_PROXY_HEADERS_PROXY_BASIC_AUTH environment.</div>
328 </td>
329 </tr>
330 <tr>
331 <td class="elbow-placeholder"></td>
332 <td colspan="1">
333 <div class="ansibleOptionAnchor" id="parameter-"></div>
334 <b>user_agent</b>
335 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
336 <div style="font-size: small">
337 <span style="color: purple">string</span>
338 </div>
339 </td>
340 <td>
341 </td>
342 <td>
343 <div>String representing the user-agent you want, such as foo/1.0.</div>
344 <div>Can also be specified via K8S_AUTH_PROXY_HEADERS_USER_AGENT environment.</div>
345 </td>
346 </tr>
347
348 <tr>
349 <td colspan="2">
350 <div class="ansibleOptionAnchor" id="parameter-"></div>
351 <b>replace</b>
352 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
353 <div style="font-size: small">
354 <span style="color: purple">boolean</span>
355 </div>
356 </td>
357 <td>
358 <ul style="margin: 0; padding: 0"><b>Choices:</b>
359 <li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
360 <li>yes</li>
361 </ul>
362 </td>
363 <td>
364 <div>If <code>true</code>, allow taints to be replaced.</div>
365 </td>
366 </tr>
367 <tr>
368 <td colspan="2">
369 <div class="ansibleOptionAnchor" id="parameter-"></div>
370 <b>state</b>
371 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
372 <div style="font-size: small">
373 <span style="color: purple">string</span>
374 </div>
375 </td>
376 <td>
377 <ul style="margin: 0; padding: 0"><b>Choices:</b>
378 <li><div style="color: blue"><b>present</b>&nbsp;&larr;</div></li>
379 <li>absent</li>
380 </ul>
381 </td>
382 <td>
383 <div>Determines whether to add or remove taints.</div>
384 </td>
385 </tr>
386 <tr>
387 <td colspan="2">
388 <div class="ansibleOptionAnchor" id="parameter-"></div>
389 <b>taints</b>
390 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
391 <div style="font-size: small">
392 <span style="color: purple">list</span>
393 / <span style="color: purple">elements=dictionary</span>
394 / <span style="color: red">required</span>
395 </div>
396 </td>
397 <td>
398 </td>
399 <td>
400 <div>List containing the taints.</div>
401 </td>
402 </tr>
403 <tr>
404 <td class="elbow-placeholder"></td>
405 <td colspan="1">
406 <div class="ansibleOptionAnchor" id="parameter-"></div>
407 <b>effect</b>
408 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
409 <div style="font-size: small">
410 <span style="color: purple">string</span>
411 </div>
412 </td>
413 <td>
414 <ul style="margin: 0; padding: 0"><b>Choices:</b>
415 <li>NoSchedule</li>
416 <li>NoExecute</li>
417 <li>PreferNoSchedule</li>
418 </ul>
419 </td>
420 <td>
421 <div>The effect of the taint on Pods that do not tolerate the taint.</div>
422 <div>Required when <em>state=present</em>.</div>
423 </td>
424 </tr>
425 <tr>
426 <td class="elbow-placeholder"></td>
427 <td colspan="1">
428 <div class="ansibleOptionAnchor" id="parameter-"></div>
429 <b>key</b>
430 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
431 <div style="font-size: small">
432 <span style="color: purple">string</span>
433 </div>
434 </td>
435 <td>
436 </td>
437 <td>
438 <div>The taint key to be applied to a node.</div>
439 </td>
440 </tr>
441 <tr>
442 <td class="elbow-placeholder"></td>
443 <td colspan="1">
444 <div class="ansibleOptionAnchor" id="parameter-"></div>
445 <b>value</b>
446 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
447 <div style="font-size: small">
448 <span style="color: purple">string</span>
449 </div>
450 </td>
451 <td>
452 </td>
453 <td>
454 <div>The taint value corresponding to the taint key.</div>
455 </td>
456 </tr>
457
458 <tr>
459 <td colspan="2">
460 <div class="ansibleOptionAnchor" id="parameter-"></div>
461 <b>username</b>
462 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
463 <div style="font-size: small">
464 <span style="color: purple">string</span>
465 </div>
466 </td>
467 <td>
468 </td>
469 <td>
470 <div>Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.</div>
471 <div>Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the <span class='module'>community.okd.k8s_auth</span> module, as that might do what you need.</div>
472 </td>
473 </tr>
474 <tr>
475 <td colspan="2">
476 <div class="ansibleOptionAnchor" id="parameter-"></div>
477 <b>validate_certs</b>
478 <a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
479 <div style="font-size: small">
480 <span style="color: purple">boolean</span>
481 </div>
482 </td>
483 <td>
484 <ul style="margin: 0; padding: 0"><b>Choices:</b>
485 <li>no</li>
486 <li>yes</li>
487 </ul>
488 </td>
489 <td>
490 <div>Whether or not to verify the API server&#x27;s SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.</div>
491 <div style="font-size: small; color: darkgreen"><br/>aliases: verify_ssl</div>
492 </td>
493 </tr>
494 </table>
495 <br/>
496
497
498 Notes
499 -----
500
501 .. note::
502 - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file.
503
504
505
506 Examples
507 --------
508
509 .. code-block:: yaml
510
511 - name: Taint node "foo"
512 kubernetes.core.k8s_taint:
513 state: present
514 name: foo
515 taints:
516 - effect: NoExecute
517 key: "key1"
518
519 - name: Taint node "foo"
520 kubernetes.core.k8s_taint:
521 state: present
522 name: foo
523 taints:
524 - effect: NoExecute
525 key: "key1"
526 value: "value1"
527 - effect: NoSchedule
528 key: "key1"
529 value: "value1"
530
531 - name: Remove taint from "foo".
532 kubernetes.core.k8s_taint:
533 state: absent
534 name: foo
535 taints:
536 - effect: NoExecute
537 key: "key1"
538 value: "value1"
539
540
541
542 Return Values
543 -------------
544 Common return values are documented `here <https://docs.ansible.com/ansible/latest/reference_appendices/common_return_values.html#common-return-values>`_, the following are the fields unique to this module:
545
546 .. raw:: html
547
548 <table border=0 cellpadding=0 class="documentation-table">
549 <tr>
550 <th colspan="2">Key</th>
551 <th>Returned</th>
552 <th width="100%">Description</th>
553 </tr>
554 <tr>
555 <td colspan="2">
556 <div class="ansibleOptionAnchor" id="return-"></div>
557 <b>result</b>
558 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
559 <div style="font-size: small">
560 <span style="color: purple">complex</span>
561 </div>
562 </td>
563 <td>success</td>
564 <td>
565 <div>The tainted Node object. Will be empty in the case of a deletion.</div>
566 <br/>
567 </td>
568 </tr>
569 <tr>
570 <td class="elbow-placeholder">&nbsp;</td>
571 <td colspan="1">
572 <div class="ansibleOptionAnchor" id="return-"></div>
573 <b>api_version</b>
574 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
575 <div style="font-size: small">
576 <span style="color: purple">string</span>
577 </div>
578 </td>
579 <td>success</td>
580 <td>
581 <div>The versioned schema of this representation of an object.</div>
582 <br/>
583 </td>
584 </tr>
585 <tr>
586 <td class="elbow-placeholder">&nbsp;</td>
587 <td colspan="1">
588 <div class="ansibleOptionAnchor" id="return-"></div>
589 <b>kind</b>
590 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
591 <div style="font-size: small">
592 <span style="color: purple">string</span>
593 </div>
594 </td>
595 <td>success</td>
596 <td>
597 <div>Represents the REST resource this object represents.</div>
598 <br/>
599 </td>
600 </tr>
601 <tr>
602 <td class="elbow-placeholder">&nbsp;</td>
603 <td colspan="1">
604 <div class="ansibleOptionAnchor" id="return-"></div>
605 <b>metadata</b>
606 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
607 <div style="font-size: small">
608 <span style="color: purple">complex</span>
609 </div>
610 </td>
611 <td>success</td>
612 <td>
613 <div>Standard object metadata. Includes name, namespace, annotations, labels, etc.</div>
614 <br/>
615 </td>
616 </tr>
617 <tr>
618 <td class="elbow-placeholder">&nbsp;</td>
619 <td colspan="1">
620 <div class="ansibleOptionAnchor" id="return-"></div>
621 <b>spec</b>
622 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
623 <div style="font-size: small">
624 <span style="color: purple">complex</span>
625 </div>
626 </td>
627 <td>success</td>
628 <td>
629 <div>Specific attributes of the object. Will vary based on the <em>api_version</em> and <em>kind</em>.</div>
630 <br/>
631 </td>
632 </tr>
633 <tr>
634 <td class="elbow-placeholder">&nbsp;</td>
635 <td colspan="1">
636 <div class="ansibleOptionAnchor" id="return-"></div>
637 <b>status</b>
638 <a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
639 <div style="font-size: small">
640 <span style="color: purple">complex</span>
641 </div>
642 </td>
643 <td>success</td>
644 <td>
645 <div>Current status details for the object.</div>
646 <br/>
647 </td>
648 </tr>
649
650 </table>
651 <br/><br/>
652
653
654 Status
655 ------
656
657
658 Authors
659 ~~~~~~~
660
661 - Alina Buzachis (@alinabuzachis)