Files
rancher-docs/assets/js/eaf2a302.eaa09e9e.js
T

1 line
8.8 KiB
JavaScript

"use strict";(self.webpackChunkrancher_docs=self.webpackChunkrancher_docs||[]).push([[45422],{3905:(e,n,t)=>{t.d(n,{Zo:()=>p,kt:()=>g});var o=t(67294);function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?r(Object(t),!0).forEach((function(n){a(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):r(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function l(e,n){if(null==e)return{};var t,o,a=function(e,n){if(null==e)return{};var t,o,a={},r=Object.keys(e);for(o=0;o<r.length;o++)t=r[o],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(o=0;o<r.length;o++)t=r[o],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var s=o.createContext({}),d=function(e){var n=o.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},p=function(e){var n=d(e.components);return o.createElement(s.Provider,{value:n},e.children)},c={inlineCode:"code",wrapper:function(e){var n=e.children;return o.createElement(o.Fragment,{},n)}},u=o.forwardRef((function(e,n){var t=e.components,a=e.mdxType,r=e.originalType,s=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),u=d(t),g=a,h=u["".concat(s,".").concat(g)]||u[g]||c[g]||r;return t?o.createElement(h,i(i({ref:n},p),{},{components:t})):o.createElement(h,i({ref:n},p))}));function g(e,n){var t=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=t.length,i=new Array(r);i[0]=u;var l={};for(var s in n)hasOwnProperty.call(n,s)&&(l[s]=n[s]);l.originalType=e,l.mdxType="string"==typeof e?e:a,i[1]=l;for(var d=2;d<r;d++)i[d]=t[d];return o.createElement.apply(null,i)}return o.createElement.apply(null,t)}u.displayName="MDXCreateElement"},71835:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>s,contentTitle:()=>i,default:()=>h,frontMatter:()=>r,metadata:()=>l,toc:()=>d});var o=t(87462),a=(t(67294),t(3905));const r={title:"Working with Taints and Tolerations"},i=void 0,l={unversionedId:"explanations/integrations-in-rancher/logging/taints-and-tolerations",id:"version-2.5/explanations/integrations-in-rancher/logging/taints-and-tolerations",title:"Working with Taints and Tolerations",description:'"Tainting" a Kubernetes node causes pods to repel running on that node.',source:"@site/versioned_docs/version-2.5/explanations/integrations-in-rancher/logging/taints-and-tolerations.md",sourceDirName:"explanations/integrations-in-rancher/logging",slug:"/explanations/integrations-in-rancher/logging/taints-and-tolerations",permalink:"/v2.5/explanations/integrations-in-rancher/logging/taints-and-tolerations",draft:!1,editUrl:"https://github.com/rancher/rancher-docs/edit/main/versioned_docs/version-2.5/explanations/integrations-in-rancher/logging/taints-and-tolerations.md",tags:[],version:"2.5",lastUpdatedAt:1670452794,formattedLastUpdatedAt:"Dec 7, 2022",frontMatter:{title:"Working with Taints and Tolerations"},sidebar:"tutorialSidebar",previous:{title:"rancher-logging Helm Chart Options",permalink:"/v2.5/explanations/integrations-in-rancher/logging/logging-helm-chart-options"},next:{title:"Custom Resource Configuration",permalink:"/v2.5/pages-for-subheaders/custom-resource-configuration"}},s={},d=[{value:"Default Implementation in Rancher&#39;s Logging Stack",id:"default-implementation-in-ranchers-logging-stack",level:3},{value:"Adding NodeSelector Settings and Tolerations for Custom Taints",id:"adding-nodeselector-settings-and-tolerations-for-custom-taints",level:3}],p=e=>function(n){return console.warn("Component "+e+" was not imported, exported, or provided by MDXProvider as global scope"),(0,a.kt)("div",n)},c=p("Tabs"),u=p("TabItem"),g={toc:d};function h(e){let{components:n,...t}=e;return(0,a.kt)("wrapper",(0,o.Z)({},g,t,{components:n,mdxType:"MDXLayout"}),(0,a.kt)("p",null,'"Tainting" a Kubernetes node causes pods to repel running on that node.'),(0,a.kt)("p",null,"Unless the pods have a ",(0,a.kt)("inlineCode",{parentName:"p"},"toleration")," for that node's taint, they will run on other nodes in the cluster."),(0,a.kt)("p",null,(0,a.kt)("a",{parentName:"p",href:"https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/"},"Taints and tolerations")," can work in conjunction with the ",(0,a.kt)("inlineCode",{parentName:"p"},"nodeSelector")," ",(0,a.kt)("a",{parentName:"p",href:"https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector"},"field")," within the ",(0,a.kt)("inlineCode",{parentName:"p"},"PodSpec"),", which enables the ",(0,a.kt)("em",{parentName:"p"},"opposite")," effect of a taint."),(0,a.kt)("p",null,"Using ",(0,a.kt)("inlineCode",{parentName:"p"},"nodeSelector")," gives pods an affinity towards certain nodes."),(0,a.kt)("p",null,"Both provide choice for the what node(s) the pod will run on."),(0,a.kt)("ul",null,(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("a",{parentName:"li",href:"#default-implementation-in-rancher-s-logging-stack"},"Default Implementation in Rancher's Logging Stack")),(0,a.kt)("li",{parentName:"ul"},(0,a.kt)("a",{parentName:"li",href:"#adding-nodeselector-settings-and-tolerations-for-custom-taints"},"Adding NodeSelector Settings and Tolerations for Custom Taints"))),(0,a.kt)("h3",{id:"default-implementation-in-ranchers-logging-stack"},"Default Implementation in Rancher's Logging Stack"),(0,a.kt)(c,{mdxType:"Tabs"},(0,a.kt)(u,{value:"Rancher v2.5.8+",mdxType:"TabItem"},(0,a.kt)("p",null,"By default, Rancher taints all Linux nodes with ",(0,a.kt)("inlineCode",{parentName:"p"},"cattle.io/os=linux"),", and does not taint Windows nodes.\nThe logging stack pods have ",(0,a.kt)("inlineCode",{parentName:"p"},"tolerations")," for this taint, which enables them to run on Linux nodes.\nMoreover, most logging stack pods run on Linux only and have a ",(0,a.kt)("inlineCode",{parentName:"p"},"nodeSelector")," added to ensure they run on Linux nodes.")),(0,a.kt)(u,{value:"Rancher before v2.5.8",mdxType:"TabItem"},(0,a.kt)("p",null,"By default, Rancher taints all Linux nodes with ",(0,a.kt)("inlineCode",{parentName:"p"},"cattle.io/os=linux"),", and does not taint Windows nodes.\nThe logging stack pods have ",(0,a.kt)("inlineCode",{parentName:"p"},"tolerations")," for this taint, which enables them to run on Linux nodes.\nMoreover, we can populate the ",(0,a.kt)("inlineCode",{parentName:"p"},"nodeSelector")," to ensure that our pods ",(0,a.kt)("em",{parentName:"p"},"only")," run on Linux nodes."))),(0,a.kt)("p",null,"This example Pod YAML file shows a nodeSelector being used with a toleration:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-yaml"},'apiVersion: v1\nkind: Pod\n# metadata...\nspec:\n # containers...\n tolerations:\n - key: cattle.io/os\n operator: "Equal"\n value: "linux"\n effect: NoSchedule\n nodeSelector:\n kubernetes.io/os: linux\n')),(0,a.kt)("p",null,"In the above example, we ensure that our pod only runs on Linux nodes, and we add a ",(0,a.kt)("inlineCode",{parentName:"p"},"toleration")," for the taint we have on all of our Linux nodes."),(0,a.kt)("p",null,"You can do the same with Rancher's existing taints, or with your own custom ones."),(0,a.kt)("h3",{id:"adding-nodeselector-settings-and-tolerations-for-custom-taints"},"Adding NodeSelector Settings and Tolerations for Custom Taints"),(0,a.kt)("p",null,"If you would like to add your own ",(0,a.kt)("inlineCode",{parentName:"p"},"nodeSelector")," settings, or if you would like to add ",(0,a.kt)("inlineCode",{parentName:"p"},"tolerations")," for additional taints, you can pass the following to the chart's values."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-yaml"},"tolerations:\n # insert tolerations...\nnodeSelector:\n # insert nodeSelector...\n")),(0,a.kt)("p",null,"These values will add both settings to the ",(0,a.kt)("inlineCode",{parentName:"p"},"fluentd"),", ",(0,a.kt)("inlineCode",{parentName:"p"},"fluentbit"),", and ",(0,a.kt)("inlineCode",{parentName:"p"},"logging-operator")," containers.\nEssentially, these are global settings for all pods in the logging stack."),(0,a.kt)("p",null,"However, if you would like to add tolerations for ",(0,a.kt)("em",{parentName:"p"},"only")," the ",(0,a.kt)("inlineCode",{parentName:"p"},"fluentbit")," container, you can add the following to the chart's values."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-yaml"},"fluentbit_tolerations:\n # insert tolerations list for fluentbit containers only...\n")))}h.isMDXComponent=!0}}]);