What you’ll need
- A DigitalOcean account.
- 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>.
Provision a new cluster on DigitalOcean with doctl
In this guide, the CLI is used as much as possible to showcase how tightly the ngrok Kubernetes Operator can integrate with DigitalOcean and how you might automate these steps in the future.
-
With
doctlinstalled, check node sizes and specs (they affect monthly pricing): -
Provision your cluster with the command below, replacing
NODE_SIZEandCLUSTER_NAMEwith your chosen size and a relevant name. - Now you can install the ngrok Kubernetes Operator to provide ingress to services. Check out the Operator installation doc for details on how to use Helm to install with your ngrok credentials.
Deploy an example app on your DigitalOcean-managed cluster
Explore how to add apps or services to your DigitalOcean-managed Kubernetes cluster. This guide uses the Bookinfo app from DigitalOcean’s sample Kubernetes apps repository.-
Clone the repository to your local workstation and
cdinto the new directory: -
Deploy the Bookinfo app to your cluster:
You should see your cluster create a handful of new services, then verify everything is running correctly with
kubectl get all -n bookinfo.
Configure the ngrok Kubernetes Operator
Your Bookinfo app is running, but you have no means of accessing it. You could usekubectl port-forward..., but that’s a fragile method of accessing your new app, and isn’t appropriate for production use.
Instead, finish configuring the ngrok Kubernetes Operator to direct incoming requests to the user-facing Bookinfo container.
The Bookinfo example uses the productpage service on port 9080; use that to configure the ngrok Kubernetes Operator.
-
Create a new file called
bookinfo-ingress.yamlon your local workstation. This configuration defines how the ngrok Kubernetes Operator routes traffic onNGROK_DOMAINto theproductpageservice on port9080.showLineNumbers -
Apply the new configuration to your cluster:
-
Navigate to
https://<NGROK_DOMAIN>in your browser to see your Bookinfo app. Click Normal user to explore; it’s a working Kubernetes app with secure ingress via the ngrok Kubernetes Operator.
Enable extra features of ngrok’s cloud service
To demonstrate ingress configuration and OAuth support, you can launch an observability stack (for example, Prometheus, Grafana, and Alertmanager) on your cluster.- In the DigitalOcean console, go to the Kubernetes Clusters dashboard and click the cluster you created.
- Click the Marketplace tab, find or search for Kubernetes Monitoring Stack, and click Install. Confirm your choice. In the background, DigitalOcean uses Helm to create a new integrated deployment for Prometheus, Grafana, and Alertmanager.
-
Create a new domain in the ngrok dashboard at
monitoring.<NGROK_DOMAIN>. -
Edit your
bookinfo-ingress.yamlfile to add the configuration below, which routes traffic onhttps://monitoring.NGROK_DOMAIN/to thekube-prometheus-stack-grafanaservice on port9090in your cluster.showLineNumbers -
Visit a URL like
https://monitoring.NGROK_DOMAIN/alertsto see data from Alertmanager. For security, restrict who can access your metrics and alerts. -
Edit your
bookinfo-ingress.yamlfile again to add OAuth, leaving the previous configurations untouched. Note the newannotationsfield and theNgrokTrafficPolicyCR.showLineNumbers -
Re-apply your configuration.
- When you open your demo app again, you’ll be asked to log in via Google. That’s a start, but what if you want to authenticate only yourself or colleagues?
-
You can use expressions and CEL interpolation to filter out and reject OAuth logins that don’t contain
example.com. Update theNgrokTrafficPolicyportion of your manifest after changingexample.comto your domain. - Check your deployed app again. If you log in with an email that doesn’t match your domain, ngrok rejects your request.
What’s next?
You’ve now used the open-source ngrok Kubernetes Operator to add public ingress to an example app on a Kubernetes cluster managed by DigitalOcean. Because ngrok abstracts ingress and middleware execution to its cloud service, and thanks to DigitalOcean’sdoctl tool, you can quickly deploy new clusters, apps, and helpful services without leaving your CLI.
Learn more about the ngrok Kubernetes Operator, or contribute to its ongoing development, by checking out the GitHub repository.
An extensive explainer is available for how the Operator works, plus additional documentation, which also includes details on using the Kubernetes Gateway API.