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

feat: refactor chart to make it compatible with GeoNode projects #203

Merged
merged 4 commits into from
Aug 7, 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
24 changes: 24 additions & 0 deletions charts/geonode/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,27 @@ amqp://{{ .Values.rabbitmq.auth.username }}:{{ .Values.rabbitmq.auth.password }}
{{- define "boolean2str" -}}
{{ . | ternary "True" "False" }}
{{- end -}}

{{- define "settings_module" -}}
{{- if (not .Values.geonode.general.settings_module) -}}
{{ .Values.geonode.general.geonode_project }}.settings
{{- else -}}
{{ .Values.geonode.general.settings_module }}
{{- end -}}
{{- end -}}

{{- define "geonode_root_path" -}}
/usr/src/{{ .Values.geonode.general.geonode_project }}
{{- end -}}

{{- define "geonode_path" -}}
/usr/src/{{ .Values.geonode.general.geonode_project }}/{{ .Values.geonode.general.geonode_project }}
{{- end -}}

{{- define "initial_data_path" -}}
{{- if (eq .Values.geonode.general.geonode_project "geonode") -}}
geonode/base/fixtures/initial_data.json
{{- else -}}
initial_data.json
{{- end -}}
{{- end -}}
33 changes: 18 additions & 15 deletions charts/geonode/templates/geonode/geonode-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,18 @@ spec:
cd /usr/src/geonode/
{{ end }}

cd {{ include "geonode_root_path" .}}/
# Add config overrides
cat /usr/src/geonode/geonode/geonode-k8s-settings.py >> /usr/src/geonode/geonode/settings.py
cat /usr/src/geonode/geonode/geonode-k8s-settings-additions.py >> /usr/src/geonode/geonode/settings.py
cat /usr/src/geonode/geonode/geonode-k8s-settings.py >> {{ include "geonode_path" .}}/settings.py
cat /usr/src/geonode/geonode/geonode-k8s-settings-additions.py >> {{ include "geonode_path" .}}/settings.py

# Setup
touch /usr/src/geonode/invoke.log
dockerize -stdout /usr/src/geonode/invoke.log /usr/src/geonode/entrypoint.sh
touch {{ include "geonode_root_path" .}}/invoke.log
dockerize -stdout {{ include "geonode_root_path" .}}/invoke.log {{ include "geonode_root_path" .}}/entrypoint.sh

# Run web server
touch /var/log/geonode.log
dockerize -stdout /var/log/geonode.log /usr/local/bin/uwsgi --ini /usr/src/geonode/uwsgi.ini
dockerize -stdout /var/log/geonode.log /usr/local/bin/uwsgi --ini {{ include "geonode_root_path" .}}/uwsgi.ini

ports:
- name: http
Expand Down Expand Up @@ -133,14 +134,14 @@ spec:
- name: cache-volume
mountPath: /tmp
- name: tasks-py
mountPath: "/usr/src/geonode/tasks.py"
mountPath: "{{ include "geonode_root_path" .}}/tasks.py"
subPath: tasks.py
readOnly: true
- name: entrypoint-sh
mountPath: "/usr/src/geonode/entrypoint.sh"
mountPath: "{{ include "geonode_root_path" .}}/entrypoint.sh"
subPath: entrypoint.sh
- name: uwsgi-ini
mountPath: "/usr/src/geonode/uwsgi.ini"
mountPath: "{{ include "geonode_root_path" .}}/uwsgi.ini"
subPath: uwsgi.ini
readOnly: true
- name: geonode-k8s-settings-py
Expand All @@ -152,7 +153,7 @@ spec:
readOnly: true
{{ if .Values.geonodeFixtures }}
- name: geonode-fixtures
mountPath: "/usr/src/geonode/geonode/fixtures"
mountPath: "{{ include "geonode_path" .}}/fixtures"
readOnly: true
{{ end }}

Expand Down Expand Up @@ -199,16 +200,18 @@ spec:
cd /usr/src/geonode/
{{ end }}

cd {{ include "geonode_root_path" .}}/

{{ if .Values.geonode.sentry.enabled }}
pip install sentry-sdk
{{ end }}

# Add config overrides
cat /usr/src/geonode/geonode/geonode-k8s-settings.py >> /usr/src/geonode/geonode/settings.py
cat /usr/src/geonode/geonode/geonode-k8s-settings-additions.py >> /usr/src/geonode/geonode/settings.py
cat /usr/src/geonode/geonode/geonode-k8s-settings.py >> {{ include "geonode_path" .}}/settings.py
cat /usr/src/geonode/geonode/geonode-k8s-settings-additions.py >> {{ include "geonode_path" .}}/settings.py
# Setup
touch /var/log/celery.log
dockerize -stdout /var/log/celery.log /usr/src/geonode/entrypoint.sh celery-cmd
dockerize -stdout /var/log/celery.log {{ include "geonode_root_path" .}}/entrypoint.sh celery-cmd

envFrom:
- configMapRef:
Expand Down Expand Up @@ -260,10 +263,10 @@ spec:
- name: cache-volume
mountPath: /tmp
- name: entrypoint-sh
mountPath: "/usr/src/geonode/entrypoint.sh"
mountPath: "{{ include "geonode_root_path" .}}/entrypoint.sh"
subPath: entrypoint.sh
- name: tasks-py
mountPath: "/usr/src/geonode/tasks.py"
mountPath: "{{ include "geonode_root_path" .}}/tasks.py"
subPath: tasks.py
readOnly: true
- name: geonode-k8s-settings-py
Expand All @@ -275,7 +278,7 @@ spec:
readOnly: true
{{ if .Values.geonodeFixtures }}
- name: geonode-fixtures
mountPath: "/usr/src/geonode/geonode/fixtures"
mountPath: "{{ include "geonode_path" .}}/fixtures"
readOnly: true
{{ end }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data:
then
/usr/local/bin/invoke $@
else
/usr/local/bin/invoke $@ > /usr/src/geonode/invoke.log 2>&1
/usr/local/bin/invoke $@ > {{ include "geonode_root_path" . }}/invoke.log 2>&1
fi
echo "$@ tasks done"
}
Expand Down
4 changes: 2 additions & 2 deletions charts/geonode/templates/geonode/geonode-env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ data:

# General settings
FREETEXT_KEYWORDS_READONLY: {{ include "boolean2str" .Values.geonode.general.freetext_keywords_readonly | quote }}
FIXTURE_DIRS: "[ '/usr/src/geonode/geonode/fixtures' ]"
FIXTURE_DIRS: "[ '{{ include "geonode_path" .}}/fixtures' ]"
# PUBLISHING
RESOURCE_PUBLISHING: {{ include "boolean2str" .Values.geonode.general.publishing.resource_publishing_by_staff | quote }}
ADMIN_MODERATE_UPLOADS: {{ include "boolean2str" .Values.geonode.general.publishing.admin_moderate_uploads | quote }}
Expand Down Expand Up @@ -121,7 +121,7 @@ data:
CATALOGUE_ENGINE: geonode.catalogue.backends.pycsw_local
{{ end}}

DJANGO_SETTINGS_MODULE: {{ .Values.geonode.general.settings_module }}
DJANGO_SETTINGS_MODULE: {{ include "settings_module" . }}
DEFAULT_BACKEND_DATASTORE: datastore
DEFAULT_BACKEND_UPLOADER: geonode.importer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ data:
pty=True,
)
ctx.run(
f"python manage.py loaddata geonode/base/fixtures/initial_data.json \
f"python manage.py loaddata {{ include "initial_data_path" . }} \
--settings={_localsettings()}",
pty=True,
)
Expand Down
8 changes: 4 additions & 4 deletions charts/geonode/templates/geonode/geonode-uwsgi-ini-conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ data:
http-socket = 0.0.0.0:8001
# pidfile = /tmp/geonode.pid

chdir = /usr/src/geonode/
module = geonode.wsgi:application
chdir = {{ include "geonode_root_path" . }}/
module = {{ .Values.geonode.general.geonode_project }}.wsgi:application

strict = false
master = true
Expand All @@ -24,7 +24,7 @@ data:
# path to where uwsgi logs will be saved
logto = /var/log/geonode.log

touch-reload = /usr/src/geonode/geonode/wsgi.py
touch-reload = {{ include "geonode_path" . }}/wsgi.py
buffer-size = {{ .Values.geonode.uwsgi.buffer_size }}

harakiri = {{ .Values.geonode.uwsgi.harakiri }}
Expand All @@ -49,4 +49,4 @@ data:
cheaper-busyness-backlog-step = {{ .Values.geonode.uwsgi.cheaper_busyness_backlog_step }}

# daemonize = /var/log/uwsgi/geonode.log
# cron = -1 -1 -1 -1 -1 /usr/local/bin/python /usr/src/geonode/manage.py collect_metrics -n
# cron = -1 -1 -1 -1 -1 /usr/local/bin/python {{ include "geonode_root_path" . }}/manage.py collect_metrics -n
2 changes: 2 additions & 0 deletions charts/geonode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ geonode:
debug: False
# -- enable django static debug
debug_static: False
# -- the name of the geonode project used (keep geonode for base image)
geonode_project: geonode
# -- the settings module to load
settings_module: geonode.settings
# -- add additional settings to the settings py. This code will be appended to the end of the geonode settings.py
Expand Down
Loading