How to add a sidecar
The following sections describe where to declare sidecars in the Slurm Helm chart values for login and compute node pods. The chart exposes acontainers field on both pod types, along with supporting fields such as volumes and dnsConfig for further customization. The exact location of these configuration changes differs between login and compute pods.
Add a sidecar to a login pod
For login pods, add sidecars underlogin.containers.
The login pod configuration offers the following options:
Add a sidecar to a compute pod
To add sidecars to a compute pod, you must apply the configuration at the node level. Add sidecars undercompute.nodes.<nodeType>.containers, where <nodeType> represents a custom name assigned to a specific compute type.
Sidecar example: Knot Resolver
Knot Resolver is a full caching DNS resolver implementation. You can use it as a proxy to CoreDNS or as a direct replacement. This example shows how to use it as a proxy in a sidecar to improve DNS performance for jobs that involve web scraping. The process involves adding a sidecar container and a corresponding ConfigMap, then deploying both to the Kubernetes namespace. Follow these steps in order: define the sidecar in the Helm values, create the ConfigMap that backs it, and then deploy the ConfigMap before rolling out the chart changes.-
To add the Knot Resolver sidecar container, adjust the
containers,volumes,dnsPolicy, anddnsConfigfields as shown in the following example: -
Create the corresponding ConfigMap YAML file
knot-resolver-configmap.yamlwith the following contents:For morekresd.confconfiguration examples, see the Knot Resolver GitHub repository. -
Deploy the ConfigMap into the
slurmnamespace before deploying changes for the sidecars, as in the following example. The sidecar container mounts this ConfigMap on startup, so it must exist in the namespace before the compute pods are rolled out.If a ConfigMap with the same name already exists in the specified Kubernetes namespace, theapplycommand updates the existing file with the new configuration. If no such file exists,applycreates one. The-fflag specifies the file name to create or update. In this example, the file to create or update isknot-resolver-configmap.yaml. The-nflag specifies the Kubernetes namespace to create or update the file.
Test the Knot Resolver sidecar
With the sidecar container and its ConfigMap deployed, the next step is to confirm that the resolver is reachable from inside a compute pod and that Slurm itself is still healthy. To test if the DNS server is up and running, run thedig command within a Slurm compute node.
First, open a shell in a worker node in the slurmd container. In this example, the worker node is slurm-cpu-epyc-000-002.
To update the local package list and install the dnsutils package, which includes the dig command, run:
dig command:
kresd is working, the result resembles the following:
Example dig response
scontrol ping:
Sidecar example: Tailscale
Tailscale is a VPN service that makes your devices and applications reachable across networks. In this example, you attach your Slurm login node to your Tailscale network through a userspace sidecar so you can reach it from any device on that network. The procedure creates a Tailscale auth key, stores it as a Kubernetes Secret, configures the RBAC the sidecar needs to read that Secret, and registers the sidecar on the login pod through the Helm chart.- Log in to Tailscale’s admin console to create a reusable, ephemeral auth key for the machine. You use this auth key to authenticate the login node against the Tailscale network.
-
Create a Secret for the
TS_AUTHKEYthrough a YAML manifest, for examplets-secret.yaml. Replace[TS-AUTH-KEY]with the auth key you generated in the previous step. -
Add the Secret to the
slurmnamespace with the following command: -
Configure the RBAC surrounding the Secret to allow the sidecar to obtain the Secret. This requires you to edit three files:
rolebinding.yaml,role.yaml, andsa.yaml. If you cloned the Tailscale repository, you can find these files undertailscale/docs/k8s. Adjust the values in the files to match the following configuration:sa.yaml:sa.yamlrole.yaml:role.yamlrolebinding.yaml:rolebinding.yaml -
Deploy these manifests into the
slurmnamespace by running the following command: -
Edit the login node’s
containersfield to include the Tailscale sidecar. Set theserviceAccountNametotailscale, andautomountServiceAccountTokentotrue. The following example shows these edits in thecharts/slurm/values.yamlmanifest:charts/slurm/values.yaml - Deploy the sidecar.
Test the Tailscale sidecar
After you deploy the sidecar, the login node should appear in your Tailscale network and be reachable from any other device on that network. From a machine connected to the Tailscale network, you can check that the Slurm login node is now connected and present:Test with curl
ssh configured, you can test that with the following command: