Expose a Kubernetes service to the internet using the ngrok Kubernetes Operator and a standard Kubernetes Ingress.
- A running Kubernetes cluster with
kubectlaccess - Helm 3.0.0+
- An ngrok account with:
- An authtoken
- An API key
- A reserved domain
git clone git@github.com:ngrok/k8s-operator-example.git
cd k8s-operator-examplehelm repo add ngrok https://charts.ngrok.com
helm repo update
export NGROK_AUTHTOKEN=<token>
export NGROK_API_KEY=<api-key>
helm install ngrok-operator ngrok/ngrok-operator \
--namespace ngrok-operator \
--create-namespace \
--set credentials.apiKey=$NGROK_API_KEY \
--set credentials.authtoken=$NGROK_AUTHTOKENkubectl apply -f deployment.yamlEdit ingress.yaml and replace YOUR_DOMAIN with your reserved domain, then apply:
kubectl apply -f ingress.yamlYour service is now available at https://YOUR_DOMAIN.
If you already have a Deployment and Service running in your cluster:
-
Install the ngrok Operator (one-time setup).
-
Create an Ingress resource pointing to your service:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-app spec: ingressClassName: ngrok rules: - host: YOUR_DOMAIN http: paths: - path: / pathType: Prefix backend: service: name: my-service port: number: 80
-
Apply it:
kubectl apply -f ingress.yaml
Your service is now publicly accessible at https://YOUR_DOMAIN.
MIT