infrapuzzle/k8s/n8n/garmin-mcp.yaml

84 lines
3.0 KiB
YAML

# --- Garmin MCP Server Deployment ---
# This manifest defines the desired state for the Garmin MCP server.
# It uses a standard Python image and installs the necessary tools and
# the application itself upon startup.
apiVersion: apps/v1
kind: Deployment
metadata:
name: garmin-mcp-server
namespace: n8n
labels:
app: garmin-mcp-server
spec:
replicas: 1
selector:
matchLabels:
app: garmin-mcp-server
template:
metadata:
labels:
app: garmin-mcp-server
spec:
containers:
- name: server
# Use a standard, slim Python image as the base.
image: python:3.12-slim
# Override the default command to perform setup and then run the server.
command: ["/bin/sh", "-c"]
args:
- |
set -e
echo "Step 1/4: Installing git client..."
# Update package lists and install git. --no-install-recommends keeps it minimal.
# rm -rf cleans up the apt cache to keep the running container lean.
apt-get update && apt-get install -y git --no-install-recommends && rm -rf /var/lib/apt/lists/*
echo "Step 2/4: Installing uv package manager..."
pip install uv
echo "Step 3/4: Launching server via uvx (will install from git)..."
# 'uvx' runs a command from a temporary environment.
# We specify the git repository to install the package from.
# The '--host 0.0.0.0' flag is crucial to ensure the server
# is accessible from outside its container within the cluster network.
uvx --from git+https://github.com/Taxuspt/garmin_mcp garmin-mcp --host 0.0.0.0 --port 8000
echo "Step 4/4: Server has been started."
ports:
- name: http
containerPort: 8000
protocol: TCP
# Mount the Garmin credentials from the Kubernetes secret as environment variables.
envFrom:
- secretRef:
name: garmin-credentials
# Basic readiness probe to ensure the service is not marked ready until the app is listening.
readinessProbe:
tcpSocket:
port: 8000
initialDelaySeconds: 25 # Increased delay to account for git installation
periodSeconds: 10
---
# --- Garmin MCP Server Service ---
# This manifest creates a stable internal endpoint (ClusterIP service)
# for the Garmin MCP server deployment. Your n8n instance will use this
# service's DNS name to communicate with the server.
apiVersion: v1
kind: Service
metadata:
name: garmin-mcp-service
namespace: n8n
spec:
# This service will be of type ClusterIP, only reachable from within the cluster.
type: ClusterIP
selector:
# This selector must match the labels of the pods created by the Deployment.
app: garmin-mcp-server
ports:
- name: http
protocol: TCP
# The port the service will be available on within the cluster.
port: 80
# The port on the container that the service will forward traffic to.
targetPort: 8000