-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add osm-simple-metrics container * Add chartpress section for osm-simple-metrics and helm template * Set fixed port for DB in osm-metrics * Fix mapping values - context, job metrics * Fix path for aws bucket name * Get metrics code from main branch
- Loading branch information
Ruben L. Mendoza
authored
May 16, 2023
1 parent
d516466
commit 51a2eed
Showing
7 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3' | ||
services: | ||
osm-simple-metrics: | ||
image: osm-simple-metrics:v1 | ||
build: | ||
context: ../images/osm-simple-metrics | ||
dockerfile: Dockerfile | ||
env_file: | ||
- ../envs/.env.db | ||
- ../envs/.env.cloudprovider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM node:18 | ||
|
||
# Create app directory | ||
WORKDIR /usr/src/app | ||
|
||
# Clone | ||
RUN git clone https://github.com/developmentseed/osm-simple-metrics.git ./ | ||
|
||
RUN npm install && npm link | ||
COPY start.sh / | ||
CMD /start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# OSM Simple Metrics | ||
|
||
This is a container that allows to extract simple metrics calculations for an OSM database. | ||
|
||
Repo: https://github.com/developmentseed/osm-simple-metrics | ||
|
||
#### Building the container | ||
|
||
|
||
```sh | ||
docker compose -f compose/osm-simple-metrics.yml build | ||
``` | ||
|
||
#### Access the container | ||
|
||
```sh | ||
docker-compose -f compose/osm-simple-metrics.yml run osm-simple-metrics bash | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
conString=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB} | ||
bucket_name="${AWS_S3_BUCKET#s3://}" | ||
|
||
CLIS=(cumulative_elements current_elements changeset_counts) | ||
for cli in "${CLIS[@]}"; do | ||
echo "Star running... $cli" | ||
if [ $CLOUDPROVIDER == "aws" ]; then | ||
osm-simple-metrics $cli \ | ||
$conString \ | ||
-csv \ | ||
-s3 $bucket_name | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
{{- if .Values.osmSimpleMetrics.enabled -}} | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ .Release.Name }}-osm-simple-metrics-job | ||
labels: | ||
app: {{ template "osm-seed.name" . }} | ||
component: osm-simple-metrics-job | ||
environment: {{ .Values.environment }} | ||
release: {{ .Release.Name }} | ||
spec: | ||
schedule: {{ quote .Values.osmSimpleMetrics.schedule }} | ||
startingDeadlineSeconds: 100 | ||
successfulJobsHistoryLimit: 2 | ||
failedJobsHistoryLimit: 2 | ||
concurrencyPolicy: Forbid | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: {{ .Release.Name }}-osm-simple-metrics-job | ||
image: {{ .Values.osmSimpleMetrics.image.name }}:{{ .Values.osmSimpleMetrics.image.tag }} | ||
{{- if .Values.osmSimpleMetrics.resources.enabled }} | ||
resources: | ||
requests: | ||
memory: {{ .Values.osmSimpleMetrics.resources.requests.memory }} | ||
cpu: {{ .Values.osmSimpleMetrics.resources.requests.cpu }} | ||
limits: | ||
memory: {{ .Values.osmSimpleMetrics.resources.limits.memory }} | ||
cpu: {{ .Values.osmSimpleMetrics.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: CLOUDPROVIDER | ||
value: {{ .Values.cloudProvider }} | ||
# In case cloudProvider=aws | ||
{{- if eq .Values.cloudProvider "aws" }} | ||
- name: AWS_S3_BUCKET | ||
value: {{ .Values.AWS_S3_BUCKET }} | ||
{{- end }} | ||
# In case cloudProvider=gcp | ||
{{- if eq .Values.cloudProvider "gcp" }} | ||
- name: GCP_STORAGE_BUCKET | ||
value: {{ .Values.GCP_STORAGE_BUCKET }} | ||
{{- end }} | ||
# In case cloudProvider=azure | ||
{{- if eq .Values.cloudProvider "azure" }} | ||
- name: AZURE_STORAGE_ACCOUNT | ||
value: {{ .Values.AZURE_STORAGE_ACCOUNT }} | ||
- name: AZURE_CONTAINER_NAME | ||
value: {{ .Values.AZURE_CONTAINER_NAME }} | ||
- name: AZURE_STORAGE_CONNECTION_STRING | ||
value: {{ .Values.AZURE_STORAGE_CONNECTION_STRING }} | ||
{{- end }} | ||
restartPolicy: OnFailure | ||
{{- if .Values.osmSimpleMetrics.nodeSelector.enabled }} | ||
nodeSelector: | ||
{{ .Values.osmSimpleMetrics.nodeSelector.label_key }}: {{ .Values.osmSimpleMetrics.nodeSelector.label_value }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters