|
| 1 | +// Module included in the following assemblies: |
| 2 | +// logging/log_storage/cluster-logging-loki.adoc |
| 3 | + |
| 4 | +:_mod-docs-content-type: CONCEPT |
| 5 | +[id="logging-loki-pod-placement_{context}"] |
| 6 | += Loki pod placement |
| 7 | +You can control which nodes the Loki pods run on, and prevent other workloads from using those nodes, by using tolerations or node selectors on the pods. |
| 8 | + |
| 9 | +You can apply tolerations to the log store pods with the LokiStack custom resource (CR) and apply taints to a node with the node specification. A taint on a node is a `key:value` pair that instructs the node to repel all pods that do not allow the taint. Using a specific `key:value` pair that is not on other pods ensures that only the log store pods can run on that node. |
| 10 | + |
| 11 | +.Example LokiStack with node selectors |
| 12 | +[source,yaml] |
| 13 | +---- |
| 14 | +apiVersion: loki.grafana.com/v1 |
| 15 | +kind: LokiStack |
| 16 | +metadata: |
| 17 | + name: logging-loki |
| 18 | + namespace: openshift-logging |
| 19 | +spec: |
| 20 | +# ... |
| 21 | + template: |
| 22 | + compactor: # <1> |
| 23 | + nodeSelector: |
| 24 | + node-role.kubernetes.io/infra: "" # <2> |
| 25 | + distributor: |
| 26 | + nodeSelector: |
| 27 | + node-role.kubernetes.io/infra: "" |
| 28 | + gateway: |
| 29 | + nodeSelector: |
| 30 | + node-role.kubernetes.io/infra: "" |
| 31 | + indexGateway: |
| 32 | + nodeSelector: |
| 33 | + node-role.kubernetes.io/infra: "" |
| 34 | + ingester: |
| 35 | + nodeSelector: |
| 36 | + node-role.kubernetes.io/infra: "" |
| 37 | + querier: |
| 38 | + nodeSelector: |
| 39 | + node-role.kubernetes.io/infra: "" |
| 40 | + queryFrontend: |
| 41 | + nodeSelector: |
| 42 | + node-role.kubernetes.io/infra: "" |
| 43 | + ruler: |
| 44 | + nodeSelector: |
| 45 | + node-role.kubernetes.io/infra: "" |
| 46 | +# ... |
| 47 | +---- |
| 48 | + |
| 49 | +<1> Specifies the component pod type that applies to the node selector. |
| 50 | +<2> Specifies the pods that are moved to nodes containing the defined label. |
| 51 | + |
| 52 | +In the previous example configuration, all Loki pods are moved to nodes containing the `node-role.kubernetes.io/infra: ""` label. |
| 53 | + |
| 54 | + |
| 55 | +.Example LokiStack CR with node selectors and tolerations |
| 56 | +[source,yaml] |
| 57 | +---- |
| 58 | +apiVersion: loki.grafana.com/v1 |
| 59 | +kind: LokiStack |
| 60 | +metadata: |
| 61 | + name: logging-loki |
| 62 | + namespace: openshift-logging |
| 63 | +spec: |
| 64 | +# ... |
| 65 | + template: |
| 66 | + compactor: |
| 67 | + nodeSelector: |
| 68 | + node-role.kubernetes.io/infra: "" |
| 69 | + tolerations: |
| 70 | + - effect: NoSchedule |
| 71 | + key: node-role.kubernetes.io/infra |
| 72 | + value: reserved |
| 73 | + - effect: NoExecute |
| 74 | + key: node-role.kubernetes.io/infra |
| 75 | + value: reserved |
| 76 | + distributor: |
| 77 | + nodeSelector: |
| 78 | + node-role.kubernetes.io/infra: "" |
| 79 | + tolerations: |
| 80 | + - effect: NoSchedule |
| 81 | + key: node-role.kubernetes.io/infra |
| 82 | + value: reserved |
| 83 | + - effect: NoExecute |
| 84 | + key: node-role.kubernetes.io/infra |
| 85 | + value: reserved |
| 86 | + nodeSelector: |
| 87 | + node-role.kubernetes.io/infra: "" |
| 88 | + tolerations: |
| 89 | + - effect: NoSchedule |
| 90 | + key: node-role.kubernetes.io/infra |
| 91 | + value: reserved |
| 92 | + - effect: NoExecute |
| 93 | + key: node-role.kubernetes.io/infra |
| 94 | + value: reserved |
| 95 | + indexGateway: |
| 96 | + nodeSelector: |
| 97 | + node-role.kubernetes.io/infra: "" |
| 98 | + tolerations: |
| 99 | + - effect: NoSchedule |
| 100 | + key: node-role.kubernetes.io/infra |
| 101 | + value: reserved |
| 102 | + - effect: NoExecute |
| 103 | + key: node-role.kubernetes.io/infra |
| 104 | + value: reserved |
| 105 | + ingester: |
| 106 | + nodeSelector: |
| 107 | + node-role.kubernetes.io/infra: "" |
| 108 | + tolerations: |
| 109 | + - effect: NoSchedule |
| 110 | + key: node-role.kubernetes.io/infra |
| 111 | + value: reserved |
| 112 | + - effect: NoExecute |
| 113 | + key: node-role.kubernetes.io/infra |
| 114 | + value: reserved |
| 115 | + querier: |
| 116 | + nodeSelector: |
| 117 | + node-role.kubernetes.io/infra: "" |
| 118 | + tolerations: |
| 119 | + - effect: NoSchedule |
| 120 | + key: node-role.kubernetes.io/infra |
| 121 | + value: reserved |
| 122 | + - effect: NoExecute |
| 123 | + key: node-role.kubernetes.io/infra |
| 124 | + value: reserved |
| 125 | + queryFrontend: |
| 126 | + nodeSelector: |
| 127 | + node-role.kubernetes.io/infra: "" |
| 128 | + tolerations: |
| 129 | + - effect: NoSchedule |
| 130 | + key: node-role.kubernetes.io/infra |
| 131 | + value: reserved |
| 132 | + - effect: NoExecute |
| 133 | + key: node-role.kubernetes.io/infra |
| 134 | + value: reserved |
| 135 | + ruler: |
| 136 | + nodeSelector: |
| 137 | + node-role.kubernetes.io/infra: "" |
| 138 | + tolerations: |
| 139 | + - effect: NoSchedule |
| 140 | + key: node-role.kubernetes.io/infra |
| 141 | + value: reserved |
| 142 | + - effect: NoExecute |
| 143 | + key: node-role.kubernetes.io/infra |
| 144 | + value: reserved |
| 145 | + gateway: |
| 146 | + nodeSelector: |
| 147 | + node-role.kubernetes.io/infra: "" |
| 148 | + tolerations: |
| 149 | + - effect: NoSchedule |
| 150 | + key: node-role.kubernetes.io/infra |
| 151 | + value: reserved |
| 152 | + - effect: NoExecute |
| 153 | + key: node-role.kubernetes.io/infra |
| 154 | + value: reserved |
| 155 | +# ... |
| 156 | +---- |
| 157 | + |
| 158 | +To configure the `nodeSelector` and `tolerations` fields of the LokiStack (CR), you can use the [command]`oc explain` command to view the description and fields for a particular resource: |
| 159 | + |
| 160 | +[source,terminal] |
| 161 | +---- |
| 162 | +$ oc explain lokistack.spec.template |
| 163 | +---- |
| 164 | + |
| 165 | +.Example output |
| 166 | +[source,text] |
| 167 | +---- |
| 168 | +KIND: LokiStack |
| 169 | +VERSION: loki.grafana.com/v1 |
| 170 | +
|
| 171 | +RESOURCE: template <Object> |
| 172 | +
|
| 173 | +DESCRIPTION: |
| 174 | + Template defines the resource/limits/tolerations/nodeselectors per |
| 175 | + component |
| 176 | +
|
| 177 | +FIELDS: |
| 178 | + compactor <Object> |
| 179 | + Compactor defines the compaction component spec. |
| 180 | +
|
| 181 | + distributor <Object> |
| 182 | + Distributor defines the distributor component spec. |
| 183 | +... |
| 184 | +---- |
| 185 | + |
| 186 | +For more detailed information, you can add a specific field: |
| 187 | + |
| 188 | +[source,terminal] |
| 189 | +---- |
| 190 | +$ oc explain lokistack.spec.template.compactor |
| 191 | +---- |
| 192 | + |
| 193 | +.Example output |
| 194 | +[source,text] |
| 195 | +---- |
| 196 | +KIND: LokiStack |
| 197 | +VERSION: loki.grafana.com/v1 |
| 198 | +
|
| 199 | +RESOURCE: compactor <Object> |
| 200 | +
|
| 201 | +DESCRIPTION: |
| 202 | + Compactor defines the compaction component spec. |
| 203 | +
|
| 204 | +FIELDS: |
| 205 | + nodeSelector <map[string]string> |
| 206 | + NodeSelector defines the labels required by a node to schedule the |
| 207 | + component onto it. |
| 208 | +... |
| 209 | +---- |
0 commit comments