K3S Cluster and Frigate NVR: Running Containers and Accessing Coral Mini PCIe Accelerator
In this article, we will discuss how to run a K3S cluster with several containers, one of which is Frigate NVR for object detection. We will also cover how to access the Coral Mini PCIe accelerator when using containers moved from a Home Assistant OS setup.
Prerequisites
Before we begin, make sure you have the following:
- A Raspberry Pi or any other device that supports K3S installation
- A Coral Mini PCIe accelerator
- A working Home Assistant OS setup with Frigate NVR and the Coral Mini PCIe accelerator installed
Moving Containers to K3S Cluster
To move the containers from Home Assistant OS to the K3S cluster, follow these steps:
- Backup the Frigate NVR container and the Coral Mini PCIe accelerator container
- Export the containers as tar files
- Transfer the tar files to the K3S cluster
- Import the tar files to the K3S cluster
Running Containers on K3S Cluster
To run the containers on the K3S cluster, follow these steps:
- Create a K3S cluster using the Raspberry Pi or any other supported device
- Create a new namespace for the Frigate NVR and Coral Mini PCIe accelerator containers
- Deploy the Frigate NVR and Coral Mini PCIe accelerator containers to the K3S cluster
Accessing the Coral Mini PCIe Accelerator
To access the Coral Mini PCIe accelerator from the Frigate NVR container, follow these steps:
- Create a PCIe passthrough for the Coral Mini PCIe accelerator
- Attach the PCIe passthrough to the Frigate NVR container
- Configure the Frigate NVR container to use the Coral Mini PCIe accelerator
Code Blocks
Here are some code blocks that demonstrate the commands used in this article:
# Backup the Frigate NVR container
docker commit [container_name] [new_image_name]
docker save -o frigate.tar [new_image_name]
# Export the Coral Mini PCIe accelerator container
docker export [container_name] > coral.tar
# Transfer the tar files to the K3S cluster
scp frigate.tar coral.tar [k3s_cluster_ip]:/path/to/destination
# Import the tar files to the K3S cluster
cd /path/to/destination
docker load -i frigate.tar
docker load -i coral.tar
# Create a new namespace for the Frigate NVR and Coral Mini PCIe accelerator containers
kubectl create namespace frigate
# Deploy the Frigate NVR and Coral Mini PCIe accelerator containers to the K3S cluster
kubectl apply -f frigate-deployment.yaml -n frigate
kubectl apply -f coral-daemonset.yaml -n frigate
# Create a PCIe passthrough for the Coral Mini PCIe accelerator
kubectl edit configmap kubelet -n kube-system
# Attach the PCIe passthrough to the Frigate NVR container
kubectl patch daemonset [frigate_daemonset_name] -n frigate --type='json' -p='[{"op": "add", "path": "/spec/template/spec/containers/0/devices", "value": [{"name": "coral", "hostPath": "/dev/coral"}]}]'
# Configure the Frigate NVR container to use the Coral Mini PCIe accelerator
kubectl edit deployment [frigate_deployment_name] -n frigate
In this article, we have discussed how to run a K3S cluster with several containers, one of which is Frigate NVR for object detection. We have also covered how to access the Coral Mini PCIe accelerator when using containers moved from a Home Assistant OS setup. By following the steps outlined in this article, you can successfully run Frigate NVR and the Coral Mini PCIe accelerator on a K3S cluster.