There may be instances where you wish to launch Posit Workbench pods to specific nodes on your Kubernetes environment. The best option here would be to use placement constraints, which is discussed in more detail below:
https://docs.posit.co/ide/server-pro/admin/job_launcher/kubernetes_plugin.html
Example
There are a number of different Kubernetes labels that we can use to determine where a pod is launched, such as instance size, availability zone, region, compute type, etc. We can also manually label nodes, instead of using the default labels for more intricate architectures and workflows. As a straightforward example, let's say you wish to launch Kubernetes pods onto a particular AWS EC2 instance based on the size of the resource profile selected by the user.
First, we need to identify the labels available to us in our Kubernetes environment. To do so, you can run the following command:
kubectl get nodes --show-labels=true
Now that we see our labels, we can see that each Kubernetes node is labelled with the size of the EC2 instance, and we can use this as a reference to map our placement constraints. As an aside, if you use serverless compute (such as AWS EKS Fargate) you can specify different fargate profiles on which to launch resources to.
From there, we can point our resources to launch to the EC2 instance based on the node.kubernetes.io/instance-type label. An example of my values.yaml would look like this:
config:
server:
jupyter.conf:
session-cull-minutes: 120
session-shutdown-minutes: 10
launcher.kubernetes.resources.conf:
"small":
cpus: "2"
mem-mb: "6000"
placement-constraints: node.kubernetes.io/instance-type:t3.2xlarge
"medium":
cpus: "4"
mem-mb: "12000"
placement-constraints: node.kubernetes.io/instance-type:m4.10xlarge
"large":
cpus: "8"
mem-mb: "24000"
placement-constraints: node.kubernetes.io/instance-type:m6id.24xlarge
profiles:
launcher.kubernetes.profiles.conf:
"*":
resource-profiles: small,medium,large
placement-constraints:
- node.kubernetes.io/instance-type:t3.2xlarge
- node.kubernetes.io/instance-type:m4.10xlarge
- node.kubernetes.io/instance-type:m6id.24xlargeIn this example, every time a user selects a job size (either small, medium, or large), their Workbench pod will be sent to a particular EC2 node as specified in both our launcher.kubernetes.resources.conf and launcher.kubernetes.profiles.conf.