How to scale down OpenShift/Kubernetes pods automatically on a schedule? How to scale down OpenShift/Kubernetes pods automatically on a schedule? kubernetes kubernetes

How to scale down OpenShift/Kubernetes pods automatically on a schedule?


OpenShift, like Kubernetes, is an api-driven application. Essentially all application functionality is exposed over the control-plane API running on the master hosts.

You can use any orchestration tool that is capable of making API calls to perform this activity. Information on calling the OpenShift API directly can be found in the official documentation in the REST API Reference Overview section.

Many orchestration tools have plugins that allow you to interact with OpenShift/Kubernetes API more natively than running network calls directly. In the case of Jenkins for example there is the OpensShift Pipeline Jenkins plugin that allows you to perform OpenShift activities directly from Jenkins pipelines. In the cases of Ansible there is the k8s module.

If you were to combine this with Jenkins capability to run jobs on a schedule you have something that meets your requirements.

For something much simpler you could just schedule Ansible or bash scripts on a server via cron to execute the appropriate API commands against the OpenShift API.

Executing these commands from within OpenShift would also be possible via the CronJob object.