Auto scale microservice with Keda on OpenShift

  1. Create a VM
  2. Add and format the disks of said VM
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: runner-scaledobject
namespace: iaas-dev
spec:
scaleTargetRef:
name: runner-deployment
triggers:
- type: rabbitmq
metadata:
protocol: amqp
queueName: flows
mode: QueueLength
value: "1"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
name: runner
namespace: iaas-dev
spec:
jobTargetRef:
template:
spec:
containers:
- name: runner
image: runner:<commit id>
envFrom:
- secretRef:
name: rabbitmq-password
pollingInterval: 10
maxReplicaCount: 10
scalingStrategy:
strategy: "accurate"
triggers:
- type: rabbitmq
metadata:
queueName: flows
mode: QueueLength
value: "1"
authenticationRef:
name: keda-trigger-auth-rabbitmq-conn
oc set image ScaledJob/runner runner=runner:<commit id>
...
resources:
- runner-scaledjob.yaml
configration:
- scaled-job-image-transformer.yaml
images:
- name: runner
newTag: <commit id>
oc set image ScaledJob/runner runner=runner:<commit id>
- path: spec/jobTargetRef/template/spec/containers/runner/image
kind: ScaledJob
kustomize edit set image runner=runner:<commit id> # For Changing the image tag in the kustomization file.
oc apply -k # For applying the new customization to the runner ScaledJob.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store