From 8a8250d5ae299c0ab0d36ffa1469182d9d6e3eaa Mon Sep 17 00:00:00 2001 From: irene-theinfinitereality <157531141+irene-theinfinitereality@users.noreply.github.com> Date: Mon, 30 Jun 2025 01:56:28 -0400 Subject: [PATCH 1/4] HPA deployment --- .gitignore | 2 + ir-engine/templates/hpa.yaml | 35 ++++++++++++++++++ ir-engine/values.yaml | 72 +++++------------------------------- 3 files changed, 46 insertions(+), 63 deletions(-) create mode 100644 ir-engine/templates/hpa.yaml diff --git a/.gitignore b/.gitignore index 59dc558..7d4dab7 100755 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ ir-engine/Chart\.lock _site .sass-cache configs/beta.values.yaml + +.DS_STORE diff --git a/ir-engine/templates/hpa.yaml b/ir-engine/templates/hpa.yaml new file mode 100644 index 0000000..f035593 --- /dev/null +++ b/ir-engine/templates/hpa.yaml @@ -0,0 +1,35 @@ +# This entire HPA block will only be rendered if HPA is enabled in values.yaml +{{- if .Values.autoscaling.enabled }} + +apiVersion: autoscaling/v2 # Use HPA v2 API for advanced metrics +kind: HorizontalPodAutoscaler # Tells Kubernetes to create an HPA resource +metadata: + # Set the HPA name based on Helm's "fullname" helper (e.g., dev-ir-engine) + name: {{ include "ir-engine.fullname" . }} + labels: + # Adds standard Helm labels from the "labels" helper + {{- include "ir-engine.labels" . | nindent 4 }} + +spec: + # This tells the HPA what to scale + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment # HPA will monitor and scale this Deployment + name: {{ include "ir-engine.fullname" . }} # The name of the Deployment to scale + + # Minimum number of pods to run + minReplicas: {{ .Values.autoscaling.minReplicas }} + + # Maximum number of pods to allow + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + + # Define the metric used to trigger scaling (here: CPU utilization) + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization # We're using percentage-based CPU utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + +{{- end }} diff --git a/ir-engine/values.yaml b/ir-engine/values.yaml index 6017524..cbfc4b1 100755 --- a/ir-engine/values.yaml +++ b/ir-engine/values.yaml @@ -39,14 +39,9 @@ client: enabled: true annotations: kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" hosts: - host: xrsocial.local paths: ["/"] - # tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local serviceAccount: create: true @@ -92,15 +87,9 @@ api: enabled: true annotations: kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" hosts: - host: api.social.local paths: ["/"] - # tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - serviceAccount: create: true @@ -115,46 +104,22 @@ api: securityContext: {} fileServer: - # This is the path of file server upload folder in your host machine. Its is required when deployed - # in local environment. - # - # For MicroK8s: it will be similar to '/home///packages/server/upload' - # or '/packages/server/upload' - # - # For Minikube: it will be similar to '/hosthome///packages/server/upload' - # The folder must be in home folder and make sure to use /hosthome/ instead of home in path. - # Ref: https://stackoverflow.com/a/48535001/2077741 hostUploadFolder: "" - # Extra Environment variables to configure xrsocial extraEnv: - # ENV_VAR1: val1 - # ENV_VAR2: val2 - - # automatically filled by chart.. ignore - # MYSQL_PORT: 3306 - # MYSQL_DATABASE: ir-engine - # MYSQL_USER: server - # MYSQL_PASSWORD: password - SMTP_HOST: "" SMTP_PORT: "" SMTP_USER: "" SMTP_PASS: "" - GITHUB_CLIENT_ID: "" GITHUB_CLIENT_SECRET: "" GITHUB_CALLBACK_URL: http://127.0.0.1:3000/oauth/github - FACEBOOK_CLIENT_ID: "" FACEBOOK_CLIENT_SECRET: "" FACEBOOK_CALLBACK_URL: http://127.0.0.1:3000/oauth/facebook - GOOGLE_CLIENT_ID: "" GOOGLE_CLIENT_SECRET: "" GOOGLE_CALLBACK_URL: http://127.0.0.1:3000/oauth/google - - STORAGE_PROVIDER: local STORAGE_S3_BUCKET_NAME: "" STORAGE_S3_PUBLIC_VIDEO_PATH: "/" @@ -163,13 +128,10 @@ api: STORAGE_S3_CLOUDFRONT_DOMAIN: "" STORAGE_AWS_ACCESS_KEY_ID: "" STORAGE_AWS_ACCESS_KEY_SECRET: "" - AWS_SMS_REGION: "" AWS_SMS_ACCESS_KEY_ID: "" AWS_SMS_SECRET_ACCESS_KEY: "" AWS_SMS_TOPIC_ARN: "" - # SERVER_MODE: "api" - media: enabled: true @@ -193,15 +155,9 @@ media: enabled: true annotations: kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" hosts: - host: api.xrsocial.local paths: ["/video"] - # tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - serviceAccount: create: true @@ -215,35 +171,20 @@ media: podSecurityContext: {} securityContext: {} - # Extra Environment variables to configure xrsocial extraEnv: - # ENV_VAR1: val1 - # ENV_VAR2: val2 - - # automatically filled by chart.. ignore - # MYSQL_PORT: 3306 - # MYSQL_DATABASE: ir-engine - # MYSQL_USER: server - # MYSQL_PASSWORD: password - SMTP_HOST: "" SMTP_PORT: "" SMTP_USER: "" SMTP_PASS: "" - GITHUB_CLIENT_ID: "" GITHUB_CLIENT_SECRET: "" GITHUB_CALLBACK_URL: http://127.0.0.1:3000/oauth/github - FACEBOOK_CLIENT_ID: "" FACEBOOK_CLIENT_SECRET: "" FACEBOOK_CALLBACK_URL: http://127.0.0.1:3000/oauth/facebook - GOOGLE_CLIENT_ID: "" GOOGLE_CLIENT_SECRET: "" GOOGLE_CALLBACK_URL: http://127.0.0.1:3000/oauth/google - - STORAGE_PROVIDER: local STORAGE_S3_BUCKET_NAME: "" STORAGE_S3_PUBLIC_VIDEO_PATH: "/" @@ -252,12 +193,10 @@ media: STORAGE_S3_CLOUDFRONT_DOMAIN: "" STORAGE_AWS_ACCESS_KEY_ID: "" STORAGE_AWS_ACCESS_KEY_SECRET: "" - AWS_SMS_REGION: "" AWS_SMS_ACCESS_KEY_ID: "" AWS_SMS_SECRET_ACCESS_KEY: "" AWS_SMS_TOPIC_ARN: "" - # SERVER_MODE: "media" instanceserver: enabled: true @@ -289,8 +228,6 @@ instanceserver: annotations: {} name: -########### Subcharts - values here will overwrite the subchart - sql: database: ir-engine user: server @@ -359,3 +296,12 @@ batchinvalidator: create: true annotations: {} name: + +# --------------------------------------------------- +# Horizontal Pod Autoscaler (HPA) Configuration +# --------------------------------------------------- +autoscaling: + enabled: true # Enable HPA (true = create HorizontalPodAutoscaler resource) + minReplicas: 2 # Minimum number of pods to run + maxReplicas: 10 # Maximum number of pods to run + targetCPUUtilizationPercentage: 75 # Target CPU usage percentage to trigger autoscaling From cdce49c9a92d548c6d575cac78b231268200f122 Mon Sep 17 00:00:00 2001 From: irene-theinfinitereality <157531141+irene-theinfinitereality@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:39:01 -0400 Subject: [PATCH 2/4] fixed errors --- ir-engine/templates/api-server-deployment.yaml | 1 - ...> api-server-horizontal-pod-autoscaler.yaml} | 17 +++++++++-------- ir-engine/values.yaml | 15 +++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) rename ir-engine/templates/{hpa.yaml => api-server-horizontal-pod-autoscaler.yaml} (64%) diff --git a/ir-engine/templates/api-server-deployment.yaml b/ir-engine/templates/api-server-deployment.yaml index 58ec19c..c1e40c1 100755 --- a/ir-engine/templates/api-server-deployment.yaml +++ b/ir-engine/templates/api-server-deployment.yaml @@ -6,7 +6,6 @@ metadata: labels: {{- include "ir-engine.api.labels" . | nindent 4 }} spec: - replicas: {{ .Values.api.replicaCount }} selector: matchLabels: {{- include "ir-engine.api.selectorLabels" . | nindent 6 }} diff --git a/ir-engine/templates/hpa.yaml b/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml similarity index 64% rename from ir-engine/templates/hpa.yaml rename to ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml index f035593..4f7b434 100644 --- a/ir-engine/templates/hpa.yaml +++ b/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml @@ -1,27 +1,27 @@ # This entire HPA block will only be rendered if HPA is enabled in values.yaml -{{- if .Values.autoscaling.enabled }} +{{- if (.Values.autoscaling).enabled }} apiVersion: autoscaling/v2 # Use HPA v2 API for advanced metrics kind: HorizontalPodAutoscaler # Tells Kubernetes to create an HPA resource metadata: # Set the HPA name based on Helm's "fullname" helper (e.g., dev-ir-engine) - name: {{ include "ir-engine.fullname" . }} + name: {{ include "ir-engine.api.fullname" . }} labels: # Adds standard Helm labels from the "labels" helper - {{- include "ir-engine.labels" . | nindent 4 }} + {{- include "ir-engine.api.labels" . | nindent 4 }} spec: # This tells the HPA what to scale scaleTargetRef: apiVersion: apps/v1 kind: Deployment # HPA will monitor and scale this Deployment - name: {{ include "ir-engine.fullname" . }} # The name of the Deployment to scale + name: {{ include "ir-engine.api.fullname" . }} # The name of the Deployment to scale # Minimum number of pods to run - minReplicas: {{ .Values.autoscaling.minReplicas }} + minReplicas: {{ .Values.api.autoscaling.minReplicas }} # Maximum number of pods to allow - maxReplicas: {{ .Values.autoscaling.maxReplicas }} + maxReplicas: {{ .Values.api.autoscaling.maxReplicas }} # Define the metric used to trigger scaling (here: CPU utilization) metrics: @@ -30,6 +30,7 @@ spec: name: cpu target: type: Utilization # We're using percentage-based CPU utilization - averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }} -{{- end }} + +{{- end }} \ No newline at end of file diff --git a/ir-engine/values.yaml b/ir-engine/values.yaml index cbfc4b1..bb1f1f1 100755 --- a/ir-engine/values.yaml +++ b/ir-engine/values.yaml @@ -132,6 +132,12 @@ api: AWS_SMS_ACCESS_KEY_ID: "" AWS_SMS_SECRET_ACCESS_KEY: "" AWS_SMS_TOPIC_ARN: "" + + autoscaling: + enabled: true # Enable HPA (true = create HorizontalPodAutoscaler resource) + minReplicas: 2 # Minimum number of pods to run + maxReplicas: 10 # Maximum number of pods to run + targetCPUUtilizationPercentage: 75 # Target CPU usage percentage to trigger autoscaling media: enabled: true @@ -297,11 +303,4 @@ batchinvalidator: annotations: {} name: -# --------------------------------------------------- -# Horizontal Pod Autoscaler (HPA) Configuration -# --------------------------------------------------- -autoscaling: - enabled: true # Enable HPA (true = create HorizontalPodAutoscaler resource) - minReplicas: 2 # Minimum number of pods to run - maxReplicas: 10 # Maximum number of pods to run - targetCPUUtilizationPercentage: 75 # Target CPU usage percentage to trigger autoscaling + From d0535ec3740c7a14286743a8ca91d028af6470a7 Mon Sep 17 00:00:00 2001 From: irene-theinfinitereality <157531141+irene-theinfinitereality@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:41:34 -0400 Subject: [PATCH 3/4] Update api-server-horizontal-pod-autoscaler.yaml --- ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml b/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml index 4f7b434..d6a888a 100644 --- a/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml +++ b/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml @@ -1,5 +1,5 @@ # This entire HPA block will only be rendered if HPA is enabled in values.yaml -{{- if (.Values.autoscaling).enabled }} +{{- if ((.Values.api).autoscaling).enabled }} apiVersion: autoscaling/v2 # Use HPA v2 API for advanced metrics kind: HorizontalPodAutoscaler # Tells Kubernetes to create an HPA resource From c2c4698f99090b4f66332b32319a4bde9099a980 Mon Sep 17 00:00:00 2001 From: irene-theinfinitereality <157531141+irene-theinfinitereality@users.noreply.github.com> Date: Mon, 30 Jun 2025 15:58:12 -0400 Subject: [PATCH 4/4] Added Memory usage for autoscaling --- .../templates/api-server-horizontal-pod-autoscaler.yaml | 7 ++++++- ir-engine/values.yaml | 9 +++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml b/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml index d6a888a..505e05b 100644 --- a/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml +++ b/ir-engine/templates/api-server-horizontal-pod-autoscaler.yaml @@ -31,6 +31,11 @@ spec: target: type: Utilization # We're using percentage-based CPU utilization averageUtilization: {{ .Values.api.autoscaling.targetCPUUtilizationPercentage }} - + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.api.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} \ No newline at end of file diff --git a/ir-engine/values.yaml b/ir-engine/values.yaml index bb1f1f1..ec452ab 100755 --- a/ir-engine/values.yaml +++ b/ir-engine/values.yaml @@ -134,10 +134,11 @@ api: AWS_SMS_TOPIC_ARN: "" autoscaling: - enabled: true # Enable HPA (true = create HorizontalPodAutoscaler resource) - minReplicas: 2 # Minimum number of pods to run - maxReplicas: 10 # Maximum number of pods to run - targetCPUUtilizationPercentage: 75 # Target CPU usage percentage to trigger autoscaling + enabled: true # Enable HPA (true = create HorizontalPodAutoscaler resource) + minReplicas: 2 # Minimum number of pods to run + maxReplicas: 10 # Maximum number of pods to run + targetCPUUtilizationPercentage: 75 # Target CPU usage percentage to trigger autoscaling + targetMemoryUtilizationPercentage: 80 # Target RAM usage percentage to trigger autoscaling media: enabled: true