Kubexpose: A Kubernetes Operator, for fun and profit!
Say you have a web service running as a Kubernetes Deployment. There are a bunch of ways to access it over a public URL, but Kubexpose makes it easy to do so. It’s a Kubernetes Operator backed by a Custom Resource Definition and the corresponding controller implementation.
Kubexposebuilt using kubebuilder and available on GitHub

To try it out, jump into the next section or scroll down to How it works? to learn more
Quick start
Any Kubernetes cluster will work (minikube, kind, Docker Desktop, on the cloud, whatever…).
To deploy the operator and required components:
kubectl apply -f https://raw.githubusercontent.com/abhirockzz/kubexpose-operator/master/kubexpose-all-in-one.yamlMake sure the Operator is up and running:
export OPERATOR_NAMESPACE=kubexpose-operator-system
# check Pods
kubectl get pods -n $OPERATOR_NAMESPACE
# check logs
kubectl logs -f $(kubectl get pods --namespace $OPERATOR_NAMESPACE -o=jsonpath='{.items[0].metadata.name}') -c manager -n $OPERATOR_NAMESPACECreate a nginx Deployment to test things out — this is the one you want to expose over the internet using a public URL).
Along with it, create a kubexpose resource — which will help you access ngnix Deployment over the Internet!
kubectl apply -f https://raw.githubusercontent.com/abhirockzz/kubexpose-operator/master/quickstart/nginx.yaml
kubectl apply -f https://raw.githubusercontent.com/abhirockzz/kubexpose-operator/master/quickstart/kubexpose.yamlWait for a few seconds and check the public URL at which the Nginx Deployment can be accessed:
kubectl get kubexpose/kubexpose-test -o=jsonpath='{.status.url}'Access the public URL using your browser or test it using
curl
Confirm that the Service and Deployment have been created as well:
kubectl get svc/nginx-test-svc-kubexpose-test
kubectl get deployment/nginx-test-expose-kubexpose-testYou can try out other scenarios such as trying to
Deploymentand/orService- the Operator will reconcile or bring things back to the state as specified in the resource.
To delete the kubexpose resource:
kubectl delete kubexpose/kubexpose-testThis will also delete the
ServiceandDeploymentwhich were created for this resource
To uninstall the Operator:
kubectl delete -f https://raw.githubusercontent.com/abhirockzz/kubexpose-operator/master/kubexpose-all-in-one.yamlThis will delete the CRD,
kubexposeoperator and other resources.
How does it work?
Behind the scenes, Kubexpose uses the awesome ngrok project to get the job done!
When you create a kubexpose resource, the operator:
- Creates a
ClusterIPtypeServicefor theDeploymentyou want to access (naming format:<deployment name>-svc-<kubexpose resource name>) - Creates a
Deployment(using this ngrok Docker image) that runsngrok- which is configured to point to theService(naming format:<deployment name>-expose-<kubexpose resource name>). It’s equivalent to startingngrokas such:ngrok http foo-svc-bar 80

The
DeploymentandServiceand owned and managed by the Kubexpose resource instance.
Enjoy!