Deploy Google Antigravity Next.js applications to Kubernetes with Helm charts, autoscaling, and production configurations.
# Kubernetes Deployment Patterns
Deploy your Google Antigravity Next.js applications to Kubernetes with best practices. This guide covers deployments, services, autoscaling, and Helm charts.
## Deployment Manifest
Create a production-ready deployment:
```yaml
# k8s/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: antigravity-app
labels:
app: antigravity
spec:
replicas: 3
selector:
matchLabels:
app: antigravity
template:
metadata:
labels:
app: antigravity
spec:
containers:
- name: app
image: your-registry/antigravity:latest
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: "production"
- name: NEXT_PUBLIC_SUPABASE_URL
valueFrom:
secretKeyRef:
name: antigravity-secrets
key: supabase-url
- name: NEXT_PUBLIC_SUPABASE_ANON_KEY
valueFrom:
secretKeyRef:
name: antigravity-secrets
key: supabase-anon-key
resources:
requests:
cpu: "100m"
memory: "256Mi"
limits:
cpu: "500m"
memory: "512Mi"
livenessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
imagePullSecrets:
- name: registry-credentials
```
## Service and Ingress
Expose the application with proper networking:
```yaml
# k8s/service.yaml
apiVersion: v1
kind: Service
metadata:
name: antigravity-service
spec:
selector:
app: antigravity
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: ClusterIP
---
# k8s/ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: antigravity-ingress
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
spec:
tls:
- hosts:
- antigravityai.directory
secretName: antigravity-tls
rules:
- host: antigravityai.directory
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: antigravity-service
port:
number: 80
```
## Horizontal Pod Autoscaler
Scale based on CPU and memory:
```yaml
# k8s/hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: antigravity-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: antigravity-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 10
periodSeconds: 60
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 15
```
## Helm Chart Structure
Organize deployments with Helm:
```yaml
# charts/antigravity/values.yaml
replicaCount: 3
image:
repository: your-registry/antigravity
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
ingress:
enabled: true
className: nginx
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
hosts:
- host: antigravityai.directory
paths:
- path: /
pathType: Prefix
tls:
- secretName: antigravity-tls
hosts:
- antigravityai.directory
resources:
limits:
cpu: 500m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70
env:
NODE_ENV: production
secrets:
supabaseUrl: ""
supabaseAnonKey: ""
```
## Deployment Script
Automate deployments:
```bash
#!/bin/bash
# deploy.sh
set -e
NAMESPACE="production"
RELEASE="antigravity"
CHART="./charts/antigravity"
# Build and push image
TAG=$(git rev-parse --short HEAD)
docker build -t your-registry/antigravity:$TAG .
docker push your-registry/antigravity:$TAG
# Deploy with Helm
helm upgrade --install $RELEASE $CHART \
--namespace $NAMESPACE \
--create-namespace \
--set image.tag=$TAG \
--set secrets.supabaseUrl=$SUPABASE_URL \
--set secrets.supabaseAnonKey=$SUPABASE_ANON_KEY \
--wait
echo "Deployed version $TAG"
```
## Best Practices
1. **Resource Limits**: Always set CPU and memory limits
2. **Health Checks**: Implement liveness and readiness probes
3. **Secrets Management**: Use Kubernetes secrets or external secret managers
4. **Rolling Updates**: Configure proper update strategies
5. **Pod Disruption Budgets**: Ensure availability during updates
6. **Monitoring**: Deploy Prometheus and Grafana for observabilityThis kubernetes prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their kubernetes implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For kubernetes projects, consider mentioning your framework version, coding style, and any specific libraries you're using.