You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
= Configuring pod priority and pod affinity in a MetalLB deployment
7
7
8
-
You can optionally assign pod priority and pod affinity rules to `controller` and `speaker` pods by configuring the `MetalLB` custom resource. The pod priority indicates the relative importance of a pod on a node and schedules the pod based on this priority. Set a high priority on your `controller` or `speaker` pod to ensure scheduling priority over other pods on the node.
8
+
You can optionally assign pod priority and pod affinity rules to `controller` and `speaker` pods by configuring the `MetalLB` custom resource. The pod priority indicates the relative importance of a pod on a node and schedules the pod based on this priority. Set a high priority on your `controller` or `speaker` pod to ensure scheduling priority over other pods on the node.
9
9
10
-
Pod affinity manages relationships among pods. Assign pod affinity to the `controller` or `speaker` pods to control on what node the scheduler places the pod in the context of pod relationships. For example, you can allow pods with logically related workloads on the same node, or ensure pods with conflicting workloads are on separate nodes.
10
+
Pod affinity manages relationships among pods. Assign pod affinity to the `controller` or `speaker` pods to control on what node the scheduler places the pod in the context of pod relationships. For example, you can use pod affinity rules to ensure that certain pods are located on the same node or nodes, which can help improve network communication and reduce latency between those components.
11
11
12
12
.Prerequisites
13
13
14
14
* You are logged in as a user with `cluster-admin` privileges.
15
15
16
16
* You have installed the MetalLB Operator.
17
17
18
+
* You have started the MetalLB Operator on your cluster.
19
+
18
20
.Procedure
19
-
. Create a `PriorityClass` custom resource, such as `myPriorityClass.yaml`, to configure the priority level. This example uses a high-priorityclass:
21
+
. Create a `PriorityClass` custom resource, such as `myPriorityClass.yaml`, to configure the priority level. This example defines a `PriorityClass` named `high-priority` with a value of `1000000`. Pods that are assigned this priority class are considered higher priority during scheduling compared to pods with lower priority classes:
20
22
+
21
23
[source,yaml]
22
24
----
@@ -34,7 +36,7 @@ value: 1000000
34
36
$ oc apply -f myPriorityClass.yaml
35
37
----
36
38
37
-
. Create a `MetalLB` custom resource, such as `MetalLBPodConfig.yaml`, to specify the `priorityClassName` and `podAffinity` values:
39
+
. Create a `MetalLB` custom resource, such as `MetalLBPodConfig.yaml`, to specify the `priorityClassName` and `podAffinity` values:
38
40
+
39
41
[source,yaml]
40
42
----
@@ -46,19 +48,27 @@ metadata:
46
48
spec:
47
49
logLevel: debug
48
50
controllerConfig:
49
-
priorityClassName: high-priority
50
-
runtimeClassName: myclass
51
+
priorityClassName: high-priority <1>
52
+
affinity:
53
+
podAffinity: <2>
54
+
requiredDuringSchedulingIgnoredDuringExecution:
55
+
- labelSelector:
56
+
matchLabels:
57
+
app: metallb
58
+
topologyKey: kubernetes.io/hostname
51
59
speakerConfig:
52
60
priorityClassName: high-priority
53
-
runtimeClassName: myclass
54
-
affinity:
61
+
affinity:
55
62
podAffinity:
56
63
requiredDuringSchedulingIgnoredDuringExecution:
57
64
- labelSelector:
58
65
matchLabels:
59
66
app: metallb
60
67
topologyKey: kubernetes.io/hostname
61
68
----
69
+
+
70
+
<1> Specifies the priority class for the MetalLB controller pods. In this case, it is set to `high-priority`.
71
+
<2> Specifies that you are configuring pod affinity rules. These rules dictate how pods are scheduled in relation to other pods or nodes. This configuration instructs the scheduler to schedule pods that have the label `app: metallb` onto nodes that share the same hostname. This helps to co-locate MetalLB-related pods on the same nodes, potentially optimizing network communication, latency, and resource usage between these pods.
62
72
63
73
. Apply the `MetalLB` custom resource configuration:
* To verify that the scheduler placed pods according to pod affinity rules, view the metadata for the pod's node by running the following command, replacing `<namespace>` with your target namespace:
99
+
* To verify that the scheduler placed pods according to pod affinity rules, view the metadata for the pod's node or nodes by running the following command:
79
100
+
80
101
[source,bash]
81
102
----
82
-
$ oc get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name -n <namespace>
103
+
$ oc get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name -n metallb-system
= Configuring a container runtime class in a MetalLB deployment
7
7
8
-
You can optionally assign a container runtime class to `controller` and `speaker` pods by configuring the `MetalLB` custom resource. For example, for Windows workloads, you can assign a Windows runtime class to the pod, which uses this runtime class for all containers in the pod.
8
+
You can optionally assign a container runtime class to `controller` and `speaker` pods by configuring the MetalLB custom resource. For example, for Windows workloads, you can assign a Windows runtime class to the pod, which uses this runtime class for all containers in the pod.
9
9
10
10
.Prerequisites
11
11
@@ -21,7 +21,7 @@ You can optionally assign a container runtime class to `controller` and `speaker
21
21
apiVersion: node.k8s.io/v1
22
22
kind: RuntimeClass
23
23
metadata:
24
-
name: myclass
24
+
name: myclass
25
25
handler: myconfiguration
26
26
----
27
27
@@ -32,7 +32,7 @@ handler: myconfiguration
32
32
$ oc apply -f myRuntimeClass.yaml
33
33
----
34
34
35
-
. Create a `MetalLB` custom resource, such as `MetalLBRuntime.yaml`, to specify the `runtimeClassName` value:
35
+
. Create a `MetalLB` custom resource, such as `MetalLBRuntime.yaml`, to specify the `runtimeClassName` value:
36
36
+
37
37
[source,yaml]
38
38
----
@@ -47,12 +47,12 @@ spec:
47
47
runtimeClassName: myclass
48
48
annotations: <1>
49
49
controller: demo
50
-
speakerConfig:
50
+
speakerConfig:
51
51
runtimeClassName: myclass
52
52
annotations: <1>
53
53
speaker: demo
54
54
----
55
-
<1> This example uses `annotations` to add metadata such as build release information or GitHub pull request information. You can populate annotations with characters not permitted in labels. However, you cannot use annotations to identify or select objects.
55
+
<1> This example uses `annotations` to add metadata such as build release information or GitHub pull request information. You can populate annotations with characters that are not permitted in labels. However, you cannot use annotations to identify or select objects.
56
56
57
57
. Apply the `MetalLB` custom resource configuration:
0 commit comments