Cloud Native 14 min read

Deploying MCP Gateway on Kubernetes: A Step‑by‑Step Guide

This article explains how to quickly turn existing HTTP APIs into MCP services using the Go‑based mcp‑gateway, covering the installation of a local Kind Kubernetes cluster, the required YAML manifests, Docker image handling, OpenAPI import, and verification through the web console and chat interface.

Go Programming World
Go Programming World
Go Programming World
Deploying MCP Gateway on Kubernetes: A Step‑by‑Step Guide

With the rapid rise of Model Context Protocol (MCP) servers, many HTTP services need to be converted to MCP endpoints, and the mcp-gateway Go project provides a one‑click solution that requires only an OpenAPI‑compliant specification.

The gateway implements the MCP protocol and acts as a lightweight gateway service; it can expose existing APIs as MCP services without modifying any application code.

While the official documentation offers Docker and binary deployment, this guide demonstrates how to run the gateway inside a Kubernetes cluster created with Kind, making the process reproducible on a local machine.

First, create a Kind cluster configuration:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: mcp-cluster
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 30080
    hostPort: 30080
    listenAddress: "0.0.0.0"
    protocol: TCP
  - containerPort: 30081
    hostPort: 30081
    listenAddress: "0.0.0.0"
    protocol: TCP
  - containerPort: 30082
    hostPort: 30082
    listenAddress: "0.0.0.0"
    protocol: TCP
  - containerPort: 30083
    hostPort: 30083
    listenAddress: "0.0.0.0"
    protocol: TCP

After installing Kind, launch the cluster with kind create cluster --config=config.yaml , then verify it using kubectl get nodes -o wide .

Next, apply the Kubernetes manifests that define the namespace, deployment, service, configmaps, and PVC required by the gateway:

apiVersion: v1
kind: Namespace
metadata:
  name: mcp
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mcp-gateway
  namespace: mcp
  labels:
    app: mcp-gateway
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mcp-gateway
  template:
    metadata:
      name: mcp-gateway
      labels:
        app: mcp-gateway
    spec:
      containers:
      - name: mcp-gateway
        image: registry.ap-southeast-1.aliyuncs.com/mcp-ecosystem/mcp-gateway-allinone:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80   # Web UI
        - containerPort: 5234 # API Server
        - containerPort: 5235 # MCP Gateway
        - containerPort: 5335 # Management
        - containerPort: 5236 # Mock User Service
        env:
        - name: ENV
          value: production
        - name: OPENAI_BASE_URL
          value: https://dashscope.aliyuncs.com/compatible-mode/v1
        - name: OPENAI_API_KEY
          value: sk-xxx
        - name: OPENAI_MODEL
          value: qwen-turbo
        volumeMounts:
        - mountPath: /app/configs
          name: config-volume
        - mountPath: /app/data
          name: data-volume
        - mountPath: /app/.env
          name: env-volume
      restartPolicy: Always
      volumes:
      - name: config-volume
        configMap:
          name: mcp-config
      - name: env-volume
        configMap:
          name: mcp-env
      - name: data-volume
        persistentVolumeClaim:
          claimName: mcp-storage
---
apiVersion: v1
kind: Service
metadata:
  name: mcp-gateway-web
  namespace: mcp
spec:
  type: NodePort
  selector:
    app: mcp-gateway
  ports:
  - name: web
    port: 80
    targetPort: 80
    nodePort: 30080
  - name: api-server
    port: 5234
    targetPort: 5234
    nodePort: 30081
  - name: mcp-gateway
    port: 5235
    targetPort: 5235
    nodePort: 30082
  - name: mock-user
    port: 5236
    targetPort: 5236
    nodePort: 30083
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: mcp-config
  namespace: mcp
data:
  mcp-gateway.yaml: |
    ...
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: mcp-env
  namespace: mcp
data:
  ...
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mcp-storage
  namespace: mcp
spec:
  accessModes:
  - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 8Gi
  storageClassName: standard

Applying these manifests with kubectl apply -f mcp-gateway.yaml creates the namespace, deployment, service, and supporting resources; the service exposes the gateway on host ports 30080‑30083.

After deployment, access the web console at http://127.0.0.1:30080/ (default credentials admin/admin ) to manage MCP services, create a mock user service, and test the gateway via the built‑in chat interface, which can invoke the MCP server to register a user.

The gateway also offers an "Import OpenAPI" button. By uploading a standard OpenAPI 3.0 document (e.g., petstore.yaml ) the gateway automatically generates an MCP server configuration, eliminating the need to write YAML manually.

Although the example uses the public Swagger petstore, which lacks a real backend, the process demonstrates a complete workflow for converting any existing HTTP API into an MCP service that can be consumed by large language models.

In summary, the guide shows how to set up MCP Gateway on a local Kind cluster, configure ports and environment variables for model access, import OpenAPI specifications, and verify the resulting MCP services, providing a practical, cloud‑native approach to building model‑ready APIs.

cloud-nativeMCPKubernetesgogatewayOpenAPI
Go Programming World
Written by

Go Programming World

Mobile version of tech blog https://jianghushinian.cn/, covering Golang, Docker, Kubernetes and beyond.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.