cron-hpa

command module
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

CronHPA

CronHPA was created by dtaniwaki. We forked because the original version is no longer being actively maintained.

Go Reference Coverage Status

CronHPA is an operator designed to modify Horizontal Pod Autoscaler (HPA) resources according to specific schedules. This functionality allows for dynamic adjustments, such as reducing the minimum number of replicas during night-time hours and increasing them during day-time hours.

Here's a CronHPA example.

apiVersion: cron-hpa.ubie-oss.github.com/v1alpha1
kind: CronHorizontalPodAutoscaler
metadata:
  name: cron-hpa-example
spec:
  template:
    spec:
      scaleTargetRef:
        apiVersion: apps/v1
        kind: Deployment
        name: cron-hpa-nginx
      minReplicas: 3
      maxReplicas: 10
      metrics:
      - type: Resource
        resource:
          name: cpu
          target:
            type: Utilization
            averageUtilization: 50
  scheduledPatches:
  - name: daytime
    schedule: "0 8 * * *"
    timezone: "Asia/Tokyo"
  - name: nighttime
    schedule: "0 22 * * *"
    timezone: "Asia/Tokyo"
    patch:
      minReplicas: 1 # Less minimum replicas.
      - type: Resource
        resource:
          name: cpu
          target:
            type: Utilization
            averageUtilization: 70 # More conservative scaling.

How to use CronHPA

Disable CronHPA temporarily

Mark the target HPA resource as below to temporarily skip getting CronHPA's update.

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  annotations:
    cron-hpa.ubie-oss.github.com/skip: "true"
...

Prerequisites

Build

Build and load the Docker image to your cluster.

$ make docker-build

# run a command to load the image to your cluster.

If you use a kind cluster, there's a useful shortcut.

$ make kind-load

Deployment

Install the CRD to the cluster.

$ make install

Deploy a controller to the cluster.

$ make deploy

Usage

Now, deploy the samples.

$ make deploy-samples

You will see sample HPA and deployment in the current context, maybe default depending on your env. The HPA resource gets updated periodically by the CronHPA.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright (c) 2024 Ubie, Inc. See LICENSE for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 contains API Schema definitions for the cronhpa v1alpha1 API group +kubebuilder:object:generate=true +groupName=cron-hpa.ubie-oss.github.com
Package v1alpha1 contains API Schema definitions for the cronhpa v1alpha1 API group +kubebuilder:object:generate=true +groupName=cron-hpa.ubie-oss.github.com

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL