Custom domain
In the Kubernetes Ingress and Gateway API specs, ingresses and routes can have multiple rules with different hostnames. The full relationship of these rules' hostnames to ngrok reserved domains and edges can be found in the ingress to edge relationship documentation. While standard ngrok domains are available for use immediately after reservation, custom white label domains may require a couple extra steps to get working. The following outlines 2 options for getting custom white label domains working with the ngrok Kubernetes Operator.
Managed by Kubernetes
If you create an ingress object (k8s ingress) or route object (Gateway API) with a hostname that is not a standard ngrok domain, the operator will attempt to create a custom white label domain for you. This domain will be reserved and registered with ngrok, but will not be configured until you have configured the DNS records for it. This will be registered in the ngrok API and also show up as a domain CRD For example:
If you create an ingress object such as this
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: service1
port:
number: 80
The operator will attempt to reserve and register the domain foo.bar.com
with ngrok. This will be registered in the ngrok API and also show up as a domain CRD. The operator will then wait for the DNS records to be configured for this domain. Once the DNS records are configured, the operator will configure the edge to route traffic to the ingress or route object.
You should be able to see the domain CRD via kubectl
kubectl describe domain foo.bar.com
For custom domains, the domain resource contains the CNAME target value that needs to be created for DNS resolution and certificates to work properly. This value is added to the ingress or route object's status.loadBalancer field.
kubectl describe ingress example-ingress
Status:
loadBalancer:
ingress:
hostname: 12jkh25.cname.ngrok.app
Externally managed
Domains can also be created
- manually via the dashboard UI
- via the ngrok API
- via the ngrok terraform provider
If created externally, the operator will discover the domain is already registered, and not interact with it unless you modify or delete the crd itself. Deleting the ingress objects that use that host won't result in the domain CRD in being deleted.