Skip to content

Commit

Permalink
update templates and values to recommended structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Volland committed Feb 22, 2024
1 parent a14f61a commit 9b45fd0
Show file tree
Hide file tree
Showing 14 changed files with 406 additions and 87 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Please note: changes in `README.md` are ignored.
# first we need to build a container containing the default realm settings
docker build -t keycloak-data:1.0 data/keycloak/
kind load docker-image --name kind-dev-cluster keycloak-data:1.0 docker.terrestris.de/postgis/postgis:15-3.3-alpine docker-public.terrestris.de/terrestris/shogun-admin:11.4.0 docker-public.terrestris.de/shogun/shogun-boot:18.0.0 docker-public.terrestris.de/terrestris/shogun-gis-client:6.9.0
kubectl create secret generic postgis-credentials --from-literal=username=postgres --from-literal=password=postgres
kubectl create secret generic postgres-credentials --from-literal=username=postgres --from-literal=password=postgres
kubectl create secret generic keycloak-credentials --from-literal=username=admin --from-literal=password=admin
cd charts/shogun
helm dependency build
Expand Down
43 changes: 26 additions & 17 deletions charts/shogun/charts/shogun-admin/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "shogun-admin.fullname" . }}
labels:
{{ include "shogun-admin.labels" . | indent 4 }}
{{- include "shogun-admin.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{ include "shogun-admin.selectorLabels" . | indent 6 }}
{{- include "shogun-admin.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- if .Values.logs.enabled }}
fluentd: "true"
{{- end }}
{{ include "shogun-admin.labels" . | indent 8 }}
{{- include "shogun-admin.labels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "shogun-admin.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
Expand All @@ -35,6 +49,7 @@ spec:
httpGet:
path: /
port: http
initialDelaySeconds: 60
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
Expand All @@ -50,6 +65,9 @@ spec:
- name: layer-config-volume
mountPath: "/var/www/html/modelconfigs/layer.json"
subPath: layer.json
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: config-volume
configMap:
Expand All @@ -75,22 +93,13 @@ spec:
items:
- key: index-html
path: "index.html"
{{- with .Values.image.pullSecret }}
imagePullSecrets:
- name: {{ .Values.image.pullSecret }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- range .Values.hostAliases }}
hostAliases:
- ip: {{ .ip | quote }}
hostnames:
{{- range .hostnames }}
- {{ .hostname }}
{{- end }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
Expand Down
32 changes: 32 additions & 0 deletions charts/shogun/charts/shogun-admin/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "shogun-admin.fullname" . }}
labels:
{{- include "shogun-admin.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "shogun-admin.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/shogun/charts/shogun-admin/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "shogun-admin.serviceAccountName" . }}
labels:
{{- include "shogun-admin.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
77 changes: 65 additions & 12 deletions charts/shogun/charts/shogun-admin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,42 @@ logs:
image:
repository: docker-public.terrestris.de/terrestris/shogun-admin
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

service:
type: ClusterIP
port: 80

serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}
podLabels: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

ingress:
enabled: false
className: ""
Expand All @@ -31,12 +59,43 @@ ingress:
# - shogun.local

resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 250m
memory: 256Mi
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# limits:
# cpu: 1
# memory: 2Gi
# requests:
# cpu: 250m
# memory: 256Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
extraVolumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
extraVolumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

nodeSelector: {}

tolerations: []

affinity: {}

shogun:
appPrefix: ""
Expand All @@ -53,9 +112,3 @@ client:

geoserver:
url: https://geoserver.example.com

nodeSelector: {}

tolerations: []

affinity: {}
39 changes: 26 additions & 13 deletions charts/shogun/charts/shogun-boot/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "shogun-boot.fullname" . }}
labels:
{{ include "shogun-boot.labels" . | indent 4 }}
{{- include "shogun-boot.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{ include "shogun-boot.selectorLabels" . | indent 6 }}
{{- include "shogun-boot.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- if .Values.logs.enabled }}
fluentd: "true"
{{- end }}
{{ include "shogun-boot.labels" . | indent 8 }}
{{- include "shogun-boot.labels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "shogun-boot.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: check-db-ready
image: {{ .Values.postgresInitImage }}
Expand All @@ -44,7 +56,9 @@ spec:
key: password
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}"
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: DB_USER
Expand Down Expand Up @@ -94,6 +108,7 @@ spec:
httpGet:
path: /
port: http
initialDelaySeconds: 60
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
Expand All @@ -103,6 +118,9 @@ spec:
- name: log4j2-config-volume
mountPath: /config/log4j2.yml
subPath: log4j2.yml
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: config-volume
configMap:
Expand All @@ -123,14 +141,9 @@ spec:
items:
- key: init-sh
path: "init.sh"
{{- range .Values.hostAliases }}
hostAliases:
- ip: {{ .ip | quote }}
hostnames:
{{- range .hostnames }}
- {{ .hostname }}
{{- end }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
32 changes: 32 additions & 0 deletions charts/shogun/charts/shogun-boot/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "shogun-boot.fullname" . }}
labels:
{{- include "shogun-boot.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "shogun-boot.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/shogun/charts/shogun-boot/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "shogun-boot.serviceAccountName" . }}
labels:
{{- include "shogun-boot.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading

0 comments on commit 9b45fd0

Please sign in to comment.