ngrok Ingress Controller

The ngrok Ingress Controller for Kubernetes provides ingress-as-a-service to your Kubernetes applications by offloading traffic management, performance, and security to ngrok’s global network.

Because it leverages native Kubernetes tooling, you can configure the route, host, and downstream service via the standard Kubernetes Ingress object, and you can deploy it to your DigitalOcean Kubernetes (DOKS) cluster with a Helm chart.

Once deployed to your cluster, the Ingress Controller connects to ngrok’s cloud service, which provisions the resources necessary to provide the ingress—such as Web Application Firewalls, Global Server Load Balancers, local load balancers, and reverse proxies—in ngrok’s global network.

The ngrok Ingress Controller for Kubernetes equips you to serve apps and APIs without needing to configure networking details such as ELBs, IPs, network interfaces, or VPC routing, radically simplifying ingress into Kubernetes.

Creating an App using the Control Panel

Click the Deploy to DigitalOcean button to install a Kubernetes 1-Click Application. If you aren’t logged in, this link will prompt you to log in with your DigitalOcean account.

Deploy to DO

Creating an App using the API

In addition to creating ngrok Ingress Controller using the control panel, you can also use the DigitalOcean API. As an example, to create a 3 node DigitalOcean Kubernetes cluster made up of Basic Droplets in the SFO2 region, you can use the following doctl command. You need to authenticate with doctl with your API access token) and replace the $CLUSTER_NAME variable with the chosen name for your cluster in the command below.

doctl kubernetes clusters create --size s-4vcpu-8gb $CLUSTER_NAME --1-clicks ngrok-ingress-controller

Getting Started After Deploying ngrok Ingress Controller

Connect to your cluster

Follow these instructions to connect to your cluster with kubectl and doctl.

Confirm that the ngrok Ingress Controller is running

Run the steps below to confirm the Ingress Controller is running in your cluster.

Verify the Helm installation was successful

Run the following command:

helm ls -n ngrok-ingress-controller

The output looks similar to the following:

NAME                        NAMESPACE                   REVISION    UPDATED                                 STATUS      CHART                                   APP VERSION
ngrok-ingress-controller    ngrok-ingress-controller    1           2023-12-05 16:16:32.756868 -0600 CST    deployed    kubernetes-ingress-controller-0.12.1    0.10.1

The STATUS column value should be deployed.

Verify the ngrok Ingress Controller pods are up and running

Run the following command:

kubectl get pods -n ngrok-ingress-controller

The output looks similar to the following:

NAME                                                              READY   STATUS    RESTARTS   AGE
ngrok-ingress-controller-kubernetes-ingress-controller-manwpd5d   1/1     Running   0          33s

All pods should be in a READY state, and STATUS should be Running.

Add ngrok credentials

By default, the ngrok Ingress Controller looks for your authtoken and API key in the named secret: ngrok-ingress-controller-credentials

Please ensure that the secret exists in your cluster. To apply the secret to your cluster, create a file called creds.yaml with the contents below, entering your own API_KEY and AUTHTOKEN values.

apiVersion: v1
kind: Secret
metadata:
  name: ngrok-ingress-controller-credentials
  namespace: ngrok-ingress-controller
data:
  API_KEY: "YOUR-API-KEY"
  AUTHTOKEN: "YOUR-AUTHTOKEN"

Apply the manifest to your DOKS cluster by running the following:

kubectl apply -f creds.yaml

Deploy a sample application

You can now deploy an application to your DOKS cluster and configure ingress using the standard Ingress object.

Create a manifest.yml file with the following contents, replacing NGROK_DOMAIN with your ngrok domain name:

apiVersion: v1
kind: Service
metadata:
 name: game-2048
 namespace: ngrok-ingress-controller
spec:
 ports:
   - name: http
     port: 80
     targetPort: 80
 selector:
   app: game-2048
---
apiVersion: apps/v1
kind: Deployment
metadata:
 name: game-2048
 namespace: ngrok-ingress-controller
spec:
 replicas: 1
 selector:
   matchLabels:
     app: game-2048
 template:
   metadata:
     labels:
       app: game-2048
   spec:
     containers:
       - name: backend
         image: alexwhen/docker-2048
         ports:
           - name: http
             containerPort: 80
---
# ngrok Ingress Controller Configuration
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: game-2048-ingress
 namespace: ngrok-ingress-controller
spec:
 ingressClassName: ngrok
 rules:
   - host: NGROK_DOMAIN
     http:
       paths:
         - path: /
           pathType: Prefix
           backend:
             service:
               name: game-2048
               port:
                 number: 80

Apply the manifest to your DOKS cluster by running the following:

kubectl apply -f ngrok-manifest.yaml

Verify deployment

To confirm the manifest was successfully applied, go to the ngrok Dashboard and click Edge Configurations. You should see a new Edge Configuration for your cluster with the name matching your URL. For example, my-awesome-k8s-cluster.ngrok.app (1). Also note that some of your cluster configurations are presented in the dashboard as annotations (2).

Go to your ngrok domain in a web browser to test the deployment. You should see the 2048 game application running.