-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
name: cronjobber | ||
home: https://github.com/hiddeco/cronjobber | ||
version: 0.1.1 | ||
appVersion: 0.3.0 | ||
description: Cronjobber is the cronjob controller from Kubernetes patched with time zone support. | ||
maintainers: | ||
- name: CyberHippo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Cronjobber Helm Chart | ||
|
||
## Chart Details | ||
This chart will do the following: | ||
|
||
* Installing `Cronjobber` which is the cronjob controller from Kubernetes patched with time zone support. | ||
|
||
## Installing the Chart | ||
|
||
To install the chart with the release name `my-release`: | ||
|
||
```bash | ||
$ helm install my-release chart/ | ||
``` | ||
|
||
## Configuration | ||
|
||
The following table lists the configurable parameters of the cronjobber chart and their default values. | ||
|
||
| Parameter | Description | Default | | ||
| ----------------------- | ---------------------------------- | ---------------------------------------------------------- | | ||
| `name` | Name of the resources | `cronjobber` | | ||
| `namespace` | Namespace to deploy the resources | `default` | | ||
| `image.repository` | Container image name | `quay.io/hiddeco/cronjobber` | | ||
| `image.tag` | Container image tag | `0.3.0` | | ||
| `replicas` | Number of replicas | `1` | | ||
| `resources.requests.cpu`| CPU request for the main container | `50m` | | ||
| `resources.requests.memory`| Memory request for the main container | `64Mi` | | ||
| `sidecar.enabled` | Sidecar to keep the timezone database up-to-date | `False` | | ||
| `sidecar.name` | Init container name | `init-updatetz` | | ||
| `sidecar.image.repository`| Sidecar and init container image name | `quay.io/hiddeco/cronjobber-updatetz` | | ||
| `sidecar.image.tag` | Sidecar and init container image tag | `0.1.1` | | ||
| `sidecar.resources.requests.cpu`| Sidecar and init container cpu request | `100m` | | ||
| `sidecar.resources.requests.memory`| Sidecar and init container memory request | `64Mi` | | ||
|
||
|
||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. | ||
|
||
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, | ||
|
||
```bash | ||
$ helm install --name my-release -f values.yaml chart | ||
``` | ||
|
||
> **Tip**: You can use the default [values.yaml](values.yaml) | ||
## Usage | ||
|
||
Instead of creating a [`CronJob`](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/) | ||
like you normally would, you create a `TZCronJob`, which works exactly | ||
the same but supports an additional field: `.spec.timezone`. Set this | ||
to the time zone you wish to schedule your jobs in and Cronjobber will | ||
take care of the rest. | ||
|
||
```yaml | ||
apiVersion: cronjobber.hidde.co/v1alpha1 | ||
kind: TZCronJob | ||
metadata: | ||
name: hello | ||
spec: | ||
schedule: "*/1 * * * *" | ||
timezone: "Europe/Amsterdam" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox | ||
args: | ||
- /bin/sh | ||
- -c | ||
- date; echo "Hello, World!" | ||
restartPolicy: OnFailure | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ .Values.name }} | ||
labels: | ||
name: {{ .Values.name }} | ||
rules: | ||
- apiGroups: ['cronjobber.hidde.co'] | ||
resources: ['*'] | ||
verbs: ['*'] | ||
- apiGroups: ['batch'] | ||
resources: ['jobs'] | ||
verbs: ['*'] | ||
- apiGroups: [''] | ||
resources: ['events'] | ||
verbs: ['create', 'patch', 'update'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ .Values.name }} | ||
labels: | ||
name: {{ .Values.name }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ .Values.name }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ .Values.name }} | ||
namespace: {{ .Values.namespace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: tzcronjobs.cronjobber.hidde.co | ||
spec: | ||
group: cronjobber.hidde.co | ||
version: v1alpha1 | ||
names: | ||
plural: tzcronjobs | ||
singular: tzcronjob | ||
kind: TZCronJob | ||
listKind: TZCronJobList | ||
shortNames: | ||
- tzc | ||
scope: Namespaced | ||
subresources: | ||
status: {} | ||
additionalPrinterColumns: | ||
- name: Schedule | ||
type: string | ||
description: The schedule defining the interval a TZCronJob is run | ||
JSONPath: .spec.schedule | ||
- name: Time zone | ||
type: string | ||
description: The time zone the interval of a TZCronJob is calculated in | ||
JSONPath: .spec.timezone | ||
- name: Last schedule | ||
type: date | ||
description: The last time a Job was scheduled by a TZCronJob | ||
JSONPath: .status.lastScheduleTime | ||
- name: Age | ||
type: date | ||
JSONPath: .metadata.creationTimestamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Values.name }} | ||
namespace: {{ .Values.namespace }} | ||
spec: | ||
replicas: {{ .Values.replicas }} | ||
selector: | ||
matchLabels: | ||
name: {{ .Values.name }} | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
name: {{ .Values.name }} | ||
spec: | ||
serviceAccountName: {{ .Values.name }} | ||
securityContext: | ||
fsGroup: 2 #daemon | ||
{{- if .Values.sidecar.enabled }} | ||
volumes: | ||
- name: timezonedb | ||
emptyDir: {} | ||
{{- end }} | ||
{{- if .Values.sidecar.enabled }} | ||
initContainers: | ||
- name: init-updatetz | ||
image: {{ printf "%s:%s" .Values.sidecar.image.repository .Values.sidecar.image.tag | quote }} | ||
securityContext: | ||
{{ toYaml .Values.sidecar.securityContext | indent 12 }} | ||
resources: | ||
limits: | ||
cpu: {{ .Values.sidecar.resources.requests.cpu }} | ||
memory: {{ .Values.sidecar.resources.requests.memory }} | ||
volumeMounts: | ||
- name: timezonedb | ||
mountPath: /tmp/zoneinfo | ||
readOnly: false | ||
env: | ||
- name: INIT_CONTAINER | ||
value: "true" | ||
- name: REFRESH_INTERVAL | ||
value: "3s" | ||
{{- end }} | ||
containers: | ||
- name: {{ .Values.name }} | ||
image: {{ printf "%s:%s" .Values.image.repository .Values.image.tag | quote }} | ||
resources: | ||
requests: | ||
cpu: {{ .Values.resources.requests.cpu }} | ||
memory: {{ .Values.resources.requests.memory }} | ||
args: | ||
- --log-level=info | ||
{{- if .Values.sidecar.enabled }} | ||
volumeMounts: | ||
- name: timezonedb | ||
mountPath: /usr/share/zoneinfo | ||
readOnly: true | ||
{{- end }} | ||
{{- if .Values.sidecar.enabled }} | ||
- name: updatetz | ||
image: {{ printf "%s:%s" .Values.sidecar.image.repository .Values.sidecar.image.tag | quote }} | ||
# NB: the security context configuration below may not work | ||
# out of the box on OpenShift | ||
securityContext: | ||
{{ toYaml .Values.sidecar.securityContext | indent 12 }} | ||
resources: | ||
limits: | ||
cpu: {{ .Values.sidecar.resources.requests.cpu }} | ||
memory: {{ .Values.sidecar.resources.requests.memory }} | ||
volumeMounts: | ||
- name: timezonedb | ||
mountPath: /tmp/zoneinfo | ||
readOnly: false | ||
{{- end }} | ||
{{- if .Values.nodeSelector }} | ||
nodeSelector: | ||
{{ toYaml .Values.nodeSelector | indent 8 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ .Values.name }} | ||
namespace: {{ .Values.namespace }} | ||
labels: | ||
name: {{ .Values.name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: cronjobber | ||
namespace: default | ||
image: | ||
repository: quay.io/hiddeco/cronjobber | ||
tag: 0.3.0 | ||
replicas: 1 | ||
resources: | ||
requests: | ||
cpu: 50m | ||
memory: 64Mi | ||
sidecar: | ||
enabled: false | ||
name: init-updatetz | ||
image: | ||
repository: quay.io/hiddeco/cronjobber-updatetz | ||
tag: 0.1.1 | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 64Mi | ||
# NB: the security context configuration below may not work | ||
# out of the box on OpenShift | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
nodeSelector: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
target-branch: main | ||
excluded-charts: | ||
- cronjobber |