Skip to content

Commit

Permalink
Add helm template for cgimap
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Sep 1, 2023
1 parent e0f2388 commit a798afd
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 6 deletions.
4 changes: 2 additions & 2 deletions chartpress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ charts:
valuesPath: osmSimpleMetrics.image
changeset-replication-job:
valuesPath: changesetReplicationJob.image
cgmap:
valuesPath: cgmap.image
cgimap:
valuesPath: cgimap.image
1 change: 0 additions & 1 deletion compose/cgimap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ services:
context: ../images/cgimap
dockerfile: Dockerfile
ports:
# - '8000:8000'
- '80:80'
volumes:
- ../data/cgimap-data:/apps/data/
Expand Down
4 changes: 2 additions & 2 deletions images/cgimap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RUN apt-get update -qq && \
apt-get install -y \
libfcgi-bin libmemcached11 libboost-locale1.71.0 libboost-program-options1.71.0 \
libxml2 libcrypto++6 libyajl2 libpqxx-6.4 zlib1g libargon2-1 \
--no-install-recommends lighttpd && \
--no-install-recommends lighttpd gettext-base && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -43,5 +43,5 @@ RUN groupadd -g 61000 cgimap && \

USER cgimap
COPY start.sh /
COPY lighttpd.conf /
COPY lighttpd.conf.template /
CMD /start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $HTTP["request-method"] == "PUT" {
}

$HTTP["url"] =~ "^/(?!(dispatch\.map))" {
proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "3000" ) ) )
proxy.server = ( "" => ( ( "host" => "${API_WEB_HOST}", "port" => "${API_WEB_PORT}" ) ) )
}

fastcgi.debug = 1
Expand Down
4 changes: 4 additions & 0 deletions images/cgimap/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
set -ex

# Make sure that the follow env vars has been declare
# API_WEB_HOST
# API_WEB_PORT
envsubst < lighttpd.conf.template > lighttpd.conf
/usr/sbin/lighttpd -f lighttpd.conf

/usr/local/bin/openstreetmap-cgimap \
Expand Down
64 changes: 64 additions & 0 deletions osm-seed/templates/cgimap/cgimap-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- if .Values.cgimap.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "osm-seed.fullname" . }}-cgimap
labels:
app: {{ template "osm-seed.name" . }}
component: cgimap-deployment
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
replicas: {{ .Values.cgimap.replicaCount }}
selector:
matchLabels:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-cgimap
template:
metadata:
labels:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-cgimap
spec:
containers:
- name: {{ .Chart.Name }}-cgimap
image: "{{ .Values.cgimap.image.name }}:{{ .Values.cgimap.image.tag }}"
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 600 # 10 min, because the compile process takes time.
timeoutSeconds: 30
{{- if .Values.cgimap.resources.enabled }}
resources:
requests:
memory: {{ .Values.cgimap.resources.requests.memory }}
cpu: {{ .Values.cgimap.resources.requests.cpu }}
limits:
memory: {{ .Values.cgimap.resources.limits.memory }}
cpu: {{ .Values.cgimap.resources.limits.cpu }}
{{- end }}
env:
- name: POSTGRES_HOST
value: {{ .Release.Name }}-db
- name: POSTGRES_DB
value: {{ .Values.db.env.POSTGRES_DB }}
- name: POSTGRES_PASSWORD
value: {{ quote .Values.db.env.POSTGRES_PASSWORD }}
- name: POSTGRES_USER
value: {{ .Values.db.env.POSTGRES_USER }}
- name: API_WEB_HOST
value: {{ .Release.Name }}-web
- name: API_WEB_PORT
value: 80
{{- if .Values.cgimap.nodeSelector.enabled }}
nodeSelector:
{{ .Values.cgimap.nodeSelector.label_key }} : {{ .Values.cgimap.nodeSelector.label_value }}
{{- end }}
{{- end }}
26 changes: 26 additions & 0 deletions osm-seed/templates/cgimap/cgimap-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if and .Values.cgimap.enabled (eq .Values.serviceType "ClusterIP") }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ template "osm-seed.fullname" . }}-ingress-cgimap-api
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
spec:
tls:
- hosts:
- cgimap.{{ .Values.domain }}
secretName: {{ template "osm-seed.fullname" . }}-secret-cgimap

rules:
- host: cgimap.{{ .Values.domain }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ template "osm-seed.fullname" . }}-cgimap
port:
number: 80
{{- end }}
43 changes: 43 additions & 0 deletions osm-seed/templates/cgimap/cgimap-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.cgimap.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "osm-seed.fullname" . }}-cgimap
labels:
app: {{ template "osm-seed.name" . }}
component: cgimap-service
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
annotations:
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: {{ .Values.AWS_SSL_ARN }}
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https
{{- end }}
{{- if eq .Values.serviceType "ClusterIP" }}
kubernetes.io/ingress.class: nginx
cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
{{- else }}
fake.annotation: fake
{{- end }}
{{- with .Values.cgimap.serviceAnnotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.serviceType }}
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
{{- if and (eq .Values.serviceType "LoadBalancer") .Values.AWS_SSL_ARN }}
- port: 443
targetPort: http
protocol: TCP
name: https
{{- end }}
selector:
app: {{ template "osm-seed.name" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}-cgimap
{{- end }}

0 comments on commit a798afd

Please sign in to comment.