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:
- Next, let's check a node under the
gke-kubectl-lab-we-app-pool
name. 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:
- There, we have a
node-pool=web-app
label, which is the same for all nodes of thegke-kubectl-lab-we-app-pool
pool. - Let's update the
deployment.yaml
file with thenodeAffinity
rule, so thenginx
application...