- Change HPA minReplicas from 2 to 3 - Maintain maxReplicas at 10 - Default 3 pods, auto-scale up to 10 based on CPU/Memory 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
114 lines
2.1 KiB
YAML
114 lines
2.1 KiB
YAML
apiVersion: v1
|
|
kind: Namespace
|
|
metadata:
|
|
name: site11-news
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: news-api-config
|
|
namespace: site11-news
|
|
data:
|
|
MONGODB_URL: "mongodb://host.docker.internal:27017"
|
|
DB_NAME: "ai_writer_db"
|
|
SERVICE_NAME: "news-api"
|
|
API_V1_STR: "/api/v1"
|
|
DEFAULT_PAGE_SIZE: "20"
|
|
MAX_PAGE_SIZE: "100"
|
|
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: news-api
|
|
namespace: site11-news
|
|
labels:
|
|
app: news-api
|
|
tier: backend
|
|
spec:
|
|
replicas: 3
|
|
selector:
|
|
matchLabels:
|
|
app: news-api
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: news-api
|
|
tier: backend
|
|
spec:
|
|
containers:
|
|
- name: news-api
|
|
image: ${DOCKER_HUB_USER}/news-api:latest
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- containerPort: 8000
|
|
name: http
|
|
envFrom:
|
|
- configMapRef:
|
|
name: news-api-config
|
|
resources:
|
|
requests:
|
|
cpu: 100m
|
|
memory: 128Mi
|
|
limits:
|
|
cpu: 500m
|
|
memory: 512Mi
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8000
|
|
initialDelaySeconds: 10
|
|
periodSeconds: 30
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /health
|
|
port: 8000
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: news-api-service
|
|
namespace: site11-news
|
|
labels:
|
|
app: news-api
|
|
spec:
|
|
type: ClusterIP
|
|
ports:
|
|
- port: 8000
|
|
targetPort: 8000
|
|
protocol: TCP
|
|
name: http
|
|
selector:
|
|
app: news-api
|
|
|
|
---
|
|
apiVersion: autoscaling/v2
|
|
kind: HorizontalPodAutoscaler
|
|
metadata:
|
|
name: news-api-hpa
|
|
namespace: site11-news
|
|
spec:
|
|
scaleTargetRef:
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
name: news-api
|
|
minReplicas: 3
|
|
maxReplicas: 10
|
|
metrics:
|
|
- type: Resource
|
|
resource:
|
|
name: cpu
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: 70
|
|
- type: Resource
|
|
resource:
|
|
name: memory
|
|
target:
|
|
type: Utilization
|
|
averageUtilization: 80
|