Skip to content

Commit 8cd302d

Browse files
committed
upating the pod affinity example OCPBUGS-17959
1 parent a0787c8 commit 8cd302d

3 files changed

+43
-20
lines changed

modules/nw-metallb-operator-setting-pod-priority-affinity.adoc

+33-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
[id="nw-metallb-operator-setting-pod-priority-affinity_{context}"]
66
= Configuring pod priority and pod affinity in a MetalLB deployment
77

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.
99

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.
1111

1212
.Prerequisites
1313

1414
* You are logged in as a user with `cluster-admin` privileges.
1515

1616
* You have installed the MetalLB Operator.
1717

18+
* You have started the MetalLB Operator on your cluster.
19+
1820
.Procedure
19-
. Create a `PriorityClass` custom resource, such as `myPriorityClass.yaml`, to configure the priority level. This example uses a high-priority class:
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:
2022
+
2123
[source,yaml]
2224
----
@@ -34,7 +36,7 @@ value: 1000000
3436
$ oc apply -f myPriorityClass.yaml
3537
----
3638

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:
3840
+
3941
[source,yaml]
4042
----
@@ -46,19 +48,27 @@ metadata:
4648
spec:
4749
logLevel: debug
4850
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
5159
speakerConfig:
5260
priorityClassName: high-priority
53-
runtimeClassName: myclass
54-
affinity:
61+
affinity:
5562
podAffinity:
5663
requiredDuringSchedulingIgnoredDuringExecution:
5764
- labelSelector:
5865
matchLabels:
5966
app: metallb
6067
topologyKey: kubernetes.io/hostname
6168
----
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.
6272

6373
. Apply the `MetalLB` custom resource configuration:
6474
+
@@ -68,16 +78,27 @@ $ oc apply -f MetalLBPodConfig.yaml
6878
----
6979

7080
.Verification
71-
* To view the priority class that you assigned to pods in a namespace, run the following command, replacing `<namespace>` with your target namespace:
81+
* To view the priority class that you assigned to pods in the `metallb-system` namespace, run the following command:
7282
+
7383
[source,bash]
7484
----
75-
$ oc get pods -n <namespace> -o custom-columns=NAME:.metadata.name,PRIORITY:.spec.priorityClassName
85+
$ oc get pods -n metallb-system -o custom-columns=NAME:.metadata.name,PRIORITY:.spec.priorityClassName
86+
----
87+
+
88+
.Example output
89+
+
90+
[source,terminal]
91+
----
92+
NAME PRIORITY
93+
controller-584f5c8cd8-5zbvg high-priority
94+
metallb-operator-controller-manager-9c8d9985-szkqg <none>
95+
metallb-operator-webhook-server-c895594d4-shjgx <none>
96+
speaker-dddf7 high-priority
7697
----
7798

78-
* 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:
79100
+
80101
[source,bash]
81102
----
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
83104
----

modules/nw-metallb-operator-setting-runtimeclass.adoc

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[id="nw-metallb-operator-setting-runtimeclass_{context}"]
66
= Configuring a container runtime class in a MetalLB deployment
77

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.
99

1010
.Prerequisites
1111

@@ -21,7 +21,7 @@ You can optionally assign a container runtime class to `controller` and `speaker
2121
apiVersion: node.k8s.io/v1
2222
kind: RuntimeClass
2323
metadata:
24-
name: myclass
24+
name: myclass
2525
handler: myconfiguration
2626
----
2727

@@ -32,7 +32,7 @@ handler: myconfiguration
3232
$ oc apply -f myRuntimeClass.yaml
3333
----
3434

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:
3636
+
3737
[source,yaml]
3838
----
@@ -47,12 +47,12 @@ spec:
4747
runtimeClassName: myclass
4848
annotations: <1>
4949
controller: demo
50-
speakerConfig:
50+
speakerConfig:
5151
runtimeClassName: myclass
5252
annotations: <1>
5353
speaker: demo
5454
----
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.
5656

5757
. Apply the `MetalLB` custom resource configuration:
5858
+

networking/metallb/metallb-operator-install.adoc

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ include::modules/nw-metallb-operator-deployment-specifications-for-metallb.adoc[
2626
// Deployment specs to limit speaker pods to specific nodes
2727
include::modules/nw-metallb-operator-limit-speaker-to-nodes.adoc[leveloffset=+2]
2828

29-
// Deployment specs to set pod priority and pod ffinity
29+
// Deployment specs to set RuntimeClass
30+
include::modules/nw-metallb-operator-setting-runtimeclass.adoc[leveloffset=+2]
31+
32+
// Deployment specs to set pod priority and pod affinity
3033
include::modules/nw-metallb-operator-setting-pod-priority-affinity.adoc[leveloffset=+2]
3134

3235
// Deployment specs to set pod CPU limits
3336
include::modules/nw-metallb-operator-setting-pod-CPU-limits.adoc[leveloffset=+2]
3437

35-
// Deployment specs to set RuntimeClass
36-
include::modules/nw-metallb-operator-setting-runtimeclass.adoc[leveloffset=+2]
38+
3739

3840
[role="_additional-resources"]
3941
[id="additional-resources_metallb-operator-install"]

0 commit comments

Comments
 (0)