|
| 1 | +# Configure Workloads Scheduling |
| 2 | + |
| 3 | +In this workflow scenario, you'll deploy Confluent Platform to a multi-zone Kubernetes cluster, with Pod's Workload Scheduling configured. |
| 4 | + |
| 5 | +One of the things you can do to get the optimal performance out of Confluent components is to control how the component pods are scheduled on Kubernetes nodes. For example, you can configure pods not to be scheduled on the same node as other resource intensive applications, pods to be scheduled on dedicated nodes, or pods to be scheduled on the nodes with the most suitable hardware. |
| 6 | + |
| 7 | +Read more about Pod Scheduling in [Confluent Docs][1]. |
| 8 | + |
| 9 | + |
| 10 | +## Set the current tutorial directory |
| 11 | + |
| 12 | +Set the tutorial directory for this tutorial under the directory you downloaded |
| 13 | +the tutorial files: |
| 14 | + |
| 15 | +``` |
| 16 | +export TUTORIAL_HOME=<Tutorial directory>/scheduling/pod-scheduling |
| 17 | +``` |
| 18 | + |
| 19 | +## Deploy Confluent for Kubernetes |
| 20 | + |
| 21 | +This workflow scenario assumes you are using the namespace `confluent`. |
| 22 | + |
| 23 | +Set up the Helm Chart: |
| 24 | + |
| 25 | +``` |
| 26 | +helm repo add confluentinc https://packages.confluent.io/helm |
| 27 | +``` |
| 28 | + |
| 29 | +Install Confluent For Kubernetes using Helm: |
| 30 | + |
| 31 | +``` |
| 32 | +helm upgrade --install operator confluentinc/confluent-for-kubernetes -n confluent |
| 33 | +``` |
| 34 | + |
| 35 | +Check that the Confluent For Kubernetes pod comes up and is running: |
| 36 | + |
| 37 | +``` |
| 38 | +kubectl get pods |
| 39 | +``` |
| 40 | + |
| 41 | +## Configure |
| 42 | + |
| 43 | +### Set Required or Preferred |
| 44 | + |
| 45 | +Two types of affinity rules are supported: |
| 46 | + |
| 47 | +1. `requiredDuringSchedulingIgnoredDuringExecution` |
| 48 | +2. `preferredDuringSchedulingIgnoredDuringExecution` |
| 49 | + |
| 50 | +In `confluent-platform.yml`, `requiredDuringSchedulingIgnoredDuringExecution` is used. |
| 51 | + |
| 52 | +### Set the labelSelector |
| 53 | + |
| 54 | +`labelSelector` is used to find matching pods by label. This can be found by querying the pod: |
| 55 | + |
| 56 | +``` |
| 57 | +> kubectl describe pod/<pod-name> |
| 58 | +
|
| 59 | +# In the Labels section, key-value names are found. |
| 60 | +
|
| 61 | +Labels: app=zookeeper |
| 62 | + clusterId=confluent |
| 63 | + confluent-platform=true |
| 64 | + controller-revision-hash=zookeeper-75c664dbbf |
| 65 | + platform.confluent.io/type=zookeeper |
| 66 | + statefulset.kubernetes.io/pod-name=zookeeper-0 |
| 67 | + type=zookeeper |
| 68 | +``` |
| 69 | + |
| 70 | +To only apply this rule to zookeeper, set |
| 71 | + |
| 72 | +``` |
| 73 | +- labelSelector: |
| 74 | + matchExpressions: |
| 75 | + - key: app |
| 76 | + operator: In |
| 77 | + values: |
| 78 | + - zookeeper |
| 79 | +``` |
| 80 | + |
| 81 | + |
| 82 | +### Get the topologyKey |
| 83 | + |
| 84 | +The topology key is the label of the cluster node to specify the nodes to co-locate or avoid scheduling pods. This depends on the Kubernetes flavors such as cloud providers. To get the correct value, run: |
| 85 | + |
| 86 | +``` |
| 87 | +> kubectl get node |
| 88 | +
|
| 89 | +NAME STATUS ROLES AGE VERSION |
| 90 | +aks-agentpool-18842733-vmss000001 Ready agent 7h59m v1.24.6 |
| 91 | +aks-agentpool-18842733-vmss000003 Ready agent 154m v1.24.6 |
| 92 | +aks-agentpool-18842733-vmss000004 Ready agent 153m v1.24.6 |
| 93 | +``` |
| 94 | + |
| 95 | +And pick a node and describe it: |
| 96 | + |
| 97 | +``` |
| 98 | +> kubectl describe node/aks-agentpool-18842733-vmss000001 |
| 99 | +
|
| 100 | +Labels: agentpool=agentpool |
| 101 | + beta.kubernetes.io/arch=amd64 |
| 102 | + beta.kubernetes.io/instance-type=Standard_A8m_v2 |
| 103 | + beta.kubernetes.io/os=linux |
| 104 | + failure-domain.beta.kubernetes.io/region=japaneast |
| 105 | + failure-domain.beta.kubernetes.io/zone=japaneast-2 |
| 106 | + kubernetes.azure.com/agentpool=agentpool |
| 107 | + kubernetes.azure.com/cluster=MC_taku-test_taku-test_japaneast |
| 108 | + kubernetes.azure.com/kubelet-identity-client-id=f8663bd6-a676-4b9f-8cb7-f57bc43a92a7 |
| 109 | + kubernetes.azure.com/mode=system |
| 110 | + kubernetes.azure.com/node-image-version=AKSUbuntu-1804containerd-2023.01.10 |
| 111 | + kubernetes.azure.com/os-sku=Ubuntu |
| 112 | + kubernetes.azure.com/role=agent |
| 113 | + kubernetes.azure.com/storageprofile=managed |
| 114 | + kubernetes.azure.com/storagetier=Standard_LRS |
| 115 | + kubernetes.io/arch=amd64 |
| 116 | + kubernetes.io/hostname=aks-agentpool-18842733-vmss000001 |
| 117 | + kubernetes.io/os=linux |
| 118 | + kubernetes.io/role=agent |
| 119 | + node-role.kubernetes.io/agent= |
| 120 | + node.kubernetes.io/instance-type=Standard_A8m_v2 |
| 121 | + storageprofile=managed |
| 122 | + storagetier=Standard_LRS |
| 123 | + topology.disk.csi.azure.com/zone=japaneast-2 |
| 124 | + topology.kubernetes.io/region=japaneast |
| 125 | + topology.kubernetes.io/zone=japaneast-2 |
| 126 | +``` |
| 127 | + |
| 128 | +Select a key to use, for example, `topology.kubernetes.io/zone`. |
| 129 | + |
| 130 | + |
| 131 | +## Deploy Kafka Components |
| 132 | + |
| 133 | +To deploy Kafka components: |
| 134 | +``` |
| 135 | +kubectl apply -f $TUTORIAL_HOME/confluent-platform.yml |
| 136 | +``` |
| 137 | + |
| 138 | +If the changes aren't applied, run `kubectl delete pod/<pod-name>` to restart individual pods. |
| 139 | + |
| 140 | +## Tear Down |
| 141 | + |
| 142 | +To tear down the components, run: |
| 143 | +``` |
| 144 | +kubectl delete -f $TUTORIAL_HOME/confluent-platform.yml |
| 145 | +``` |
| 146 | + |
| 147 | +## Troubleshooting |
| 148 | + |
| 149 | +1. Pod is in a Pending state. |
| 150 | + |
| 151 | +Run `kubectl describe pod/<pod-name>` and see why the correct node is not assigned. |
| 152 | + |
| 153 | +2. Pod is not assigned to node due to `volume node affinity conflict`. |
| 154 | + |
| 155 | +Check the Persistent Volume and Persistent Volume Claim. (`kubectl get pv` or `kubectl get pvc`) Most likely multiple volumes already belong to the same node or zone. A quick forceful fix is by tearing down the YAML file, removing pods, removing PVC, removing PVs, and then deploy again. |
| 156 | + |
| 157 | + |
0 commit comments