Deploy Gateway on Kubernetes
On this page, you will find instructions for installing and running the Gateway demo application in Kubernetes using Kubernetes manifests.
Before you begin
To follow this guide:
- You need the latest version of Kubernetes running either locally or remotely on a public or private cloud.
- If you plan to use it in a local environment, you can use various Kubernetes options such as minikube, kind, Docker Desktop, and others.
- If you plan to use Kubernetes in a production setting, it’s recommended to utilize managed cloud services like Google Kubernetes Engine (GKE), Amazon Elastic Kubernetes Service (EKS), or Azure Kubernetes Service (AKS).
- Configured
kubectl
to work with your cluster - Access to GitHub Container Registry (ghcr.io)
System requirements
This section provides minimum hardware and software requirements.
Minimum Hardware Requirements
- Memory: 250 MiB (approx 250 MB)
- CPU: 125m (approx 0.125 cores)
Note
Enable the necessary ports in your network environment for Gateway.
Deploy Gateway on Kubernetes
This section explains how to install Gateway using Kubernetes.
Create a namespace
It is recommended to create a new namespace in Kubernetes to better manage, organize, allocate, and manage cluster resources:
kubectl create namespace demo
Deploy the Gateway application
-
Create a
gateway.yaml
file, and copy-and-paste the following content into it:---apiVersion: v1kind: ConfigMapmetadata:name: gateway-confignamespace: demodata:config.yaml: |api:name: Automatic APIdescription: ""version: 1.0.0database:type: postgresconnection: "connection-string"plugins: {}---apiVersion: apps/v1kind: Deploymentmetadata:name: gatewaynamespace: demolabels:app: gatewayspec:replicas: 1selector:matchLabels:app: gatewaytemplate:metadata:labels:app: gatewayspec:volumes:- name: configconfigMap:name: gateway-configcontainers:- name: gatewayimage: ghcr.io/centralmind/gateway:latestargs:- start- --config- /etc/gateway/config.yaml- --addr- ":8080"imagePullPolicy: Alwaysports:- containerPort: 8080name: httpvolumeMounts:- name: configmountPath: /etc/gatewayreadOnly: true---apiVersion: v1kind: Servicemetadata:name: gatewaynamespace: demospec:ports:- port: 80targetPort: httpselector:app: gateway -
Run the following command to send the manifest to the Kubernetes API server:
Terminal window kubectl apply -f gateway.yaml
Verify the deployment
-
Complete the following steps to verify the deployment status of each object:
a. For Pods, run the following command:
Terminal window kubectl get pods -n demob. For Services, run the following command:
Terminal window kubectl get svc -n demo -o wide
Access the Gateway API
To access the Gateway API from your local machine, you can use port forwarding. This allows you to connect to the Gateway service running in your Kubernetes cluster without exposing it externally.
-
First, identify the Gateway pod name:
Terminal window kubectl get pods -n demo -l app=gateway -
Set up port forwarding to the Gateway pod:
Terminal window kubectl port-forward -n demo svc/gateway 8080:8080This command forwards your local port 8080 to port 80 of the Gateway service in the Kubernetes cluster.
-
Now you can access the Gateway API at:
http://localhost:8080
Example endpoints:
- GET
/gachi_teams
- List all teams - GET
/gachi_personas
- List all personas
Note
The port forwarding session will continue until you terminate it with Ctrl+C. If you close the terminal or the connection is interrupted, you’ll need to restart the port forwarding.
Configuration
You can modify the Kubernetes manifests to customize your deployment:
gateway.yaml
- Gateway configuration
Update an existing deployment
Update Gateway configuration
To update the Gateway configuration:
- Edit the
gateway.yaml
file with your changes - Apply the updated configuration:
Terminal window kubectl apply -f gateway.yaml
Troubleshooting
Collecting logs
To collect Gateway logs, run:
kubectl logs -l app=gateway -n demo
Using the —dry-run command
You can use the --dry-run=client
flag with kubectl to test your manifests without actually applying them:
kubectl apply -f gateway.yaml --dry-run=client
Remove Gateway
To remove the deployment:
-
Delete Gateway resources:
Terminal window kubectl delete -f gateway.yaml -
Delete the namespace (optional):
Terminal window kubectl delete namespace demo
Was this page helpful?
If you have questions or suggestions for improving this documentation, please create an issue in the project repository.