is there a way to tell kubectl that my pods should only deployed on a certain instance pool?
For example:
nodeSelector:
pool: poolname
Assumed i created already my pool with something like:
gcloud container node-pools create poolname --cluster=cluster-1 --num-nodes=10 --machine-type=n1-highmem-32
Ok, i found out a solution:
gcloud creates a label for the pool name. In my manifest i just dropped that under the node selector. Very easy.
Here comes my manifest.yaml: i deploy ipyparallel with kubernetes
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ipengine
spec:
replicas: 1
template:
metadata:
labels:
app: ipengine
spec:
containers:
- name: ipengine
image: <imageaddr.>
args:
- ipengine
- --ipython-dir=/tmp/config/
- --location=ipcontroller.default.svc.cluster.local
- --log-level=0
resources:
requests:
cpu: 1
#memory: 3Gi
nodeSelector:
#<labelname>:value
cloud.google.com/gke-nodepool: pool-highcpu32
You can also use taints and tolerations. That way, you don't have to know/hardcode the specific pool name, but simply that it will have the taint high-cpu
, for example. Then you give your pods a tolerance for that taint, and they can schedule on that target pool.
That allows you to have multiple pools, or to have HA pool deployment, where you can migrate from one pool to another by changing the taints on the pools.
The gotcha here, however, is that while a toleration allows pods to schedule on a tainted pool, it won't prevent them from scheduling elsewhere. So, you've need to taint pool-a
with taint-a
, and pool-b
with taint-b
, and give pods for pool-a
and pool-b
the proper taints to keep them out of eachother's pools.