Master Kubernetes deployment strategies for production workloads
# Kubernetes Deployment Patterns
Master Kubernetes deployment strategies with Google Antigravity IDE. This comprehensive guide covers deployment configurations, scaling, and production best practices.
## Why Kubernetes?
Kubernetes provides container orchestration for scalable applications. Google Antigravity IDE's Gemini 3 engine suggests optimal deployment configurations.
## Deployment Configuration
```yaml
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: antigravity-api
labels:
app: antigravity-api
version: v1
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: antigravity-api
template:
metadata:
labels:
app: antigravity-api
version: v1
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9090"
spec:
serviceAccountName: antigravity-api
containers:
- name: api
image: antigravity/api:v1.0.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3000
name: http
- containerPort: 9090
name: metrics
env:
- name: NODE_ENV
value: production
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: database-credentials
key: url
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health/live
port: 3000
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /health/ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
successThreshold: 1
securityContext:
runAsNonRoot: true
runAsUser: 1000
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchLabels:
app: antigravity-api
topologyKey: kubernetes.io/hostname
```
## Horizontal Pod Autoscaler
```yaml
# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: antigravity-api-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: antigravity-api
minReplicas: 3
maxReplicas: 20
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
- type: Pods
value: 4
periodSeconds: 15
selectPolicy: Max
```
## Service Configuration
```yaml
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: antigravity-api
labels:
app: antigravity-api
spec:
type: ClusterIP
ports:
- port: 80
targetPort: 3000
protocol: TCP
name: http
selector:
app: antigravity-api
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: antigravity-api-ingress
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod
nginx.ingress.kubernetes.io/rate-limit: "100"
spec:
tls:
- hosts:
- api.antigravity.dev
secretName: api-tls
rules:
- host: api.antigravity.dev
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: antigravity-api
port:
number: 80
```
## ConfigMap and Secrets
```yaml
# configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: antigravity-config
data:
LOG_LEVEL: "info"
CACHE_TTL: "3600"
FEATURE_FLAGS: |
{
"newFeature": true,
"betaAccess": false
}
---
# sealed-secret.yaml
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
name: database-credentials
spec:
encryptedData:
url: AgB2...encrypted...
password: AgC3...encrypted...
```
## Best Practices
- Use rolling updates for zero-downtime deployments
- Configure resource limits and requests
- Implement health checks for reliability
- Apply pod anti-affinity for distribution
- Use HPA for automatic scaling
- Secure secrets with sealed-secrets
Google Antigravity IDE provides Kubernetes templates and automatically validates your deployment configurations.This 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.