Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k8s): add a horizontal pod autoscaler #768

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/reusable-push-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ jobs:

run: |
cat deployments/templates/deployment.yml | envsubst > deployments/deployment.yml
cat deployments/templates/hpa.yml | envsubst > deployments/hpa.yml
cat deployments/templates/ingress.yml | envsubst > deployments/ingress.yml
cat deployments/templates/service.yml | envsubst > deployments/service.yml
cat deployments/templates/secrets.yml | envsubst > deployments/secrets.yml
Expand Down
8 changes: 7 additions & 1 deletion deployments/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ metadata:
labels:
app: find-moj-data
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
Expand All @@ -22,6 +21,13 @@ spec:
containers:
- name: find-moj-data
image: ${IMAGE_PATH}
resources:
requests:
cpu: 20m
memory: 300Mi
limits:
cpu: 1000m
memory: 1000Mi
ports:
- name: http
containerPort: 8000
Expand Down
19 changes: 19 additions & 0 deletions deployments/templates/hpa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: find-moj-data
namespace: ${NAMESPACE}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: find-moj-data-deployment
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 95