Skip to content

Commit

Permalink
Merge branch 'main' into issue_#144_Task_use_official_geonode_docker_…
Browse files Browse the repository at this point in the history
…images
  • Loading branch information
mwallschlaeger authored Feb 27, 2024
2 parents c27ef09 + f6b4313 commit de2321e
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 110 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ helm upgrade --cleanup-on-fail --install --namespace geonode --create-namespac

## Delete Installation
```bash
helm delete --namespace geonode geonode charts/geonode
helm delete --namespace geonode geonode geonode
```

## Contribution
Expand Down
4 changes: 0 additions & 4 deletions charts/geonode/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ maintainers:
email: [email protected]
url: https://github.com/mwallschlaeger
dependencies:
- name: postgres-operator-ui
version: ~1.9.0
repository: https://opensource.zalando.com/postgres-operator/charts/postgres-operator-ui/
condition: postgres-operator-ui.enabled
- name: postgres-operator
version: ~1.9.0
repository: https://opensource.zalando.com/postgres-operator/charts/postgres-operator/
Expand Down
32 changes: 11 additions & 21 deletions charts/geonode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Helm Chart for Geonode. Supported versions: Geonode: 4.1.3, Geoserver: 2.23.0, p
|------------|------|---------|
| https://charts.bitnami.com/bitnami | memcached | ~6.x.x |
| https://charts.bitnami.com/bitnami | rabbitmq | ~10.1.7 |
| https://opensource.zalando.com/postgres-operator/charts/postgres-operator-ui/ | postgres-operator-ui | ~1.9.0 |
| https://opensource.zalando.com/postgres-operator/charts/postgres-operator/ | postgres-operator | ~1.9.0 |

## Values
Expand Down Expand Up @@ -172,34 +171,25 @@ Helm Chart for Geonode. Supported versions: Geonode: 4.1.3, Geoserver: 2.23.0, p
| nginx.resources.limits.memory | string | `"1Gi"` | limits memory as in resource.limits.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| nginx.resources.requests.cpu | string | `"500m"` | requested cpu as in resource.requests.cpu (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| nginx.resources.requests.memory | string | `"1Gi"` | requested memory as in resource.requests.memory (https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) |
| postgres-operator-ui.enabled | bool | `false` | |
| postgres-operator-ui.envs.operatorApiUrl | string | `"http://{{ $.Release.Name }}-postgres-operator:8080"` | |
| postgres-operator-ui.ingress.enabled | bool | `false` | |
| postgres-operator-ui.ingress.hosts[0].host | string | `"postgres-ui"` | |
| postgres-operator-ui.ingress.hosts[0].paths[0] | string | `""` | |
| postgres-operator-ui.ingress.ingressClassName | string | `nil` | |
| postgres-operator-ui.replicaCount | int | `1` | |
| postgres-operator-ui.service.port | int | `80` | |
| postgres-operator-ui.service.type | string | `"ClusterIP"` | |
| postgres-operator.configLoggingRestApi.api_port | int | `8080` | REST API listener listens to this port |
| postgres-operator.enabled | bool | `true` | enable postgres-operator (this or postgresql.enabled NOT both ) |
| postgres-operator.operatorApiUrl | string | `"http://{{ .Release.Name }}-postgres-operator:8080"` | ??? |
| postgres-operator.podServiceAccount | object | `{"name":""}` | not setting the podServiceAccount name will leed to generation of this name. This allows to run multiple postgres-operators in a single kubernetes cluster. just seperating them by namespace. |
| postgres-operator.storageClass | string | `nil` | postgress pv storageclass |
| postgres.external_postgres.enabled | bool | `false` | |
| postgres.external_postgres.hostname | string | `"my-external-postgres.com"` | |
| postgres.external_postgres.port | int | `5432` | |
| postgres.external_postgres.secret.existingSecretName | string | `""` | name of an existing Secret to use. Set, if you want to separately maintain the Secret. |
| postgres.external_postgres.secret.geodata_password | string | `"geogeonode"` | |
| postgres.external_postgres.secret.geonode_password | string | `"geonode"` | |
| postgres.external_postgres.secret.postgres_password | string | `"postgres"` | |
| postgres.external.hostname | string | `"my-external-postgres.com"` | |
| postgres.external.port | int | `5432` | |
| postgres.external.secret.existingSecretName | string | `""` | name of an existing Secret to use. Set, if you want to separately maintain the Secret. |
| postgres.external.secret.geodata_password | string | `"geogeonode"` | |
| postgres.external.secret.geonode_password | string | `"geonode"` | |
| postgres.external.secret.postgres_password | string | `"postgres"` | |
| postgres.geodata_databasename_and_username | string | `"geodata"` | geoserver database name and username |
| postgres.geonode_databasename_and_username | string | `"geonode"` | geonode database name and username |
| postgres.operator_manifest.numberOfInstances | int | `1` | number of database instances |
| postgres.operator_manifest.pod_name | string | `"postgresql"` | pod name for postgres containers == teamID for mainifest |
| postgres.operator_manifest.postgres_version | int | `15` | postgres version |
| postgres.operator_manifest.storageSize | string | `"3Gi"` | Database storage size |
| postgres.operator.numberOfInstances | int | `1` | number of database instances |
| postgres.operator.pod_name | string | `"postgresql"` | pod name for postgres containers == teamID for mainifest |
| postgres.operator.postgres_version | int | `15` | postgres version |
| postgres.operator.storageSize | string | `"3Gi"` | Database storage size |
| postgres.schema | string | `"public"` | database schema |
| postgres.type | string | `"operator"` | type of used postgres: "operator" or "external". \ if external is used, host, port and password have to be set in postgres.external using values or external secret if operator is used, host port and passwords get set automatically using postgres-operator. If your Kubernetes cluster does not have a running postgres-operator, you can install the postgres-operator with postgres-operator.enabled = true |
| postgres.username | string | `"postgres"` | postgres username |
| pycsw.config | string | based of pycsw example.cfg: https://github.com/geopython/pycsw/blob/master/docker/pycsw.cfg | pycsw config file parameters, see docs: https://docs.pycsw.org/_/downloads/en/latest/pdf/ |
| pycsw.container_name | string | `"pycsw"` | pycsw container name |
Expand Down
46 changes: 23 additions & 23 deletions charts/geonode/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{- end -}}

{{- define "postgres_pod_name" -}}
{{ .Release.Name }}-{{ .Values.postgres.operator_manifest.pod_name }}
{{ .Release.Name }}-{{ .Values.postgres.operator.pod_name }}
{{- end -}}

{{- define "nginx_pod_name" -}}
Expand All @@ -29,77 +29,77 @@

# Database definitions
{{- define "database_hostname" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
{{ include "postgres_pod_name" . }}
{{- else if .Values.postgres.external_postgres.enabled -}}
{{- .Values.postgres.external_postgres.hostname -}}
{{- else if (eq .Values.postgres.type "external") -}}
{{- .Values.postgres.external.hostname -}}
{{- end -}}
{{- end -}}

{{- define "database_port" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
5432
{{- else if .Values.postgres.external_postgres.enabled -}}
{{ .Values.postgres.external_postgres.port }}
{{- else if (eq .Values.postgres.type "external") -}}
{{ .Values.postgres.external.port }}
{{- end -}}
{{- end -}}

# secret key reference for the password of user: .Values.postgres.username
{{- define "database_postgres_password_secret_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
"{{ .Values.postgres.username }}.{{ include "postgres_pod_name" . }}.credentials.postgresql.acid.zalan.do"
{{- else if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName ) -}}
{{- else if and (eq .Values.postgres.type "external") (not .Values.postgres.external.secret.existingSecretName ) -}}
"{{ .Release.Name }}-postgres-external-secrets"
{{- else -}}
"{{.Values.postgres.external_postgres.secret.existingSecretName }}"
"{{.Values.postgres.external.secret.existingSecretName }}"
{{- end -}}
{{- end -}}

# secret key reference for the password of user: .Values.postgres.geonode_databasename_and_username
{{- define "database_geonode_password_secret_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
"{{ .Values.postgres.geonode_databasename_and_username }}.{{ include "postgres_pod_name" . }}.credentials.postgresql.acid.zalan.do"
{{- else if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName ) -}}
{{- else if and (eq .Values.postgres.type "external") (not .Values.postgres.external.secret.existingSecretName ) -}}
"{{ .Release.Name }}-geonode-external-secrets"
{{- else -}}
"{{.Values.postgres.external_postgres.secret.existingSecretName }}"
"{{.Values.postgres.external.secret.existingSecretName }}"
{{- end -}}
{{- end -}}

# secret key reference for the password of user: .Values.postgres.geodata_databasename_and_username
{{- define "database_geodata_password_secret_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
"{{ .Values.postgres.geodata_databasename_and_username }}.{{ include "postgres_pod_name" . }}.credentials.postgresql.acid.zalan.do"
{{- else if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName ) -}}
{{- else if and (eq .Values.postgres.type "external") (not .Values.postgres.external.secret.existingSecretName ) -}}
"{{ .Release.Name }}-geodata-external-secrets"
{{- else -}}
"{{.Values.postgres.external_postgres.secret.existingSecretName }}"
{{- else if .Values.postgres.external.secret.existingSecretName -}}
"{{.Values.postgres.external.secret.existingSecretName }}"
{{- end -}}
{{- end -}}

# define password key name in geonode postgres secret
{{- define "database_geonode_password_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
password
{{- else if .Values.postgres.external_postgres.enabled -}}
{{- else if (eq .Values.postgres.type "external") -}}
geonode-password
{{- end -}}
{{- end -}}

# define password key name in geodata postgres secret
{{- define "database_geodata_password_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
password
{{- else if .Values.postgres.external_postgres.enabled -}}
{{- else if (eq .Values.postgres.type "external") -}}
geodata-password
{{- end -}}
{{- end -}}

# define password key name in postgres postgres secret
{{- define "database_postgres_password_key_ref" -}}
{{- if (index .Values "postgres-operator" "enabled") -}}
{{- if (eq .Values.postgres.type "operator") -}}
password
{{- else if .Values.postgres.external_postgres.enabled -}}
{{- else if (eq .Values.postgres.type "external") -}}
postgres-password
{{- end -}}
{{- end -}}
Expand Down
18 changes: 5 additions & 13 deletions charts/geonode/templates/geonode/geonode-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
# check if external and postgres-operator database backends are active
{{ $postgres_operator := index .Values "postgres-operator" "enabled" }}
{{ $postgres_operator_ui := index .Values "postgres-operator-ui" "enabled"}}
# check if multiple database backends are active
{{ if and .Values.postgres.external_postgres.enabled $postgres_operator }}
{{- fail "Error, two Database backends enabled, check .Values.postgres.external_postgres or .Values.postgres-operator ..." }}
{{ else if and (not .Values.postgres.external_postgres.enabled) (not $postgres_operator) }}
{{- fail "Error, no Database backend is enabled, check .Values.postgres.external_postgres or .Values.postgres-operator ..." }}
# check if postgres.type is set to external operator
{{ $is_operator := (eq .Values.postgres.type "operator") }}
{{ $is_external := (eq .Values.postgres.type "external") }}
{{ if not (or $is_operator $is_external) }}
{{- fail "Deploymnent FAILED, unknown postgres.type defined, please set postgres.type to operator or external ..." }}
{{ end }}
# check if operator ui is activated even postgres-operator is disabled
{{ if and ($postgres_operator_ui) (not $postgres_operator) }}
{{- fail "Error, postgres-operator-ui enabled even postgres-operator ist disabled ..." }}
{{ end }}


# geonode stateful set
apiVersion: apps/v1
Expand Down
9 changes: 0 additions & 9 deletions charts/geonode/templates/geoserver/geoserver-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ spec:
containers:
- name: {{ .Values.geoserver.container_name }}
image: "{{ .Values.geoserver.image.name }}:{{ .Values.geoserver.image.tag }}"
# temporary overloading entry point to fix j2 template: https://github.com/GeoNode/geonode/issues/11318
command:
- sh
- -c
- |
TMP_DB_PORT={{ include "database_port" . }}
{{`sed -i 's/db:5432/{{ DATABASE_HOST }}:$TMP_DB_PORT/g' /templates/geofence/geofence-datasource-ovr.properties.j2`}}
/usr/local/tomcat/tmp/entrypoint.sh
ports:
- containerPort: {{ .Values.geoserver.port }}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName )}}
{{ if and (eq .Values.postgres.type "external") (not .Values.postgres.external.secret.existingSecretName )}}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-geodata-external-secrets
namespace: {{ .Release.Namespace }}
type: Opaque
data:
geodata_password: {{ .Values.postgres.external_postgres.secret.geodata_password | b64enc }}
geodata_password: {{ .Values.postgres.external.secret.geodata_password | b64enc }}
{{ end }}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName )}}
{{ if and (eq .Values.postgres.type "external") (not .Values.postgres.external.secret.existingSecretName )}}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-geonode-external-secrets
namespace: {{ .Release.Namespace }}
type: Opaque
data:
geonode_password: {{ .Values.postgres.external_postgres.secret.geonode_password | b64enc }}
geonode_password: {{ .Values.postgres.external.secret.geonode_password | b64enc }}
{{ end }}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{ if and .Values.postgres.external_postgres.enabled (not .Values.postgres.external_postgres.secret.existingSecretName )}}
{{ if and (eq .Values.postgres.type "external") (not .Values.postgres.external.secret.existingSecretName )}}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-postgres-external-secrets
namespace: {{ .Release.Namespace }}
type: Opaque
data:
postgres_password: {{ .Values.postgres.external_postgres.secret.postgres_password | b64enc }}
postgres_password: {{ .Values.postgres.external.secret.postgres_password | b64enc }}
{{ end }}
9 changes: 4 additions & 5 deletions charts/geonode/templates/postgres/postgresql-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

{{ $postgres_operator := index .Values "postgres-operator" "enabled" }}
{{ if $postgres_operator }}
{{- if eq .Values.postgres.type "operator" -}}
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
name: "{{ include "postgres_pod_name" . }}"
spec:
teamId: {{ .Release.Name | quote }}
volume:
size: {{ .Values.postgres.operator_manifest.storageSize }}
numberOfInstances: {{ int .Values.postgres.operator_manifest.numberOfInstances }}
size: {{ .Values.postgres.operator.storageSize }}
numberOfInstances: {{ int .Values.postgres.operator.numberOfInstances }}
users:
{{ .Values.postgres.username }}:
- superuser
Expand Down Expand Up @@ -38,5 +37,5 @@ spec:
pg_partman: {{ .Values.postgres.schema }}
postgis: {{ .Values.postgres.schema }}
postgresql:
version: {{ .Values.postgres.operator_manifest.postgres_version | quote }}
version: {{ .Values.postgres.operator.postgres_version | quote }}
{{ end }}
26 changes: 7 additions & 19 deletions charts/geonode/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,11 @@ rabbitmq:
cpu: "750m"

postgres:
# -- type of used postgres: "operator" or "external". \
# if external is used, host, port and password have to be set in postgres.external using values or external secret
# if operator is used, host port and passwords get set automatically using postgres-operator. If your Kubernetes cluster
# does not have a running postgres-operator, you can install the postgres-operator with postgres-operator.enabled = true
type: operator
# -- postgres username
username: postgres
# -- database schema
Expand All @@ -609,7 +614,7 @@ postgres:
geodata_databasename_and_username: geodata

# configuration for postgres operator database manifest
operator_manifest:
operator:
# -- pod name for postgres containers == teamID for mainifest
pod_name: postgresql
# -- Database storage size
Expand All @@ -622,8 +627,7 @@ postgres:
# infos @ https://postgres-operator.readthedocs.io/en/refactoring-sidecars/user/
# get password after creation via: kubectl get secret {{ .Release.name }}.{{ .Release.name }}-{{ container_name }}.credentials -o 'jsonpath={.data.password}' | base64 -d

external_postgres:
enabled: False
external:
hostname: my-external-postgres.com
port: 5432
secret:
Expand All @@ -648,22 +652,6 @@ postgres-operator:
podServiceAccount:
name: ""

# VALUES DEFINITION: https://github.com/zalando/postgres-operator/blob/master/charts/postgres-operator-ui/values.yaml
postgres-operator-ui:
enabled: False
replicaCount: 1
envs:
operatorApiUrl: "http://{{ $.Release.Name }}-postgres-operator:8080"
service:
type: ClusterIP
port: 80
ingress:
enabled: False
ingressClassName:
hosts:
- host: postgres-ui
paths: [""]

# -- (map of fixture files) Fixture files which shall be made available under /usr/src/geonode/geonode/fixtures (refer to https://docs.djangoproject.com/en/4.2/howto/initial-data/)
geonodeFixtures:
# @gignore
Expand Down
4 changes: 2 additions & 2 deletions docs/external-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ Now you have to configure your values.yaml to use this external database. You ca

```
postgres:
type: external
username: postgres
geonode_databasename_and_username: geonode
geodata_databasename_and_username: geodata
external_postgres:
enabled: True
external:
hostname: my-external-postgres.com
port: 5432
postgres_password:
Expand Down
6 changes: 3 additions & 3 deletions minikube-values-external-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ rabbitmq:
password: rabbit_password

postgres:
type: external
username: postgres
geonode_databasename_and_username: geonode
geodata_databasename_and_username: geodata

external_postgres:
enabled: True
external:
hostname: "external-postgres.com"
port: 5432
secret:
postgres_password:
geonode_password:
geodata_password:

postgres-operator:
enabled: False

6 changes: 2 additions & 4 deletions minikube-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ geonode:
pycsw:
enabled: False

postgres-operator-ui:
enabled: False

postgres-operator:
enabled: True

postgres:
operator_manifest:
type: operator
operator:
storageSize: 2Gi
numberOfInstances: 1
postgres_version: 15
Expand Down

0 comments on commit de2321e

Please sign in to comment.