Skip to content

Commit

Permalink
Add test cluster autoscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
vectornguyen76 committed Jan 10, 2024
1 parent f94b01d commit e477638
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 32 deletions.
39 changes: 30 additions & 9 deletions helm-charts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Helm is a package manager for Kubernetes, simplifying the process of defining, i
3. [Model Repository S3](#model-repository-s3)
4. [Install aws-ebs-csi-driver](#install-aws-ebs-csi-driver)
5. [Install Metric Server](#install-metric-server)
6. [Install Charts](#install-charts)
6. [Install Cluster Autoscaler](#install-cluster-autoscaler)
7. [Install Charts](#install-charts)
- [Ingress Nginx Controller](#ingress-nginx-controller)
- [Postgresql](#postgresql)
- [Elastic Search](#elastic-search)
Expand All @@ -20,13 +21,14 @@ Helm is a package manager for Kubernetes, simplifying the process of defining, i
- [Text Search Application](#text-search-application)
- [Backend Application](#backend-application)
- [Frontend Application](#frontend-application)
7. [Load Test Horizontal Pod Autoscaling](#load-test-horizontal-pod-autoscaling)
8. [Load Test Autoscaling](#load-test-autoscaling)
- [Test Backend Horizontal Pod Autoscaling](#test-backend-horizontal-pod-autoscaling)
8. [Upgrade Charts](#upgrade-charts)
9. [Uninstall Charts](#uninstall-charts)
10. [Clean up PVC](#clean-up-pvc)
11. [Check Resources](#check-resources)
12. [References](#references)
- [Test Cluster Autoscaler ](#test-cluster-autoscaler)
9. [Upgrade Charts](#upgrade-charts)
10. [Uninstall Charts](#uninstall-charts)
11. [Clean up PVC](#clean-up-pvc)
12. [Check Resources](#check-resources)
13. [References](#references)

## Architecture

Expand Down Expand Up @@ -124,6 +126,14 @@ kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/late
helm upgrade --install metrics-server metrics-server/metrics-server
```

## Install Cluster Autoscaler
On AWS, Cluster Autoscaler utilizes Amazon EC2 Auto Scaling Groups to manage node groups. Cluster Autoscaler typically runs as a Deployment in your cluster.

Create a Cluster Autoscaler deployment and service account:
```bash
kubectl apply -f https://raw.githubusercontent.com/kubernetes/autoscaler/master/cluster-autoscaler/cloudprovider/aws/examples/cluster-autoscaler-autodiscover.yaml
```

## Install Charts
Step-by-step instructions to create namespaces and install various Helm charts like Ingress Nginx Controller, Postgresql, Elastic Search, Qdrant, Prometheus, Grafana, and others.

Expand Down Expand Up @@ -215,7 +225,7 @@ Step-by-step instructions to create namespaces and install various Helm charts l
helm install frontend-app ./frontend --namespace application --set nodeSelector.nodegroup-type=cpu-nodegroup
```

## Load Test Horizontal Pod Autoscaling
## Load Test Autoscaling

### Test Backend Horizontal Pod Autoscaling

Expand Down Expand Up @@ -274,6 +284,15 @@ Step-by-step instructions to create namespaces and install various Helm charts l
<em>Fig: Locust Test</em>
</p>

### Test Cluster Autoscaler

<p align="center">
<img src="./assets/cluster-autoscaler.png" alt="Cluster Autoscaler" />
<br>
<em>Fig: Cluster Autoscaler</em>
</p>


## Upgrade Charts
Instructions on how to upgrade existing Helm Chart releases.

Expand Down Expand Up @@ -365,4 +384,6 @@ Deleting PVCs is irreversible and can lead to data loss. Ensure backups are in p
- [Qdrant Helm Charts](https://github.com/qdrant/qdrant-helm/tree/main/charts/qdrant)
- [Elastic Cloud on Kubernetes Documentation](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-stack-helm-chart.html)
- [CSI driver for Amazon EBS](https://github.com/kubernetes-sigs/aws-ebs-csi-driver)
- [Kubernetes Metrics Server](https://github.com/kubernetes-sigs/metrics-server)
- [Kubernetes Metrics Server](https://github.com/kubernetes-sigs/metrics-server)
- [Autoscaling in Kubernetes](https://kubernetes.io/blog/2016/07/autoscaling-in-kubernetes/)
- [Cluster Autoscaler on AWS](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md)
Binary file added helm-charts/assets/cluster-autoscaler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion helm-charts/backend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ spec:
port: http
initialDelaySeconds: 5
periodSeconds: 5
# Only limit resources for test hpa
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand Down
5 changes: 4 additions & 1 deletion helm-charts/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ env:
key: JWT_SECRET


# Only limit resources for test hpa
resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 500m
memory: 256Mi
Expand Down
42 changes: 21 additions & 21 deletions helm-charts/cluster-config-eksctl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,26 @@ nodeGroups:
labels:
nodegroup-type: cpu-nodegroup

- name: gpu-nodegroup
instanceType: g4dn.xlarge
instanceName: eks-gpu-node
minSize: 1
maxSize: 3
volumeSize: 60
volumeType: gp3
desiredCapacity: 1
iam:
withAddonPolicies:
imageBuilder: true
autoScaler: true
externalDNS: true
certManager: true
appMesh: true
appMeshPreview: true
ebs: true
fsx: true
efs: true
labels:
nodegroup-type: gpu-nodegroup
# - name: gpu-nodegroup
# instanceType: g4dn.xlarge
# instanceName: eks-gpu-node
# minSize: 1
# maxSize: 3
# volumeSize: 60
# volumeType: gp3
# desiredCapacity: 1
# iam:
# withAddonPolicies:
# imageBuilder: true
# autoScaler: true
# externalDNS: true
# certManager: true
# appMesh: true
# appMeshPreview: true
# ebs: true
# fsx: true
# efs: true
# labels:
# nodegroup-type: gpu-nodegroup

availabilityZones: ["us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d"]
2 changes: 2 additions & 0 deletions helm-charts/frontend/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ spec:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
8 changes: 8 additions & 0 deletions helm-charts/frontend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ image:
pullPolicy: Always
tag: "latest"

resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

service:
type: ClusterIP
port: 3000
Expand Down
2 changes: 2 additions & 0 deletions helm-charts/image-search/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ spec:
# port: http
# initialDelaySeconds: 5
# periodSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
8 changes: 8 additions & 0 deletions helm-charts/image-search/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ image:
pullPolicy: Always
tag: "latest"

resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

service:
type: ClusterIP
port: 7000
Expand Down
2 changes: 2 additions & 0 deletions helm-charts/text-search/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ spec:
# port: http
# initialDelaySeconds: 5
# periodSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
8 changes: 8 additions & 0 deletions helm-charts/text-search/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ image:
pullPolicy: Always
tag: "latest"

resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

service:
type: ClusterIP
port: 6000
Expand Down

0 comments on commit e477638

Please sign in to comment.