Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

break: Cronicle Scheduler (DinD or Kubernetes job) #36

Merged
merged 8 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
kexa-chart/files/environment/*
kexa-chart/files/config/*
node_modules/*
.env
.env
charts/kexa-chart/data/*
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ kubectl create secret generic kubeconfig-secret --from-file=kubeconfig.yaml=kube

## Using Custom rules

To use custom rules, you have two option :
- Remote rules repository
- Mounting your rules folder

#### With remote repository

To use a custom remote rules folder, please inform those fields in your environment file
before adding it as a secret.

Expand All @@ -47,6 +53,19 @@ before adding it as a secret.
RULESAUTHORIZATION="Bearer github_pat_XXXXXXXXXXXXXXXXXXXXXXXX" # if repo is private
```

#### With folder mount

To mount a rule folder, create a folder named "tmpconfig".
Inside this folder, put the entire "rules" folder you want to use.
So you'll get a path like "tmpconfig/rules"

You'll need to input those information into your values.yaml when installing the chart :

```yaml
hostConfigPath: /mnt/host/c/your/path/to/tmpconfig
hostConfigFolder: tmpconfig
```


## Install the chart

Expand All @@ -60,4 +79,24 @@ helm repo add YOUR_REPOSITORY_NAME https://kexa-io.github.io/helm-charts/
helm install YOUR_RELEASE_NAME YOUR_REPOSITORY_NAME/kexa
```


## Using Grafana

Once the chart is installed, follow the instructions displayed for Grafana.

## Using the scheduler

Once the chart is installed, wait for the pod to be ready and forward the Cronicle service with:
```
kubectl port-forward svc/kexa-helm-cronicle-svc 3012:80
```

Once on the page, create a new job to schedule, with the plugin "Shell script"
Simply copy paste the content of "helm-charts/cronicle/jobCronicleScriptDocker.sh" into the script area.

Save & try to run it in the "schedule" section.

Now you can schedule Kexa as you wish through Cronicle


*Read the instructions in your console !*
10 changes: 10 additions & 0 deletions charts/kexa-chart/my-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## ENTER YOUR VALUES HERE

appname: kexa-helm

namespace: default
hostConfigPath: /mnt/host/c/your/path/to/tmpconfig
hostConfigFolder: tmpconfig
kubernetesAddon:
enabled: true
mountPath: kubernetesconfigurations
59 changes: 0 additions & 59 deletions charts/kexa-chart/store/kexa-job.yaml

This file was deleted.

8 changes: 5 additions & 3 deletions charts/kexa-chart/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ kubectl port-forward svc/YOUR_RELEASE_NAME-grafana 8080:80
# All dashboards and database connection to Postgres are already set


#### Kexa Logs ####
### Cronicle dashboard (scheduling) ###

# Forwarding port
kubectl port-forward svc/kexa-helm-cronicle-svc 3012:80

# Follow logs from job
kubectl logs job/kexa-helm-job -f
#### Kexa Logs ####

# Find logs from cronjob
kubectl get jobs
Expand Down
111 changes: 111 additions & 0 deletions charts/kexa-chart/templates/cronicle-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ .Values.appname }}-cronicle"
spec:
replicas: 1
selector:
matchLabels:
app: cronicle
template:
metadata:
labels:
app: cronicle
spec:
serviceAccountName: {{ .Values.appname }}-cronicle-sa
securityContext:
runAsUser: 1000
runAsGroup: 3000
fsGroup: 2000
containers:
- name: "{{ .Values.appname }}-cronicle-container"
image: "{{ .Values.cronicle.repository }}:{{ .Values.cronicle.tag }}"
command:
- sh
- -c
- |
chown -R 1000:3000 /opt /opt/cronicle /opt/cronicle/data /opt/cronicle/lib /opt/cronicle/node_modules /opt/cronicle/logs /opt/cronicle/plugins /opt/cronicle/bin/shell-plugin.js && \
/opt/cronicle/bin/control.sh setup && /opt/cronicle/bin/control.sh start
env:
- name: POSTGRES_STRING
valueFrom:
secretKeyRef:
name: kexa-secret
key: postgres-connection-string
- name: DOCKER_HOST
value: "tcp://{{ .Values.appname }}-dind-service:2375"
securityContext:
runAsUser: 0
volumeMounts:
- name: kexa-config-volume
mountPath: /app/config/default.json
subPath: default.json
readOnly: false
- name: kexa-env-volume
mountPath: /app/.env
subPath: .env
readOnly: false
- name: writable-app-volume
mountPath: /app/config
readOnly: false
- name: rulesuser
mountPath: /app/shared/tmpconfig
subPath: tmpconfig
readOnly: false
- name: localtime
mountPath: /etc/localtime
readOnly: false
- name: timezone
mountPath: /etc/timezone
readOnly: false
- name: data
mountPath: /opt/cronicle/data
readOnly: false
- name: logs
mountPath: /opt/cronicle/logs
readOnly: false
- name: plugins
mountPath: /opt/cronicle/plugins
readOnly: false
{{- if .Values.kubernetesAddon.enabled }}
- name: kubeconfig-volume
mountPath: "/app/{{ .Values.kubernetesAddon.mountPath }}"
readOnly: false
{{- end }}
resources:
limits:
cpu: "1000m"
memory: "2048Mi"
requests:
cpu: "500m"
memory: "1024Mi"
restartPolicy: Always
volumes:
- name: kexa-config-volume
secret:
secretName: kexa-configuration-secret
- name: kexa-env-volume
secret:
secretName: kexa-environment-secret
- name: writable-app-volume
emptyDir: {}
- name: rulesuser
persistentVolumeClaim:
claimName: {{ .Values.appname }}-kexa-rules-pvc
- name: localtime
hostPath:
path: /etc/localtime
- name: timezone
hostPath:
path: /etc/timezone
- name: data
emptyDir: {}
- name: logs
emptyDir: {}
- name: plugins
emptyDir: {}
{{- if .Values.kubernetesAddon.enabled }}
- name: kubeconfig-volume
secret:
secretName: kubeconfig-secret
{{- end }}
5 changes: 5 additions & 0 deletions charts/kexa-chart/templates/cronicle-service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.appname }}-cronicle-sa
namespace: {{ .Values.namespace }}
11 changes: 11 additions & 0 deletions charts/kexa-chart/templates/cronicle-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: "{{ .Values.appname }}-cronicle-svc"
spec:
selector:
app: cronicle
ports:
- protocol: TCP
port: 80
targetPort: 3012
34 changes: 34 additions & 0 deletions charts/kexa-chart/templates/dind-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.appname }}-dind-deployment
labels:
app: {{ .Values.appname }}-dind
spec:
replicas: 1
selector:
matchLabels:
app: {{ .Values.appname }}-dind
template:
metadata:
labels:
app: {{ .Values.appname }}-dind
spec:
containers:
- name: {{ .Values.appname }}-dind-container
image: docker:27.3.1-dind
securityContext:
privileged: true
env:
- name: DOCKER_TLS_CERTDIR
value: ""
- name: DOCKER_HOST
value: "tcp://0.0.0.0:2375"
ports:
- containerPort: 2375
volumeMounts:
- name: dind-storage
mountPath: /var/lib/docker
volumes:
- name: dind-storage
emptyDir: {}
11 changes: 11 additions & 0 deletions charts/kexa-chart/templates/dind-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.appname }}-dind-service
spec:
selector:
app: {{ .Values.appname }}-dind
ports:
- protocol: TCP
port: 2375
targetPort: 2375
2 changes: 1 addition & 1 deletion charts/kexa-chart/templates/kexa-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: CronJob
metadata:
name: "{{ .Values.appname }}-job"
spec:
schedule: "*/2 * * * *"
schedule: "0 0 29 2 1" # Use "0 0 29 2 1" for never if you're using the Cronicle scheduler
jobTemplate:
spec:
template:
Expand Down
13 changes: 13 additions & 0 deletions charts/kexa-chart/templates/kexa-rules-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.appname }}-kexa-rules-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: {{ .Values.hostConfigPath }}
storageClassName: {{ .Values.appname }}-rules-storage-class
persistentVolumeReclaimPolicy: Delete
11 changes: 11 additions & 0 deletions charts/kexa-chart/templates/kexa-rules-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.appname }}-kexa-rules-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storageClassName: {{ .Values.appname }}-rules-storage-class
6 changes: 6 additions & 0 deletions charts/kexa-chart/templates/kexa-rules-storage-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: {{ .Values.appname }}-rules-storage-class
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
Loading