diff --git a/chartpress.yaml b/chartpress.yaml index fcbbac9f..79aeab27 100644 --- a/chartpress.yaml +++ b/chartpress.yaml @@ -42,5 +42,5 @@ charts: valuesPath: osmSimpleMetrics.image changeset-replication-job: valuesPath: changesetReplicationJob.image - cgmap: - valuesPath: cgmap.image \ No newline at end of file + cgimap: + valuesPath: cgimap.image \ No newline at end of file diff --git a/compose/cgimap.yml b/compose/cgimap.yml index 099cbd26..97c0cf42 100644 --- a/compose/cgimap.yml +++ b/compose/cgimap.yml @@ -9,7 +9,6 @@ services: context: ../images/cgimap dockerfile: Dockerfile ports: - # - '8000:8000' - '80:80' volumes: - ../data/cgimap-data:/apps/data/ diff --git a/images/cgimap/Dockerfile b/images/cgimap/Dockerfile index bf78d66f..916fdb35 100644 --- a/images/cgimap/Dockerfile +++ b/images/cgimap/Dockerfile @@ -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/* @@ -43,5 +43,5 @@ RUN groupadd -g 61000 cgimap && \ USER cgimap COPY start.sh / -COPY lighttpd.conf / +COPY lighttpd.conf.template / CMD /start.sh \ No newline at end of file diff --git a/images/cgimap/lighttpd.conf b/images/cgimap/lighttpd.conf.template similarity index 95% rename from images/cgimap/lighttpd.conf rename to images/cgimap/lighttpd.conf.template index 7e42430e..b2724f73 100644 --- a/images/cgimap/lighttpd.conf +++ b/images/cgimap/lighttpd.conf.template @@ -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 diff --git a/images/cgimap/start.sh b/images/cgimap/start.sh index cabca133..c10a7566 100755 --- a/images/cgimap/start.sh +++ b/images/cgimap/start.sh @@ -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 \ diff --git a/osm-seed/templates/cgimap/cgimap-deployment.yaml b/osm-seed/templates/cgimap/cgimap-deployment.yaml new file mode 100644 index 00000000..91dd7b31 --- /dev/null +++ b/osm-seed/templates/cgimap/cgimap-deployment.yaml @@ -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 }} diff --git a/osm-seed/templates/cgimap/cgimap-ingress.yaml b/osm-seed/templates/cgimap/cgimap-ingress.yaml new file mode 100644 index 00000000..7c158b60 --- /dev/null +++ b/osm-seed/templates/cgimap/cgimap-ingress.yaml @@ -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 }} \ No newline at end of file diff --git a/osm-seed/templates/cgimap/cgimap-service.yaml b/osm-seed/templates/cgimap/cgimap-service.yaml new file mode 100644 index 00000000..a7449407 --- /dev/null +++ b/osm-seed/templates/cgimap/cgimap-service.yaml @@ -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 }} \ No newline at end of file