I have Kubernetes cluster, hosted on Google cloud platform, that running two deployments: app1
and app2
.
My cluster have two Node-Pools: pool1
and pool2
.
Deploying pods, from yaml file, like this:
kubectl apply -f ./app1.yaml
kubectl apply -f ./app2.yaml
Actualy, it deploy two pods to pool1
, which is the cluster "default-pool".
I want to change this behavior to deploy app2
to pool2
(and app1
to pool1
- as before, default). Looking to pseudo command like this:
kubectl apply -f ./app1.yaml
kubectl apply -f ./app2.yaml --pool=pool2
explicit give the pool name when publishing new pod.
How to do it right?
Thanks!
You need to have labels differentiating the nodes in each pool. Then look at pod affinity to bind pods to nodes with certain labels. If you have to have this off the command line I believe it would be possible via overrides it won't look nearly as pretty as your desired line
You can have two .yaml files for two deployments and you can select the node pool as follows.
nodeSelector:
nodeclass: pool1
Add the above code to your yaml file.