Running 3forge with Kubernetes¶
This guide will take you through installing Kubernetes and deploying AMI on a Kubernetes node. For information about distributed deployment, please see this article instead.
Setting up Kubernetes¶
If you have already installed Kubernetes, feel free to skip to configuration.
This guide is for Windows systems using Chocolatey. The same actions can be performed in Unix/Linux systems with minor adjustments to command line syntax. You will also need to have Docker Desktop installed.
-
If you don't already have it, install Chocolatey by pasting the following command into Powershell (in administrator mode):
-
Install Minikube and kubectl with the command:
-
Start Docker Desktop, and run the following command in your Powershell:
-
Then, use the command kubectl get nodes. Your powershell should look something like this:
You should now have a working Kubernetes cluster.
Configuration¶
-
Create an Image Pull Secret (Optional). To allow your Kubernetes cluster to pull your private Docker image, you must create a secret containing your Docker Hub credentials.
Run the following command, replacing the placeholders with your actual Docker Hub username and password or an access token. -
Create persistent directory on the Node. Before deploying k8s, you must create the following directory on the k8s node that will host the data. SSH into your chosen node and follow the steps:
First, list the nodes and choose which one you want to use:Launch a debug pod on the chosen node:Create the directory as needed:And finally, exit: -
Prepare Kubernetes manifests by creating a new folder named 'k8s' anywhere on your system, and add the following yaml files:
This bundles all Kubernetes resources together, which you can deploy with a single command.
This defines a
StorageClassfor local volumes.This defines local PersistentVolume (PV) that maps to the directory you created on the node (not necessary if using cloud storage).
This creates two types of services for network access:
-
Headless Service: provides unique DNS entry for each pod within the cluster for stable internal communication.
-
NodePort Service: exposes pod individually to external traffic on a static port on the host node.
A StatefulSet is used to manage stateful applications that provide each pod with a persistent and unique network identifier (e.g.,
ami-instance-0,ami-instance-1) and dedicated storage. -
-
Run the following command from the
k8sdirectory usingkustomize: -
Check the status of your pods. You should see them being created sequentially, from
ami-instance-0toami-instance-2:
Cleanup¶
Option 1: Delete only the workloads (keep the instance-volume bind). To do this, run the following commands from the k8s directory to delete only the services and pods:
/mnt/data/ami-0 will be orphaned but will remain on the node's disk:
