Assigning an application to a specific node (node affinity)
There are some use cases where Kubernetes clusters have different node pools with different specs, such as the following:
- Stateful applications
- Backend applications
- Frontend applications
Let's reschedule the nginx deployment to a dedicated node pool:
- To get the nodes list, run the following command:
$ kubectl get nodes
The preceding command gives the following output:
Figure 5.3 – Node pools list
- Next, let's check a node under the
gke-kubectl-lab-we-app-poolname. Run the following command:$ kubectl describe node gke-kubectl-lab-we-app-pool-1302ab74-pg34
The output of the preceding command is as shown in the following screenshot:
Figure 5.4 – Node labels
- There, we have a
node-pool=web-applabel, which is the same for all nodes of thegke-kubectl-lab-we-app-poolpool. - Let's update the
deployment.yamlfile with thenodeAffinityrule, so thenginxapplication...