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

Added a helm implementation for the latest version of Judge0 with support for HPA #420

Open
wants to merge 1 commit into
base: master
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
23 changes: 23 additions & 0 deletions helm/charts/judge0-latest/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
22 changes: 22 additions & 0 deletions helm/charts/judge0-latest/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v2
name: judge0
description: Helm implementation of Judge0 | Free,robust and scalable open-source online code execution system.
type: application
version: 0.1.0
appVersion: "1.16.0"
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://kubernetes-charts.storage.googleapis.com/
tags:
- judge0-database
version: 7.7.2
- condition: redis.enabled
name: redis
repository: https://kubernetes-charts.storage.googleapis.com/
tags:
- judge0-redis
version: 10.2.0
maintainers:
- email: aayush.bajaj@cawstudios.com
name: Aayush Bajaj
46 changes: 46 additions & 0 deletions helm/charts/judge0-latest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
judge0
======
Helm implementation of Judge0 | Free ,robust and scalable open-source online code execution system.

Current chart version is `1.0.0`

Source code can be found [here](https://api.judge0.com)

## Chart Requirements

| Repository | Name | Version |
|------------|------|---------|
| https://kubernetes-charts.storage.googleapis.com/ | postgresql | 7.7.2 |
| https://kubernetes-charts.storage.googleapis.com/ | redis | 10.2.0 |

## Chart Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| COUNT | int | `3` | |
| MAINTENANCE_MODE | bool | `false` | |
| RAILS_MAX_THREADS | int | `10` | |
| external.postgresql.host | string | `"localhost"` | |
| external.postgresql.port | int | `5432` | |
| external.postgresql.postgresqlDatabase | string | `"judge"` | |
| external.postgresql.postgresqlPassword | string | `""` | |
| external.postgresql.postgresqlUsername | string | `"judge"` | |
| external.redis.host | string | `"localhost"` | |
| external.redis.password | string | `""` | |
| external.redis.port | int | `6379` | |
| image.registry | string | `"docker.io"` | |
| image.repository | string | `"judge0/api"` | |
| image.tag | string | `"1.5.0"` | |
| postgresql.enabled | bool | `true` | |
| postgresql.image.tag | float | `9.6` | |
| postgresql.postgresqlDatabase | string | `"judge"` | |
| postgresql.postgresqlPassword | string | `"uaeyjbzuyq"` | |
| postgresql.postgresqlUsername | string | `"judgemaster"` | |
| redis.cluster.enabled | bool | `false` | |
| redis.enabled | bool | `true` | |
| redis.password | string | `"a8iuw23iuizy"` | |
| service.annotations | string | `nil` | |
| service.externalTrafficPolicy | string | `"Cluster"` | |
| service.nodePorts.http | string | `""` | |
| service.port | int | `80` | |
| service.type | string | `"LoadBalancer"` | |
2 changes: 2 additions & 0 deletions helm/charts/judge0-latest/charts/postgresql/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
OWNERS
22 changes: 22 additions & 0 deletions helm/charts/judge0-latest/charts/postgresql/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
appVersion: 11.6.0
description: Chart for PostgreSQL, an object-relational database management system
(ORDBMS) with an emphasis on extensibility and on standards-compliance.
home: https://www.postgresql.org/
icon: https://bitnami.com/assets/stacks/postgresql/img/postgresql-stack-110x117.png
keywords:
- postgresql
- postgres
- database
- sql
- replication
- cluster
maintainers:
- email: containers@bitnami.com
name: Bitnami
- email: cedric@desaintmartin.fr
name: desaintmartin
name: postgresql
sources:
- https://github.com/bitnami/bitnami-docker-postgresql
version: 7.7.2
527 changes: 527 additions & 0 deletions helm/charts/judge0-latest/charts/postgresql/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Leave this file empty to ensure that CI runs builds against the default configuration in values.yaml.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shmVolume:
enabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copy here your postgresql.conf and/or pg_hba.conf files to use it as a config map.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
If you don't want to provide the whole configuration file and only specify certain parameters, you can copy here your extended `.conf` files.
These files will be injected as a config maps and add/overwrite the default configuration using the `include_dir` directive that allows settings to be loaded from files other than the default `postgresql.conf`.

More info in the [bitnami-docker-postgresql README](https://github.com/bitnami/bitnami-docker-postgresql#configuration-file).
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You can copy here your custom `.sh`, `.sql` or `.sql.gz` file so they are executed during the first boot of the image.

More info in the [bitnami-docker-postgresql](https://github.com/bitnami/bitnami-docker-postgresql#initializing-a-new-instance) repository.
60 changes: 60 additions & 0 deletions helm/charts/judge0-latest/charts/postgresql/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
** Please be patient while the chart is being deployed **

PostgreSQL can be accessed via port {{ template "postgresql.port" . }} on the following DNS name from within your cluster:

{{ template "postgresql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local - Read/Write connection
{{- if .Values.replication.enabled }}
{{ template "postgresql.fullname" . }}-read.{{ .Release.Namespace }}.svc.cluster.local - Read only connection
{{- end }}

{{- if and .Values.postgresqlPostgresPassword (not (eq .Values.postgresqlUsername "postgres")) }}

To get the password for "postgres" run:

export POSTGRES_ADMIN_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "postgresql.secretName" . }} -o jsonpath="{.data.postgresql-postgres-password}" | base64 --decode)
{{- end }}

To get the password for "{{ template "postgresql.username" . }}" run:

export POSTGRES_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "postgresql.secretName" . }} -o jsonpath="{.data.postgresql-password}" | base64 --decode)

To connect to your database run the following command:

kubectl run {{ template "postgresql.fullname" . }}-client --rm --tty -i --restart='Never' --namespace {{ .Release.Namespace }} --image {{ template "postgresql.image" . }} --env="PGPASSWORD=$POSTGRES_PASSWORD" {{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
--labels="{{ template "postgresql.fullname" . }}-client=true" {{- end }} --command -- psql --host {{ template "postgresql.fullname" . }} -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }} -p {{ template "postgresql.port" . }}

{{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
Note: Since NetworkPolicy is enabled, only pods with label {{ template "postgresql.fullname" . }}-client=true" will be able to connect to this PostgreSQL cluster.
{{- end }}

To connect to your database from outside the cluster execute the following commands:

{{- if contains "NodePort" .Values.service.type }}

export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "postgresql.fullname" . }})
{{ if (include "postgresql.password" . ) }}PGPASSWORD="$POSTGRES_PASSWORD" {{ end }}psql --host $NODE_IP --port $NODE_PORT -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }}

{{- else if contains "LoadBalancer" .Values.service.type }}

NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "postgresql.fullname" . }}'

export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "postgresql.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
{{ if (include "postgresql.password" . ) }}PGPASSWORD="$POSTGRES_PASSWORD" {{ end }}psql --host $SERVICE_IP --port {{ template "postgresql.port" . }} -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }}

{{- else if contains "ClusterIP" .Values.service.type }}

kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "postgresql.fullname" . }} {{ template "postgresql.port" . }}:{{ template "postgresql.port" . }} &
{{ if (include "postgresql.password" . ) }}PGPASSWORD="$POSTGRES_PASSWORD" {{ end }}psql --host 127.0.0.1 -U {{ .Values.postgresqlUsername }} -d {{- if .Values.postgresqlDatabase }} {{ .Values.postgresqlDatabase }}{{- else }} postgres{{- end }} -p {{ template "postgresql.port" . }}

{{- end }}

{{- include "postgresql.validateValues" . -}}

{{- if and (contains "bitnami/" .Values.image.repository) (not (.Values.image.tag | toString | regexFind "-r\\d+$|sha256:")) }}

WARNING: Rolling tag detected ({{ .Values.image.repository }}:{{ .Values.image.tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment.
+info https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/

{{- end }}
Loading