Interact with GKE to list clusters, manage node pools, and retrieve configs.
GKE Deployment Scripts Guide
This guide provides automated scripts to deploy sample applications to your GKE clusters for testing your GCP tools.
Google Cloud MCP Server
Current Suppported Tools: GKE
Prerequisites
Before running these scripts, you need:
- Google Cloud SDK (gcloud) - For cluster authentication
- kubectl - For Kubernetes operations
- Two GKE Autopilot clusters:
autopilot-cluster-1inus-central1autopilot-cluster-2ineurope-west2
Installation Steps
Step 1: Install Google Cloud SDK
Windows (PowerShell)
# Run PowerShell as Administrator
.\setup-gcloud.ps1
Then initialize gcloud:
gcloud init
macOS/Linux (Bash)
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init
Step 2: Install kubectl
gcloud components install kubectl
Step 3: Verify Installations
gcloud --version
kubectl version --client
Usage
Quick Start
Option A: PowerShell (Windows)
# Deploy applications to both clusters
.\deploy-apps.ps1 -ProjectId "your-project-id"
# Or use current gcloud project (if configured)
.\deploy-apps.ps1
Option B: Bash (Linux/macOS)
# Make scripts executable
chmod +x deploy-apps.sh cleanup-deployments.sh
# Deploy applications to both clusters
./deploy-apps.sh "your-project-id"
# Or use current gcloud project
./deploy-apps.sh
What Gets Deployed
Cluster 1 (us-central1)
Nginx (3 replicas)
- Default namespace
- Service: LoadBalancer on port 80
WordPress Stack
- Namespace:
wordpress - MySQL (1 replica) - Database
- WordPress (2 replicas) - Web application
- Services: LoadBalancer on port 80
- Namespace:
Monitoring Stack
- Namespace:
monitoring - Prometheus (1 replica) - Metrics collection
- Grafana (1 replica) - Visualization
- Services: LoadBalancer on ports 9090 & 3000
- Namespace:
Cluster 2 (europe-west2)
Same applications deployed for comparison and multi-cluster testing.
Verification Commands
After deployment, monitor the applications:
# Watch all pods across both clusters
kubectl get pods --all-namespaces -w
# Get LoadBalancer external IPs
kubectl get services --all-namespaces
# Check pod distribution
kubectl get pods -o wide --all-namespaces
# View resource usage
kubectl top nodes
kubectl top pods --all-namespaces
# Check deployment replicas
kubectl get deployments --all-namespaces
# View events during deployment
kubectl get events --all-namespaces --sort-by='.lastTimestamp'
Testing Your GCP Tools
Once deployments are complete, test your GCP tools:
# List both clusters
py -c "import asyncio; from src.tools.gke import list_gke_clusters; asyncio.run(list_gke_clusters('-'))"
# Get cluster details
py -c "import asyncio; from src.tools.gke import get_gke_cluster; asyncio.run(get_gke_cluster('us-central1', 'autopilot-cluster-1'))"
# List node pools
py -c "import asyncio; from src.tools.gke import list_gke_node_pools; asyncio.run(list_gke_node_pools('us-central1', 'autopilot-cluster-1'))"
# Get node pool details
py -c "import asyncio; from src.tools.gke import get_gke_node_pool; asyncio.run(get_gke_node_pool('us-central1', 'autopilot-cluster-1', 'default-pool'))"
# Get server config
py -c "import asyncio; from src.tools.gke import get_gke_server_config; asyncio.run(get_gke_server_config('us-central1'))"
Cleanup
When you're done testing, remove all deployments:
PowerShell
.\cleanup-deployments.ps1
Bash
./cleanup-deployments.sh
The cleanup script will:
- Delete all deployments
- Delete all services
- Remove custom namespaces (wordpress, monitoring)
- Keep the clusters running for future use
Troubleshooting
Issue: "gcloud not found"
Solution: Install Google Cloud SDK (see Step 1 above)
Issue: "kubectl not found"
Solution: Install kubectl with gcloud components install kubectl
Issue: "Cluster credentials failed"
- Verify cluster names spelling
- Check you're in the correct Google Cloud project:
gcloud config get-value project - Switch project:
gcloud config set project YOUR_PROJECT_ID
Issue: "CreateContainerError" or "ImagePullBackOff"
- Wait longer for pods to start (images are large)
- Check pod logs:
kubectl logs -n <namespace> - Check events:
kubectl describe pod -n <namespace>
Issue: LoadBalancer IP stuck in "Pending"
- This is normal for GKE. The IP will be assigned within a few seconds to a few minutes
- Check status:
kubectl get services --all-namespaces -w
Customization
To deploy different applications, modify the deployment scripts:
- Edit
deploy-apps.ps1ordeploy-apps.sh - Change image names, replicas, namespaces as needed
- Run the modified script
Example - Deploy a different image:
kubectl create deployment my-app --image=busybox:latest --replicas=2
File Structure
gcp
Tools (5)
list_gke_clustersLists all GKE clusters in the project.get_gke_clusterRetrieves details for a specific GKE cluster.list_gke_node_poolsLists node pools for a specific GKE cluster.get_gke_node_poolRetrieves details for a specific node pool.get_gke_server_configRetrieves the server configuration for a specific location.Environment Variables
GOOGLE_APPLICATION_CREDENTIALSrequiredPath to your Google Cloud service account JSON key file.Configuration
{"mcpServers": {"gcp": {"command": "python", "args": ["path/to/gcpmcp/src/main.py"]}}}