Schedule-based pod scaling

I am trying to deploy Pega 24.2 on EKS.

I would like to scale the Pega-web pods based on a schedule.

Is this possible?

@keisukek17309988

are you able to access the MSP GenAI Buddy? Please see if the answer helps you.

Via other references our GenAI came up with this response: All generated answers require validation against the provided references.

------------------------------------------------------------------------

it is possible to scale Pega-web pods based on a schedule when deploying Pega 24.2 on EKS. There are two main approaches you can use for implementing this capability:

Using Kubernetes CronJobs

You can create CronJobs in your Kubernetes cluster that execute scaling commands at predetermined times. This is particularly useful for predictable scaling needs, such as reducing resources during off-hours and scaling up before business hours.

Here’s how you can implement this:

  1. Create a CronJob manifest that runs the kubectl scale command to modify the replica count of your Pega-web deployment at specific times.
apiVersion: batch/v1
kind: CronJob
metadata:
  name: scale-pegaweb-up
spec:
  schedule: "0 8 * * 1-5"  # 8:00 AM Monday-Friday
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: scaling-account  # Account with permissions to scale deployments
          containers:
          - name: kubectl
            image: bitnami/kubectl:latest
            command:
            - /bin/sh
            - -c
            - kubectl scale deployment pega-web --replicas=10
          restartPolicy: OnFailure
---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: scale-pegaweb-down
spec:
  schedule: "0 20 * * 1-5"  # 8:00 PM Monday-Friday
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: scaling-account
          containers:
          - name: kubectl
            image: bitnami/kubectl:latest
            command:
            - /bin/sh
            - -c
            - kubectl scale deployment pega-web --replicas=2
          restartPolicy: OnFailure

Using Horizontal Pod Autoscaler with Target Modifications

Alternatively, if you’re already using the Horizontal Pod Autoscaler (HPA) for your Pega deployment, you can create CronJobs that modify the HPA’s minimum and maximum replicas at scheduled times:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: modify-hpa-business-hours
spec:
  schedule: "0 8 * * 1-5"  # 8:00 AM Monday-Friday
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: scaling-account
          containers:
          - name: kubectl
            image: bitnami/kubectl:latest
            command:
            - /bin/sh
            - -c
            - kubectl patch hpa pega-web-hpa --patch '{"spec":{"minReplicas":5,"maxReplicas":20}}'
          restartPolicy: OnFailure
---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: modify-hpa-off-hours
spec:
  schedule: "0 20 * * 1-5"  # 8:00 PM Monday-Friday
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: scaling-account
          containers:
          - name: kubectl
            image: bitnami/kubectl:latest
            command:
            - /bin/sh
            - -c
            - kubectl patch hpa pega-web-hpa --patch '{"spec":{"minReplicas":2,"maxReplicas":5}}'
          restartPolicy: OnFailure

Important Considerations

  1. You’ll need to create a service account with appropriate RBAC permissions to allow the CronJob to scale deployments or modify HPAs.
  2. Ensure your cluster has enough resources to handle the scaling operations.
  3. The exact deployment name and namespace may need to be adjusted based on your specific Pega implementation.
  4. Consider implementing monitoring to verify that scaling operations are working as expected.

Reference