0

I'm running a Kubernetes cluster on GKE autopilot

I have pods that do the following - Wait for a job, run the job (This can take minutes or hours), Then go to Pod Succeeded State which will cause Kubernetes to restart the pod.

The number of pods I need is variable depending on how many users are on the platform. Each user can request a job that needs a pod to run.

I don't want users to have to wait for pods to scale up so I want to keep a number of extra pods ready and waiting to execute.

The application my pods are running can be in 3 states - { waiting for job, running job, completed job}

Scaling up is fine as I can just use the scale API and always request to have a certain percentage of pods in waiting for job state

When scaling down I want to ensure that Kubernetes doesn't kill any pods that are in the running job state.

Should I implement a Custom Horizontal Pod Autoscaler?

Can I configure custom probes for my pod's application state?

I could use also use pod priority or a preStop hook

patrick_corrigan
  • 809
  • 11
  • 24
  • Could you describe your application a bit more? For example, what are users submitting to trigger a job? And what do those jobs need access to? – Gari Singh Sep 04 '21 at 09:48

1 Answers1

0

You can configure horizontal Pod autoscaling to ensure that Kubernetes doesn't kill any pods.

Steps for configuring horizontal pod scaling:

Create the Deployment, apply the nginx.yaml manifest,Run the following command:

  kubectl apply -f nginx.yaml

Autoscaling based on resources utilization

1-Go to the Workloads page in Cloud Console.

2-Click the name of the nginx Deployment.

3-Click list Actions > Autoscale.

4-Specify the following values:

-Minimum number of replicas: 1

-Maximum number of replicas: 10

-Auto Scaling metric: CPU

-Target: 50

-Unit: %

5-Click Done.

6-Click Autoscale.

To get a list of Horizontal Pod Autoscalers in the cluster, use the following command:

kubectl get hpa

Guide on how to Configure horizontal pod autoscaling.

You can also refer to this link of auto-scaling rules for the GKE autopilot cluster using a custom metric on the Cloud Console.

Fariya Rahmat
  • 2,123
  • 3
  • 11