See what makes Kong the fastest, most-adopted API gateway
Check out the latest Kong feature releases and updates
Single platform for SaaS end-to-end connectivity
Enterprise service mesh based on Kuma and Envoy
Collaborative API design platform
How to Scale High-Performance APIs and Microservices
Call for speakers & sponsors, Kong API Summit 2023!
4 MIN READ
The quest for resilience and agility has driven us into the modern age of microservices. Bringing services to market on a microservice architecture demands the utilization of sprawling technology offerings and tooling. While daunting at first glance, we can break down the process into 3 major categories:
In this hands-on series, we will use:
Kong API Gateway is an API Gateway and Ingress Controller. At its core, Kong is a reverse proxy that allows an organization to offer APIs as a product to internal and external clients via a centralized ingress point. An API Gateway truly begins to shine when leveraged to consolidate capabilities such as authentication, RBAC, session handling, rate limiting, request & response transformation, redirection, load balancing, traffic monitoring, and logging. These advanced routing features offload enforcement, maintenance, and visibility from the application teams, improving their agility and consolidating this functional ownership into a central location for improved global consistency and visibility.
Pulumi is an Infrastructure as Code (IaC) or Infrastructure as Software (IaS) cloud engineering platform. Pulumi supports IaC/IaS patterns using popular programming languages including Python, JavaScript, TypeScript, Golang, and .NET/C#. At it’s heart, the Pulumi ecosystem is a cloud engineering platform and SDK offering that brings together developer, operations, and security teams through a unified software engineering process to accelerate innovation with more confidence via a full suite of OpenGitOps compliant tools.
This article is designed for you to follow along with your MacOS or Linux laptop. Before starting, please check that you have installed all dependencies.
Okay, now that you have your dependencies, let’s grab the code and get your system ready to build the lab platform.
# Set ADDRESS to your host IP if you plan to use Keycloak export ADDRESS=127.0.0.1 cat <<EOF | sudo tee -a /etc/hosts ${ADDRESS} apps.kind.home.arpa ${ADDRESS} portal.kong.kind.home.arpa ${ADDRESS} manager.kong.kind.home.arpa ${ADDRESS} keycloak.apps.kind.home.arpa ${ADDRESS} podinfo.apps.kind.home.arpa EOF
docker volume create worker1 docker volume create controlplane1
cd ~ git clone --depth 1 --branch v2.8.0 https://github.com/kong/TheKongLaboratory cd ~/TheKongLaboratory
Great! Reviewing our checklist, we now have:
/etc/hosts
Your system is ready to run the lab and we have the code! Next, before we can deploy the Kong API Gateway we need to initialize the Pulumi codebase and configure a Stack.
# Set a Pulumi local state login password export PULUMI_CONFIG_PASSPHRASE=mypassword # Run pulumi login --help for more state backend and login information pulumi login --local
# Download npm packages for Pulumi typescript IaC npm install # Initialize and select your pulumi stack pulumi stack init thekonglaboratory pulumi stack select thekonglaboratory
# Set Kong Enterprise License, an empty license enables free mode pulumi config set --secret kong:license "'{}'" # Set enterprise to true if deploying with an enterprise license pulumi config set kong:enterprise false
Reviewing our checklist again, we now have:
Now, it is time to start your Kind cluster and deploy Kong to it!
# Start Kind Kubernetes Cluster kind create cluster --config hack/kind/config.yml # Pulumi Deploy Kong Gateway & Dependencies pulumi up -y
Let’s go ahead and test our new Kong API Gateway by deploying Podinfo as a sample application to experiment with.
# change directory to Podinfo App cd ~/TheKongLaboratory/doc/gateway-s01e01-simple-app # Set a Pulumi local state login password export PULUMI_CONFIG_PASSPHRASE=mypassword # Run pulumi login --help for more state backend and login information pulumi login --local # Download npm packages for Pulumi typescript IaC npm install # Initialize and select your pulumi stack pulumi stack init podinfo pulumi stack select podinfo # Deploy Podinfo Sample App pulumi up -y
Congratulations! In roughly 1000 lines of TypeScript code, we have deployed a working Kong API Gateway and all supporting services with Pulumi! For transparency, I want to briefly list the scope of what you just deployed.
Now that you have Kong installed and ready to use, this will be the foundation for future posts in the DevMyOps series and is also a great way to get started with Kong for evaluation and local development purposes.
From here you can continue with configuring Kong Manager and Kong plugins, or you can start using the Kong Ingress Controller to publish services on your kind cluster via Kong.
kubectl
Linux / Mac
Docker
Kind
Helm
Pulumi
npm
git client
curl client
When you are finished with your local deployment you can clean up all lab artifacts in this order:
cd ~/TheKongLaboratory export PULUMI_CONFIG_PASSPHRASE=mypassword
pulumi --stack podinfo destroy -y pulumi --stack thekonglaboratory destroy -y
pulumi --stack podinfo destroy -y
pulumi --stack thekonglaboratory destroy -y
kind delete cluster --name=kong
docker volume rm worker1 controlplane1
pulumi --stack thekonglaboratory stack rm -y cd ~ && rm -rf ~/TheKongLaboratory
127.0.0.1 apps.kind.home.arpa 127.0.0.1 portal.kong.kind.home.arpa 127.0.0.1 manager.kong.kind.home.arpa 127.0.0.1 keycloak.apps.kind.home.arpa 127.0.0.1 podinfo.apps.kind.home.arpa
Share Post
Learn how to make your API strategy a competitive advantage.