OpenResty Edge offers an efficient method for managing gateway servers in Kubernetes environments. Typically, gateway servers require manual approval to join a cluster, which readily becomes tedious in the dynamic environment of Kubernetes. What follows describes how to bind Kubernetes to a gateway cluster through OpenResty Edge’s Web console, enabling automatic approval and joining of gateway nodes.

Bind Kubernetes to a gateway cluster

If the gateway server runs in Kubernetes and it exits unexpectedly, Kubernetes will start another gateway server; having to approve each replacement manually would be cumbersome. OpenResty Edge can automate this process.

Screenshot

Switch to the Admin console of OpenResty Edge. The screenshots in this tutorial come from our sample deployment of the console; every user has her own local deployment.

After you bind Kubernetes to a gateway cluster, the gateway server running in this Kubernetes is automatically approved.

Go to the “Gateway Clusters” page and create a new gateway cluster: enter the gateway cluster name as k8s-bind-cluster, enable map to Kubernetes, select the Kubernetes cluster you want to bind, and click on “Create”.

Enable map to Kubernetes and select the Kubernetes cluster you want to bind

You will see that a new cluster is created successfully; there aren’t any gateway nodes in this cluster right now.

Screenshot

Test

On the terminal, we have prepared a yaml file to start the gateway server in Kubernetes.

Run kubectl apply to deploy the resource configuration, then kubectl get pods -n edge to view all Pods in the cluster.

We can see that the gateway server has started successfully.

Screenshot

Return to Admin. Refresh the list. Check the number of servers. In the flow demonstrated in this tutorial, the gateway server in Kubernetes has been successfully and automatically added to this gateway cluster.

Screenshot

After the gateway is ready in Kubernetes, the gateway cluster shows the server count

Summary

After you complete the binding in the Web console and enable map to Kubernetes, follow the yaml from the tutorial video to start the gateway server in Kubernetes and run the kubectl commands stated in this article. You can then reproduce what the tutorial demonstrates—no further manual approval is required—and the gateway server appears in this gateway cluster, matching the steps at the beginning of the video.

About OpenResty Edge

OpenResty Edge is our all-in-one gateway software for microservices and distributed traffic architectures. It combines traffic management, private CDN construction, API gateway, security, and more to help you easily build, manage, and protect modern applications. OpenResty Edge delivers industry-leading performance and scalability to meet the demanding needs of high concurrency, high load scenarios. It supports scheduling containerized application traffic such as K8s and manages massive domains, making it easy to meet the needs of large websites and complex applications.

If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!

About The Author

Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..

Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.

OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.

As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.