Use Cases
Common Use Cases
- Automated container deployment
- Rolling updates
- Canary deployments
- Image promotion across environments
Before You Begin
Prerequisites
- Docker installed locally
- Kubernetes cluster access (kubectl configured)
- Container registry access (Docker Hub, ECR, or GCR)
Walkthrough
Step-by-Step Guide
1
Configure Docker MCP Server
Set up Docker MCP Server with access to build and push images.
2
Configure Kubernetes MCP Server
Set up with kubeconfig for your target cluster.
3
Build and Push Image
Build a Docker image from your Dockerfile and push to a container registry.
async function buildAndPush(repo, tag) {
await docker.build({ path: ".", tag: `registry.example.com/${repo}:${tag}` });
await docker.push({ tag: `registry.example.com/${repo}:${tag}` });
return `registry.example.com/${repo}:${tag}`;
}4
Deploy to Kubernetes
Update the Kubernetes deployment with the new image using a rolling update strategy.
async function deploy(image, deployment, namespace) {
await kubernetes.patchDeployment({
name: deployment,
namespace,
body: { spec: { template: { spec: { containers: [{ name: deployment, image }] } } } }
});
// Wait for rollout
await kubernetes.waitForRollout({ deployment, namespace, timeout: 300 });
}5
Verify Deployment
Check pod health, run smoke tests, and verify the new version is serving traffic.
6
Implement Rollback
If verification fails, automatically roll back to the previous version.
Examples
Code Examples
typescript
Full Deploy Pipeline
async function deployPipeline(repo, version) {
const image = await buildAndPush(repo, version);
await deploy(image, repo, "production");
const healthy = await verifyDeployment(repo, "production");
if (!healthy) {
await kubernetes.rollbackDeployment({ name: repo, namespace: "production" });
throw new Error("Deployment failed health check, rolled back");
}
}Help
Troubleshooting
How do I handle image pull secrets?+
What's the best rollout strategy?+
How do I debug failed deployments?+
Quick Info
DifficultyAdvanced
Time Estimate2 hours
Tools
Docker MCP ServerKubernetes MCP Server