What you’ll need
- MicroK8s installed locally.
- An ngrok account.
- kubectl and Helm 3.0.0+ installed on your local workstation.
- The ngrok Kubernetes Operator installed on your cluster.
- A reserved domain from the ngrok dashboard or API; this guide refers to it as
<NGROK_DOMAIN>.
Deploy a Kubernetes cluster with MicroK8s
Start by deploying a new single-node MicroK8s Kubernetes cluster in your chosen environment. That could be your local workstation, an IoT device, a virtual machine in the cloud, or any system running one of the supported Linux flavors.- Follow the MicroK8s get-started tutorial to install the binary for your target system. Once MicroK8s is installed, it automatically deploys a single-node Kubernetes cluster.
-
Run
microk8s status --wait-readyto check on the state of your MicroK8s cluster.If you seemicrok8s is ready, your new cluster is ready.
Install an example app
Now you need a domain and Kubernetes service to ingress traffic to.-
If you don’t have an ngrok static domain, create one.
Navigate to the Domains section of the ngrok dashboard and click Create Domain or New Domain.
This static domain, which will look like
example.ngrok.app, will be yourNGROK_DOMAINfor the remainder of this guide. Creating a subdomain on the ngrok network provides a public route to accept HTTP, HTTPS, and TLS traffic. -
Create a new Kubernetes manifest (
tinyllama.yaml) with the YAML below. This manifest defines the tinyllama demo LLM application from ngrok-samples/tinyllama (service and deployment), then configures the ngrok Kubernetes Operator to connect thetinyllamaservice to the ngrok edge via yourNGROK_DOMAIN.showLineNumbers -
Apply the
tinyllama.yamlmanifest to your MicroK8s cluster.
Configure the ngrok Kubernetes Operator
With your example app running alongside the ngrok Kubernetes Operator, you now need to configure the new Kubernetes Gateway API to route traffic arriving from outside the cluster onNGROK_DOMAIN to the tinyllama service.
First you’ll create a GatewayClass, which represents a class of cluster-level Gateways.
Then you’ll configure the Gateway with a listener, and an HTTPRoute to specify how the Gateway should route requests.
-
Create a new file called
gatewayclass.yamlon your workstation with the below YAML: -
Install the GatewayClass:
-
Create a new file named
tinyllama-gateway.yamlon your workstation with the below YAML, replacing<YOUR_NGROK_DOMAIN>:This YAML uses the Gateway API to first define a Gateway that allows north/south traffic to enter the cluster from external requests, then uses an HTTPRoute to terminate the connection at the pod running theshowLineNumberstinyllamaservice. -
Access your tinyllama demo app by navigating to your ngrok domain, for example,
https://<YOUR_NGROK_DOMAIN>. ngrok’s network and the ngrok Kubernetes Operator route traffic to your app from any device or external network.