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

add geoserver helm chart #17

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
Binary file removed charts/aether-kernel-0.0.1.tgz
Binary file not shown.
Binary file added charts/aether-kernel-0.0.2.tgz
Binary file not shown.
Binary file added charts/geoserver-0.1.0.tgz
Binary file not shown.
65 changes: 61 additions & 4 deletions index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@ entries:
aether-kernel:
- apiVersion: v1
appVersion: 0.8.0
created: 2018-08-28T13:30:05.903402+02:00
created: 2018-09-04T17:49:40.553948112+02:00
description: eHealthAfrica's Aether-Kernel Helm chart
digest: f517fdef7cb8645c4f6ccf294043ccfb24daf44dc33707fa5f41d2af631be7aa
name: aether-kernel
urls:
- https://ehealthafrica.github.io/helm-charts/charts/aether-kernel-0.0.2.tgz
version: 0.0.2
- apiVersion: v1
appVersion: 0.8.0
created: 2018-09-04T17:46:17.536293908+02:00
description: eHealthAfrica's Aether-Kernel Helm chart
digest: bcd9fe832ba6c7c7d17c20aef07ee952cde881ae481b094144b90bc1dc963517
name: aether-kernel
Expand All @@ -13,7 +22,7 @@ entries:
aether-odk:
- apiVersion: v1
appVersion: 0.8.0
created: 2018-08-28T13:30:05.903825+02:00
created: 2018-09-04T17:49:40.554300857+02:00
description: eHealthAfrica's ODK Helm chart
digest: f71ddf6c3a6c6f30c447227459943c449df8019a9feb33a512049e37a3d9b31a
name: aether-odk
Expand All @@ -23,11 +32,59 @@ entries:
aether-ui:
- apiVersion: v1
appVersion: 0.8.0
created: 2018-08-28T13:30:05.904252+02:00
created: 2018-09-04T17:49:40.554646426+02:00
description: eHealthAfrica's Aether-UI Helm chart
digest: b084b0d112be9cc25932bc4ef8fa60bdcd416d66cb4c1e6a1af9ee418bb7d5bd
name: aether-ui
urls:
- https://ehealthafrica.github.io/helm-charts/charts/aether-ui-0.0.1.tgz
version: 0.0.1
generated: 2018-08-28T13:30:05.902386+02:00
geoserver:
- apiVersion: v1
appVersion: 2.13.0
created: 2018-09-04T17:49:40.55500804+02:00
description: A Helm chart for Kubernetes
digest: 4598adc84e0ef18e87dc2f50da39432a1d3ee7822a94356f74a2ae00f0d10001
name: geoserver
urls:
- https://ehealthafrica.github.io/helm-charts/charts/geoserver-0.1.0.tgz
version: 0.1.0
kernel:
- apiVersion: v1
created: 2018-09-04T17:46:17.539115102+02:00
description: A Helm chart for Kubernetes
digest: 49fbc81f02a96a449dba13e701d819cdcec952305660d5080167f3d5cd8aec18
name: kernel
urls:
- https://ehealthafrica.github.io/helm-charts/charts/kernel-0.9.0.tgz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be adding charts to the index that don't exist. Please remove all the charts that are not strictly the geoserver, if we have to revert this commit we don't want to discard unrelated charts as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is regenerated every time we publish, so it is not required to track this.

version: 0.9.0
odk:
- apiVersion: v1
created: 2018-09-04T17:46:17.539883375+02:00
description: A Helm chart for Kubernetes
digest: 104a779d5254244b87ca0f23bbdfc707f618515654ae4f4dca5e1f80f9539e25
name: odk
urls:
- https://ehealthafrica.github.io/helm-charts/charts/odk-0.8.0.tgz
version: 0.8.0
producer:
- apiVersion: v1
appVersion: "1.0"
created: 2018-09-04T17:46:17.540360723+02:00
description: A Helm chart for Kubernetes
digest: b0deace2d50ee0e991ae58a45e794b4b4e6a2f7e0a4b6616a736ad15e1644db1
name: producer
urls:
- https://ehealthafrica.github.io/helm-charts/charts/producer-0.1.0.tgz
version: 0.1.0
ui:
- apiVersion: v1
appVersion: 0.9.0
created: 2018-09-04T17:46:17.541139456+02:00
description: eHealthAfrica's Aether-UI Helm chart
digest: 84e32c4448c9a287147c2d1767c94b20de7db1678899e741b1b6c4905e0bd1e6
name: ui
urls:
- https://ehealthafrica.github.io/helm-charts/charts/ui-0.1.0.tgz
version: 0.1.0
generated: 2018-09-04T17:49:40.553381602+02:00
21 changes: 21 additions & 0 deletions src/geoserver/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove all these extensions and leave only the ones that apply to our project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was generated by helm, i removed some of the unused stuff..

# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions src/geoserver/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "2.13.0"
description: A Helm chart for Kubernetes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the description, this will be visible for users who want to install the chart.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

name: geoserver
version: 0.1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we don't start at 0.0.1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to 0.0.1 for consistency with the other modules

19 changes: 19 additions & 0 deletions src/geoserver/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "geoserver.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "geoserver.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "geoserver.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "geoserver.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these instructions accurate? Can I access the app if I follow these steps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the target port for port-forward

{{- end }}
16 changes: 16 additions & 0 deletions src/geoserver/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "geoserver.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "geoserver.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
153 changes: 153 additions & 0 deletions src/geoserver/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
labels:
app: {{ .Chart.Name }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Chart.Version }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ .Chart.Name }}
release: {{ .Chart.Version }}
spec:
initContainers:
- name: init
image: postgres:9.3-alpine
command: ['bash', '-c', './scripts/init.sh']
env:
- name: PGHOST
valueFrom :
secretKeyRef:
name: {{ .Values.database.secret }}
key: host
- name: PGUSER
valueFrom:
secretKeyRef:
name: {{ .Values.database.secret }}
key: user
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.database.secret }}
key: password
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.application.secret }}
key: geoserver-database-user
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.application.secret }}
key: geoserver-database-password
- name: DB_NAME
valueFrom:
secretKeyRef:
name: {{ .Values.application.secret }}
key: geoserver-database-name
volumeMounts:
- mountPath: /scripts
name: geoserver-init
- name: {{ .Chart.Name }}
mountPath: {{ .Values.application.data_mount }}
{{ if .Values.provider.gcp }}
- name: cloudsql-instance-credentials
mountPath: /secrets/cloudsql
readOnly: true
{{ end }}
containers:
{{ if .Values.provider.gcp }}
- name: cloudsql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useful to have a pullPolicy for every image, in case we need to force a re-download.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unlikely to happen for a 3rd party image, the default of IfNotPresent should be ok

command: ["/cloud_sql_proxy",
"-instances={{ .Values.database.instance }}=tcp:5432",
"-credential_file=/secrets/cloudsql/credentials.json"]
volumeMounts:
- name: cloudsql-instance-credentials
mountPath: /secrets/cloudsql
readOnly: true
{{ end }}
- name: {{ .Chart.Name }}
image: "{{ .Values.geoserver.repository }}:{{ .Values.geoserver.tag | default .Chart.AppVersion }}"
ports:
- containerPort: 8080
livenessProbe:
initialDelaySeconds: 120
periodSeconds: 10
httpGet:
path: /
port: 8080
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these port numbers should use the values defined in the values file.

httpHeaders:
- name: X-Kubernetes-Health-Check
value: livenessProbe
- name: Host
value: {{ .Values.url }}
readinessProbe:
initialDelaySeconds: 120
periodSeconds: 10
httpGet:
path: /
port: 8080
httpHeaders:
- name: X-Kubernetes-Health-Check
value: check
- name: Host
value: {{ .Values.url }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: DEBUG
value: {{ quote .Values.debug }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inconsistent with how the other charts handle the DEBUG value. Is this because of an app constraint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adapted to other charts

{{- if .Values.extra_env_vars -}}
{{- range $key, $value := .Values.extra_env_vars }}
- name: {{ $key }}
value: {{ . | quote }}
{{- end -}}
{{ end }}
- name: GEOSERVER_DATA_DIR
value: {{ .Values.application.data_mount }}
- name: PGUSER
valueFrom:
secretKeyRef:
name: {{ .Values.application.secret }}
key: geoserver-database-user
- name: PGPORT
value: "5432"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should come from the values file.

- name: PGHOST
valueFrom :
secretKeyRef:
name: {{ .Values.database.secret }}
key: host
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.application.secret }}
key: geoserver-database-password
- name: DB_NAME
valueFrom:
secretKeyRef:
name: {{ .Values.application.secret }}
key: geoserver-database-name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a secret?

volumeMounts:
- name: {{ .Chart.Name }}
mountPath: {{ .Values.application.data_mount }}
imagePullSecrets:
- name: regsecret
volumes:
- name: {{ .Chart.Name }}
MrPink marked this conversation as resolved.
Show resolved Hide resolved
persistentVolumeClaim:
claimName: {{ .Chart.Name }}
- name: geoserver-init
configMap:
name: geoserver-init
defaultMode: 0744
{{ if .Values.provider.gcp }}
- name: cloudsql-instance-credentials
secret:
secretName: cloudsql-instance-credentials
{{ end }}
restartPolicy: Always
34 changes: 34 additions & 0 deletions src/geoserver/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{- $serviceName := include "geoserver.name" . -}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between include and template? Why do we have a variable for one but not for the other?

{{- $servicePort := .Values.service.externalPort -}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add the indirection of a variable for a simple value? If servicePort is a better name than externalPort then we should change the value name instead. And why is it only renamed here and not in service.yaml?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is used directly the templating fails, because {{ .Values.service.externalPort }}can not be resolved inside the loop

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "geoserver.name" . }}
labels:
app: {{ template "geoserver.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
tls:
- hosts:
{{- range .Values.ingress.hosts }}
- {{ . }}
{{- end }}
{{ if not .Values.ingress.certsecret|empty -}}
secretName: {{ .Values.ingress.certsecret -}}
{{ end }}
rules:
{{- range $host := .Values.ingress.hosts }}
- host: {{ $host }}
http:
paths:
- path: /
backend:
serviceName: {{ $serviceName }}
servicePort: {{ $servicePort }}
{{- end -}}
46 changes: 46 additions & 0 deletions src/geoserver/templates/init-config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: geoserver-init
data:
{{- if .Values.provider.gcp }}
init.sh: |
#!/bin/bash
apk add --no-cache ca-certificates && update-ca-certificates
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O /cloud_sql_proxy
chmod +x /cloud_sql_proxy
echo 8.8.8.8 >>/etc/resolv.conf
echo "starting proxy in background"
/cloud_sql_proxy -instances={{ .Values.database.instance }}=tcp:5432 -credential_file=/secrets/cloudsql/credentials.json &
PROXY_PID=$!
sleep 5

psql -c "CREATE DATABASE $DB_NAME;"
psql -c "CREATE USER $DB_USERNAME WITH PASSWORD '$DB_PASSWORD';"
psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USERNAME;"
psql -d $DB_NAME -c "CREATE EXTENSION postgis;"
psql -d $DB_NAME -c "CREATE EXTENSION postgis_topology;"
psql -d $DB_NAME -c "CREATE EXTENSION fuzzystrmatch;"
psql -d $DB_NAME -c "CREATE EXTENSION postgis_tiger_geocoder;"

echo "sql executed.."
sleep 5

echo "stopping proxy"
kill $PROXY_PID
# Fix EFS mount permissions
# chmod -R 775 /media
# chown -R 1000:101 /media

{{ else }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{{- else }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing whitespace here does not make things better but instead can give problems

init.sh: |
#!/bin/bash
psql -c "CREATE DATABASE $DB_NAME;"
psql -c "CREATE USER $DB_USERNAME WITH PASSWORD '$DB_PASSWORD';"
psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USERNAME;"

# Fix EFS mount permissions
# chmod -R 775 /media
# chown -R 1000:101 /media

{{- end -}}
Loading