Kubernetes Quickstart
Estimated time: 6 minutes, 8 minutes with buffer.
Installing Tooling
We'll start by installing kubectl and k3d. kubectl is a command-line tool for managing kubernetes interfaces, and k3d is a lightweight wrapper to run k3s in Docker. Download and install the lateset release of kubectl using the folllowing commands:
Next, install the latest release of k3d using this command:
Creating and Configuring a Cluster
Now, you must create a cluster:
Then go ahead and check your context:
This should list the cluster you just created, but if not, run the following command to switch to the needed context:
In order to operate with acceleration, Kubernetes must also be set up with the AMD GPU Operator and Labeler plugins. You can install these using the following commands:
Then, go ahead and make your deployment manifest. Create a directory for your manifest and direct into it, then open up a deployment.yaml
file.
From there, paste in the following yaml:
You'll notice there are a few extra configurations we added. These are necessary to running the pod with GPU acceleration.
This specifies that the container requires 1 AMD GPU. You must explicitly request GPU resources so that Kubernetes can schedule the pod on a node with an available AMD GPU.
These definitions allow the cluster to use the necessary volumes from the host for utilizing the AMD GPUs.
These mounts correspond to the above volumes, allowing the container to access the GPU hardware.
This security context runs the containers in the pod as the group ID 110, the render group, which is necessary for PyTorch to detect the devices properly (PyTorch is used in the hello world container).
Continue by applying the manifest using the following:
This should take a few minutes to create the container. You can monitor the status here:
Once this output displays that STATUS
is Completed
, you're ready to check output. Running:
Should give an output of:
You'll notice that you only have one GPU. That's because, as covered earlier, we specified a resource limit of one. You may raise or lower this number as necessary.
Teardown
Navigate back to your base directory and remove your k8s-hello-world
folder:
Last updated