Skip to content

DEVOPS-2868-added-new-crons-service #106

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The `lightrun` Helm chart provides a reliable and efficient way to deploy and ma
| [**Router**](docs/components/router/index.md) | Directs traffic into the cluster. |
| [**Frontend**](docs/components/frontend.md) | Serves the user interface. |
| [**Backend**](docs/components/backend.md) | Acts as the control plane for Lightrun. |
| [**Crons**](docs/components/crons.md) | Handles background processing tasks such as scheduled jobs and batch operations. |
| [**Artifacts**](docs/components/artifacts.md) | Serves Lightrun artifacts. |
| [**Keycloak**](docs/components/keycloak.md) | Manages authentication. |
| [**Redis**](docs/components/redis.md) | Handles caching and pub/sub channels (can be local or external). |
Expand Down Expand Up @@ -97,7 +98,7 @@ To ensure a smooth and secure production deployment of Lightrun, follow these ke

#### **13. Choose Your Deployment Option**

Decide where to run your Kubernetes cluster based on your infrastructure needs. Consider whether youll deploy all services locally (including RabbitMQ, Redis, and MySQL) or use managed cloud services.
Decide where to run your Kubernetes cluster based on your infrastructure needs. Consider whether you'll deploy all services locally (including RabbitMQ, Redis, and MySQL) or use managed cloud services.

##### **Supported Kubernetes Platforms**

Expand Down
269 changes: 5 additions & 264 deletions chart/templates/backend-deployment.yaml

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletions chart/templates/crons/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
{{- if .Values.general.crons.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "lightrun-crons.name" . }}
labels:
app: {{ include "lightrun-crons.name" . }}
spec:
strategy:
type: Recreate
replicas: 1
selector:
matchLabels:
app: {{ include "lightrun-crons.name" . }}
template:
metadata:
{{- if or .Values.deployments.crons.appMetrics.exposeToDatadog .Values.deployments.crons.podAnnotations }}
annotations:
{{- with .Values.deployments.crons.podAnnotations }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.deployments.crons.appMetrics.exposeToDatadog }}
{{- $last := sub (len .Values.deployments.crons.appMetrics.includeMetrics ) 1 }}
ad.datadoghq.com/{{ include "lightrun-crons.name" . }}.checks: |
{
"openmetrics": {
"instances": [
{
"openmetrics_endpoint": "http://%%host%%:%%port%%/management/prometheus",
"namespace": "lightrun",
"metrics": [
{{- range $index ,$metricName:= .Values.deployments.crons.appMetrics.includeMetrics }}
{{- if ne $index $last }}
{"{{ $metricName }}": "crons.{{ $metricName }}"},
{{- else }}
{"{{ $metricName }}": "crons.{{ $metricName }}"}
{{- end }}
{{- end }}
]
}
]
}
}
{{- end }}
{{- end }}
labels:
app: {{ include "lightrun-crons.name" . }}
{{- with .Values.deployments.crons.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.deployments.crons.topologySpreadConstraints }}
topologySpreadConstraints:
{{ toYaml .Values.deployments.crons.topologySpreadConstraints | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "lightrun-crons.serviceAccountName" . }}
volumes:
{{- include "lightrun-backend-crons.volumes" . | nindent 8 }}
{{- include "lightrun-crons.volumes.asyncProfiler" . | nindent 8 }}
- name: dumps
emptyDir:
sizeLimit: {{ .Values.deployments.crons.dumpsEmptyDirSizeLimit }}
{{- with .Values.deployments.crons.extraVolumes }}
{{ toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.secrets.defaults.dockerhub_config }}
imagePullSecrets:
{{- if .Values.secrets.defaults.dockerhub_config.existingSecret }}
- name: {{ .Values.secrets.defaults.dockerhub_config.existingSecret }}
{{- else }}
- name: {{ include "secrets.dockerhub.name" . }}
{{- end -}}
{{- end }}
{{- if .Values.deployments.crons.podSecurityContext }}
securityContext:
{{- toYaml .Values.deployments.crons.podSecurityContext | nindent 8 }}
{{- end }}
{{ with .Values.deployments.crons.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ . }}
{{ end }}
containers:
{{- include "lightrun-crons.container.persist-async-profiler-output-files" . | nindent 8 }}
- name: {{ include "lightrun-crons.name" . }}
securityContext: {{- include "lightrun-crons.containerSecurityContext" . | indent 12 }}
image: "{{ .Values.deployments.crons.image.repository }}:{{ .Values.deployments.crons.image.tag }}"
imagePullPolicy: {{ .Values.deployments.crons.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
command: ["/usr/lib/jvm/default-jvm/bin/java"]
args: [
{{- if and .Values.general.internal_tls.enabled .Values.general.internal_tls.certificates.existing_ca_secret_name }}
"-Djavax.net.ssl.trustStore=/p12/internalca",
"-Djavax.net.ssl.trustStorePassword=$(KEYSTORE_PASSWORD)",
{{- end }}
{{- include "lightrun-crons.java.argument.asyncProfiler" . | nindent 12 }}
"-jar",
"/usr/src/lightrun/{{ .Values.deployments.crons.jar_name }}"
]
volumeMounts:
{{- include "lightrun-backend-crons.volumeMounts" . | nindent 12 }}
{{- include "lightrun-crons.volumeMounts.asyncProfiler" . | nindent 12 }}
{{- with .Values.deployments.crons.extraVolumeMounts }}
{{ toYaml . | nindent 12 }}
{{- end }}
startupProbe:
timeoutSeconds: {{ .Values.deployments.crons.startupProbe.timeoutSeconds }}
periodSeconds: {{ .Values.deployments.crons.startupProbe.periodSeconds }}
failureThreshold: {{ .Values.deployments.crons.startupProbe.failureThreshold }}
successThreshold: {{ .Values.deployments.crons.startupProbe.successThreshold }}
httpGet:
scheme: {{ include "http.scheme" . | upper }}
path: {{ .Values.deployments.crons.startupProbe.path }}
port: 8080
livenessProbe:
initialDelaySeconds: {{ .Values.deployments.crons.livenessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.deployments.crons.livenessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.deployments.crons.livenessProbe.periodSeconds }}
successThreshold: {{ .Values.deployments.crons.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.deployments.crons.livenessProbe.failureThreshold }}
httpGet:
scheme: {{ include "http.scheme" . | upper }}
path: {{ .Values.deployments.crons.livenessProbe.path }}
port: 8080
readinessProbe:
initialDelaySeconds: {{ .Values.deployments.crons.readinessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.deployments.crons.readinessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.deployments.crons.readinessProbe.periodSeconds }}
successThreshold: {{ .Values.deployments.crons.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.deployments.crons.readinessProbe.failureThreshold }}
httpGet:
scheme: {{ include "http.scheme" . | upper }}
path: {{ .Values.deployments.crons.readinessProbe.path }}
port: 8080
{{- with .Values.deployments.crons.lifecycle }}
lifecycle:
{{ toYaml . | nindent 12 }}
{{- end }}
resources:
requests:
cpu: {{ .Values.deployments.crons.resources.cpu }}
memory: {{ .Values.deployments.crons.resources.memory }}
limits:
cpu: {{ .Values.deployments.crons.resources.cpu }}
memory: {{ .Values.deployments.crons.resources.memory }}
envFrom:
- secretRef:
name: {{ include "secrets.backend.name" . }}
env:
{{- include "lightrun-backend-crons.environmentVariables" . | nindent 12 }}
- name: SPRING_PROFILES_ACTIVE
value: "prod,swagger,cluster,cron"
{{- $mergedExtraEnvs := include "lightrun-crons.mergedExtraEnvs" . }}
{{- if $mergedExtraEnvs }}
{{ $mergedExtraEnvs | nindent 12 }}
{{- end }}
{{- if not (include "lightrun-crons.hasJavaOptions" .) }}
- name: "_JAVA_OPTIONS"
value: {{- toYaml (include "calculate-heap-size" .Values.deployments.crons) | nindent 21 }}
{{- end }}

# waiting for mysql, rabbitmq and keycloak initialization
initContainers:
{{- include "lightrun-backend-crons.initContainers" . | nindent 6 }}
{{- include "lightrun-crons.initContainer.download-async-profiler" . | nindent 6 }}

{{- if .Values.general.tolerations }}
tolerations:
{{ toYaml .Values.general.tolerations | nindent 8 }}
{{- end }}
{{- if .Values.general.nodeSelector }}
nodeSelector:
{{ toYaml .Values.general.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.deployments.crons.affinity }}
affinity:
{{ toYaml .Values.deployments.crons.affinity | nindent 8 }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions chart/templates/crons/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if and .Values.general.crons.enabled .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: {{ include "lightrun-crons.name" . }}
name: {{ template "lightrun-crons.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
automountServiceAccountToken: {{ or .Values.serviceAccount.automountServiceAccountToken .Values.general.system_diagnostics_k8s_api.enabled }}
{{- end }}
Loading