Skip to content

Commit

Permalink
Merge pull request #3 from cleverhu/add-helm-charts
Browse files Browse the repository at this point in the history
add helm charts
  • Loading branch information
wawa0210 authored Dec 15, 2022
2 parents 59e5ca3 + a28aa09 commit d59cefe
Show file tree
Hide file tree
Showing 17 changed files with 740 additions and 0 deletions.
22 changes: 22 additions & 0 deletions charts/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions charts/.relok8s-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# controller
- "{{ .controller.image.registry }}/{{ .controller.image.repository }}:{{ .controller.image.tag }}"

# cleanup
- "{{ .cleanup.image.registry }}/{{ .cleanup.image.repository }}:{{ .cleanup.image.tag }}"
6 changes: 6 additions & 0 deletions charts/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
version: 2.2.1
digest: sha256:6c67cfa9945bf608209d4e2ca8f17079fca4770907c7902d984187ab5b21811e
generated: "2022-12-02T16:25:03.611542+08:00"
21 changes: 21 additions & 0 deletions charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: kubernetes-cronhpa-controller
description: kubernetes-cronhpa-controller is a kubernetes cron horizontal pod autoscaler
controller using crontab like scheme. You can use CronHorizontalPodAutoscaler with
any kind object defined in kubernetes which support scale subresource(such as Deployment
and StatefulSet).
apiVersion: v2
appVersion: 1.3.0
kubeVersion: ">=1.7.0-0"
keywords:
- cronhpa
- namespace:kube-system
- releaseName:kubernetes-cronhpa-controller
- category:autoscaling
home: https://github.com/AliyunContainerService/kubernetes-cronhpa-controller
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 2.x.x
version: 0.0.3
140 changes: 140 additions & 0 deletions charts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
## Overview

kubernetes-cronhpa-controller is a kubernetes cron horizontal pod autoscaler controller using crontab like scheme. You can use CronHorizontalPodAutoscaler with any kind object defined in kubernetes which support scale subresource(such as Deployment and StatefulSet).

## Prerequisites

helm version must be v2.11.0+.

## Example

Please try out the examples in the [examples folder](https://github.com/AliyunContainerService/kubernetes-cronhpa-controller/blob/master/examples).

### 1.Deploy sample workload and cronhpa

```txt
$ kubectl apply -f examples/deployment_cronhpa.yaml
```

### 2.Check deployment replicas

```txt
$ kubectl get deploy nginx-deployment-basic
```

If you see what is shown in the figure below, you have successfully deployed workload and cronhpa.

```txt
➜ kubernetes-cronhpa-controller git:(master) ✗ kubectl get deploy nginx-deployment-basic
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment-basic 2 2 2 2 9s
```

### 3.Describe cronhpa status

```txt
$ kubectl describe cronhpa cronhpa-sample
```

```txt
Name: cronhpa-sample
Namespace: default
Labels: controller-tools.k8s.io=1.0
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"autoscaling.alibabacloud.com/v1beta1","kind":"CronHorizontalPodAutoscaler","metadata":{"annotations":{},"labels":{"controll...
API Version: autoscaling.alibabacloud.com/v1beta1
Kind: CronHorizontalPodAutoscaler
Metadata:
Creation Timestamp: 2019-04-14T10:42:38Z
Generation: 1
Resource Version: 4017247
Self Link: /apis/autoscaling.alibabacloud.com/v1beta1/namespaces/default/cronhorizontalpodautoscalers/cronhpa-sample
UID: 05e41c95-5ea2-11e9-8ce6-00163e12e274
Spec:
Jobs:
Name: scale-down
Schedule: 30 */1 * * * *
Target Size: 1
Name: scale-up
Schedule: 0 */1 * * * *
Target Size: 3
Scale Target Ref:
API Version: apps/v1beta2
Kind: Deployment
Name: nginx-deployment-basic
Status:
Conditions:
Job Id: 38e79271-9a42-4131-9acd-1f5bfab38802
Last Probe Time: 2019-04-14T10:43:02Z
Message:
Name: scale-down
Schedule: 30 */1 * * * *
State: Submitted
Job Id: a7db95b6-396a-4753-91d5-23c2e73819ac
Last Probe Time: 2019-04-14T10:43:02Z
Message:
Name: scale-up
Schedule: 0 */1 * * * *
State: Submitted
Events: <none>
```

if the `State` of cronhpa job is `Succeed` that means the last execution is successful. `Submitted` means the cronhpa job is submitted to the cron engine but haven't be executed so far. Wait for 30s seconds and check the status.

```txt
➜ kubernetes-cronhpa-controller git:(master) kubectl describe cronhpa cronhpa-sample
Name: cronhpa-sample
Namespace: default
Labels: controller-tools.k8s.io=1.0
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"autoscaling.alibabacloud.com/v1beta1","kind":"CronHorizontalPodAutoscaler","metadata":{"annotations":{},"labels":{"controll...
API Version: autoscaling.alibabacloud.com/v1beta1
Kind: CronHorizontalPodAutoscaler
Metadata:
Creation Timestamp: 2019-04-15T06:41:44Z
Generation: 1
Resource Version: 15673230
Self Link: /apis/autoscaling.alibabacloud.com/v1beta1/namespaces/default/cronhorizontalpodautoscalers/cronhpa-sample
UID: 88ea51e0-5f49-11e9-bd0b-00163e30eb10
Spec:
Jobs:
Name: scale-down
Schedule: 30 */1 * * * *
Target Size: 1
Name: scale-up
Schedule: 0 */1 * * * *
Target Size: 3
Scale Target Ref:
API Version: apps/v1beta2
Kind: Deployment
Name: nginx-deployment-basic
Status:
Conditions:
Job Id: 84818af0-3293-43e8-8ba6-6fd3ad2c35a4
Last Probe Time: 2019-04-15T06:42:30Z
Message: cron hpa job scale-down executed successfully
Name: scale-down
Schedule: 30 */1 * * * *
State: Succeed
Job Id: f8579f11-b129-4e72-b35f-c0bdd32583b3
Last Probe Time: 2019-04-15T06:42:20Z
Message:
Name: scale-up
Schedule: 0 */1 * * * *
State: Submitted
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Succeed 5s cron-horizontal-pod-autoscaler cron hpa job scale-down executed successfully
```

## configuration

The following table lists the configurable parammeters of the cronhpa ahd their default values.

| Parameter | Description | Default |
| ----------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| cleanup.cleanupCustomResource | Attempt to delete CRDs when the release is removed. This option may be useful while testing . | true |
| crds.needcreate | Whether or not crds is created | true |
| controller.image | image of the deployment cronhpa | registry.cn-beijing.aliyuncs.com/acs/kubernetes-cronhpa-controller:v1.0 |
| global.rbac.create | Whether or not rbac is created | true |
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
helm.sh/resource-policy: keep
creationTimestamp: null
name: cronhorizontalpodautoscalers.autoscaling.alibabacloud.com
spec:
group: autoscaling.alibabacloud.com
names:
kind: CronHorizontalPodAutoscaler
listKind: CronHorizontalPodAutoscalerList
plural: cronhorizontalpodautoscalers
shortNames:
- cronhpa
singular: cronhorizontalpodautoscaler
scope: Namespaced
versions:
- name: v1beta1
served: true
storage: true
schema:
openAPIV3Schema:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
spec:
properties:
excludeDates:
items:
type: string
type: array
jobs:
items:
properties:
name:
type: string
runOnce:
type: boolean
schedule:
type: string
targetSize:
format: int32
type: integer
required:
- name
- schedule
- targetSize
type: object
type: array
scaleTargetRef:
properties:
apiVersion:
type: string
kind:
type: string
name:
type: string
required:
- apiVersion
- kind
- name
type: object
required:
- jobs
- scaleTargetRef
type: object
status:
properties:
conditions:
items:
properties:
jobId:
type: string
lastProbeTime:
format: date-time
type: string
message:
type: string
name:
type: string
runOnce:
type: boolean
schedule:
type: string
state:
type: string
targetSize:
format: int32
type: integer
required:
- jobId
- lastProbeTime
- name
- runOnce
- schedule
- state
- targetSize
type: object
type: array
excludeDates:
items:
type: string
type: array
scaleTargetRef:
properties:
apiVersion:
type: string
kind:
type: string
name:
type: string
required:
- apiVersion
- kind
- name
type: object
type: object
type: object
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit d59cefe

Please sign in to comment.