Set explicit resource limits for API and celery-beat pods

Overrides LimitRange defaults (500m CPU) which caused kernel CPU
throttling during streaming requests. API gets 2000m CPU limit,
celery-beat gets 200m.
This commit is contained in:
Viktor Barzin 2026-02-22 13:20:56 +00:00
parent 8db7b60493
commit 9179456bf7
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 163 additions and 0 deletions

86
k8s/api-deployment.yaml Normal file
View file

@ -0,0 +1,86 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "125"
labels:
app: realestate-crawler-api
tier: 4-aux
name: realestate-crawler-api
namespace: realestate-crawler
spec:
progressDeadlineSeconds: 600
replicas: 2
revisionHistoryLimit: 10
selector:
matchLabels:
app: realestate-crawler-api
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
app: realestate-crawler-api
kubernetes.io/cluster-service: "true"
spec:
automountServiceAccountToken: true
containers:
- env:
- name: ENV
value: prod
- name: DB_CONNECTION_STRING
value: mysql://wrongmove:N5uy5v4wntXStCOvBlY7V@mysql.dbaas.svc.cluster.local:3306/wrongmove
- name: CELERY_BROKER_URL
value: redis://redis.redis.svc.cluster.local:6379/0
- name: CELERY_RESULT_BACKEND
value: redis://redis.redis.svc.cluster.local:6379/1
- name: UVICORN_LOG_LEVEL
value: debug
- name: OSRM_FOOT_URL
value: http://osrm-foot.osm-routing.svc.cluster.local:5000
- name: OSRM_BICYCLE_URL
value: http://osrm-bicycle.osm-routing.svc.cluster.local:5000
- name: OTP_URL
value: http://otp.osm-routing.svc.cluster.local:8080
- name: SLACK_WEBHOOK_URL
value: https://hooks.slack.com/services/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
- name: WEBAUTHN_RP_ID
value: wrongmove.viktorbarzin.me
- name: WEBAUTHN_ORIGIN
value: https://wrongmove.viktorbarzin.me
image: viktorbarzin/realestatecrawler:350
imagePullPolicy: Always
name: realestate-crawler-api
ports:
- containerPort: 5001
name: http
protocol: TCP
resources:
requests:
cpu: "50m"
memory: "128Mi"
limits:
cpu: "2000m"
memory: "1Gi"
volumeMounts:
- mountPath: /app/data
mountPropagation: None
name: data
dnsConfig:
options:
- name: ndots
value: "2"
dnsPolicy: ClusterFirst
enableServiceLinks: true
priorityClassName: tier-4-aux
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
volumes:
- name: data
nfs:
path: /mnt/main/real-estate-crawler
server: 10.0.10.15

View file

@ -0,0 +1,77 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "66"
labels:
app: realestate-crawler-celery-beat
tier: 4-aux
name: realestate-crawler-celery-beat
namespace: realestate-crawler
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: realestate-crawler-celery-beat
strategy:
type: Recreate
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: "2026-02-21T23:21:10Z"
labels:
app: realestate-crawler-celery-beat
spec:
automountServiceAccountToken: true
containers:
- command:
- python
- -m
- celery
- -A
- celery_app
- beat
- --loglevel=info
env:
- name: ENV
value: prod
- name: DB_CONNECTION_STRING
value: mysql://wrongmove:N5uy5v4wntXStCOvBlY7V@mysql.dbaas.svc.cluster.local:3306/wrongmove
- name: CELERY_BROKER_URL
value: redis://redis.redis.svc.cluster.local:6379/0
- name: CELERY_RESULT_BACKEND
value: redis://redis.redis.svc.cluster.local:6379/1
- name: SCRAPE_SCHEDULES
value: |
[{"name":"Daily RENT","listing_type":"RENT","hour":"2","min_bedrooms":1,"max_bedrooms":3,"min_price":2000,"max_price":4000},{"name":"Daily BUY","listing_type":"BUY","hour":"3","min_bedrooms":2,"max_bedrooms":3,"min_price":300000,"max_price":800000}]
image: viktorbarzin/realestatecrawler:350
imagePullPolicy: Always
name: celery-beat
resources:
requests:
cpu: "10m"
memory: "64Mi"
limits:
cpu: "200m"
memory: "256Mi"
volumeMounts:
- mountPath: /app/data
mountPropagation: None
name: data
dnsConfig:
options:
- name: ndots
value: "2"
dnsPolicy: ClusterFirst
enableServiceLinks: true
priorityClassName: tier-4-aux
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
volumes:
- name: data
nfs:
path: /mnt/main/real-estate-crawler
server: 10.0.10.15