
Ngrok is a distributed reverse proxy service that securely exposes production applications irrespective of the deployment environment by masking internal application ports to an external domain name. Ngrok Ingress Controller is an Ingress-as-a-service tool that securely exposes Kubernetes applications to the Internet with external security and traffic management functionalities designed to improve the general cluster performance.
In a Kubernetes cluster, the Ngrok Ingress Controller manages Ingress objects by connecting to the Ngrok edge with a static domain name that exposes defined internal services without affecting the cluster networking structure. In addition, the controller offloads multiple management features to the Ngrok edge instead of the Kubernetes cluster which improves the internal cluster response rate and application performance. These features include:
This guide explains how to deploy the Ngrok Ingress Controller on Kubernetes with a Vultr Kubernetes Engine (VKE) cluster and securely expose sample cluster applications using a static Ngrok domain.
Create or log in to your Ngrok account, and set up a new static domain. For example, example.ngrok-free.app.
Deploy a Vultr Kubernetes Engine (VKE) cluster with a minimum of 3 nodes.
Deploy a Vultr Debian server to use as the management workstation.
Access the server using SSH.
Install and configure Kubectl to access the VKE cluster.
Install the Helm package manager:
In this section, use the Helm package manager to install the Ngrok Ingress Controller to a Kubernetes cluster with all necessary Custom Resource Definitions (CRDs). Then, create a connection to your Ngrok account by exporting the necessary credentials to securely expose cluster applications as described in the steps below.
Before you install the Ngrok Ingress Controller:
Add the Ngrok Helm repository to your system sources.
Update the local Helm repositories.
Export a new environment variable NGROK_AUTHTOKEN with your Ngrok authentication token as the value. Replace dddeNNNSAAToken with the actual Ngrok AuthToken you generated earlier.
Export the NGROK_API_KEY variable with your Ngrok API key as the value. Replace dddeNNNSAPI with your actual Ngrok account API key.
Install the Ngrok Ingress Controller using Helm.
The above command installs the Ngrok Ingress Controller to your cluster with the following details:
ngrok-ingress-controller.NGROK_API_KEY environment variable value.NGROK_AUTHTOKEN environment variable value.When successful, your output should be similar to the one below:
View all deployments in the ngrok-ingress-controller namespace to verify that the controller is available and ready to use.
Output:
Verify the status of all Ngrok Ingress Controller pods.
Output:
Based on the above output, the Ngrok Ingress Controller is installed and ready to use in the cluster. To enable the controller processes, set up a sample cluster application to expose to your Ngrok domain.
Follow the steps below to deploy a sample application in the Kubernetes cluster to expose with the Ngrok Ingress Controller using your Ngrok domain. You will deploy a snake game using the thoschu/de.schulte360.web.snake container image to run as an internal application to expose with the Ngrok Ingress Controller as described in the steps below.
Create a new deployment YAML file to create the new application.
Add the following contents to the file.
Save and close the file.
The above deployment file creates a new cluster application in the ngrok-ingress-controller namespace that runs on the internal port 8080 with the descriptive labels example-snake-game and the Pods container name game-container
Apply the deployment to your cluster to deploy the application.
Create a new service YAML file to define the internal application networking.
Add the following contents to the file.
Save and close the file.
The above configuration redirects all network requests from the cluster port 8080 to the application port 8080 for processing. To correctly route all requests, the service resource points to the application pods with the label example-snake-game.
Apply the configuration to your cluster.
View all deployments in the ngrok-ingress-controller namespace to verify that the new application is available and ready.
Output:
View the application pods and verify that all replicas are ready running.
Output:
View all service resources in the ngrok-ingress-controller namespace and verify that the application service is available.
Output:
You have deployed a sample game application to your Kubernetes cluster. The Ngrok Ingress Controller communicates and routes traffic to the application using the application service resource to map the internal cluster endpoints for access using your external Ngrok domain.
The Ngrok Ingress Controller exposes existing cluster service resources to an Ngrok domain based on the internal port. Follow the steps below to create a new Ingress resource to securely expose the sample application you created earlier and verify the Ngrok domain edge information as described in the steps below.
Create a new Ingress YAML file app-ingress.yaml.
Add the following contents to the file. Replace example.ngrok-free.app with your actual Ngrok domain name.
Save and close the file.
Apply the Ingress resource to your cluster.
View Ingress resources and verify that the new application hist value and external access port.
Output:
Verify that the your Ngrok domain correctly displays in the HOSTS column. For each Ingress resource, the Ngrok Ingress controller creates a new edge resource associated with your Ngrok domain and the cluster endpoints defined in your Ingress configuration.
Access your Ngrok Dashboard and click Edge Configurations to view the new cluster endpoints.
Verify your Ngrok domain URL and the Edge prompt Created by Kubernetes-Ingress-Controller.
Click the GLOBAL region value to view the associated Backend Kubernetes endpoints.
Verify that all available endpoints match your Kubernetes cluster specifications. Based on your Ingress configurations, your Ngrok cluster resources information should be similar to the one below:
k8s.ngrok.com: Represents the unique Ngrok resource definition for communication with your cluster.k8s.ngrok.com/service=snake:The Kubernetes cluster service exposed by the Ngrok Ingress Controllerk8s.ngrok.com/port=8080: The service port exposed by the Ngrok controller to your domain ports 80 for HTTP and 443 for HTTPS.In a new web browser tab, visit your Ngrok domain and verify that your cluster application loads correctly.
Ngrok edge offers multiple authentication and security methods based on your Ingress configurations. All features act operate between your cluster and your Ngrok domain to enhance your cluster application security. Follow the steps below to secure yoru Kubernetes application with the Ngrok edge the available methods such as:
In this section, secure your Kubernetes cluster application with open authorization (OAuth) to authenticate all users to log in using a trusted platform such as GitHub. To tighten the application security, only authenticated users with a specific email domain class can access the application. In return, this improves the application security by limiting access to only a specific group of target users.
Open your Ngrok account dashboard.
Navigate to Edges under the Cloud Edge group.
Click the active Ngrok domain in use with your Kubernetes cluster to edit its Routes properties.
Click OAuth from the list of properties to launch the authentication options.
Click Begin setup to configure a new authentication option.
Click Identity Provider and select your target provider from the list of options. For example, select GitHub.
Keep Use an ngrok-managed OAuth application enabled in the Application section within the provider configuration options.
In the Authorization section, keep Restrict access to users that both authenticate and match a given set of rules selected.
Scroll to the Email Domains field and enter your target domain URL to associate with all successful GitHub logins. For example, gmail.com enables all GitHub users with the email domain to successfully access the application. To further restrict access to the application, include each of the allowed email addresses in the Email Addresses field separated by a comma ,.
Scroll and view any the additional options with enable your new GitHub authorization method.
Click Save at the top of the Ngrok session next to Created by kubernetes-ingress-controller to apply the new changes to your application.
Open a new web browser tab and visit your Ngrok domain.
Verify that a GitHub sign-in page displays as the authentication method to access the application. Click Authorize ngrok to test access to your application.
If your GitHub account matches any of the allowed email domains, verify that you can securely access your Kubernetes application.
You have deployed the Ngrok Ingress Controller to a Vultr Kubernetes Engine (VKE) cluster and securely exposed a sample cluster application for external access using an Ngrok domain. The controller improves your cluster performance by offloading several management features to your edge instead of your Kubernetes cluster. Unlike controllers such as Traefik, Nginx Ingress Controller, HAProxy, among others, Ngrok does not require a LoadBalancer service which keeps all cluster network requests internal. To use custom domains such as example.com instead of an Ngrok domain, visit the Ngrok documentation to upgrade your account plan.
0 Comments
Be the first to comment and share your perspective with the community.