Skip to content

Commit

Permalink
Merge pull request #10 from MapColonies/helm
Browse files Browse the repository at this point in the history
ops: supporting helm deployment
  • Loading branch information
almog8k authored Sep 18, 2024
2 parents b6ac542 + a99e3c2 commit ff513ec
Show file tree
Hide file tree
Showing 18 changed files with 422 additions and 273 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ lerna-debug.log*
# Development tools
.idea
local.json
local.yaml

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
Expand Down
2 changes: 1 addition & 1 deletion catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ metadata:
spec:
type: service
lifecycle: production
owner: DevInfra
owner: Raster
system: boilerplate
61 changes: 60 additions & 1 deletion config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"prettyPrint": {
"__name": "LOG_PRETTY_PRINT_ENABLED",
"__format": "boolean"
},
"pinoCaller": {
"__name": "LOG_PINO_CALLER_ENABLED",
"__format": "boolean"
}
},
"tracing": {
Expand All @@ -17,7 +21,11 @@
"metrics": {
"enabled": "TELEMETRY_METRICS_ENABLED",
"url": "TELEMETRY_METRICS_URL",
"interval": "TELEMETRY_METRICS_INTERVAL"
"interval": "TELEMETRY_METRICS_INTERVAL",
"buckets": {
"__name": "TELEMETRY_METRICS_BUCKETS",
"__format": "json"
}
}
},
"server": {
Expand All @@ -35,5 +43,56 @@
}
}
}
},
"httpRetry": {
"attempts": "HTTP_RETRY_ATTEMPTS",
"delay": "HTTP_RETRY_DELAY",
"shouldResetTimeout": {
"__name": "HTTP_RETRY_RESET_TIMEOUT",
"__format": "boolean"
}
},
"disableHttpClientLogs": {
"__name": "DISABLE_HTTP_CLIENT_LOGS",
"__format": "boolean"
},
"mapServerCacheType": "MAP_SERVER_CACHE_TYPE",
"jobManagement": {
"config": {
"jobManagerBaseUrl": "JOB_MANAGER_BASE_URL",
"heartbeat": {
"baseUrl": "HEARTBEAT_BASE_URL",
"intervalMs": "HEARTBEAT_INTERVAL_MS"
},
"dequeueIntervalMs": "DEQUEUE_INTERVAL_MS"
},
"ingestion": {
"pollingTasks": {
"init": "INGESTION_POLLING_INIT_TASK",
"finalize": "INGESTION_POLLING_FINALIZE_TASK"
},
"jobs": {
"new": {
"type": "INGESTION_NEW_JOB_TYPE"
},
"update": {
"type": "INGESTION_UPDATE_JOB_TYPE"
},
"swapUpdate": {
"type": "INGESTION_SWAP_UPDATE_JOB_TYPE"
}
},
"task": {
"tilesMerging": {
"type": "TILES_MERGING_TASK_TYPE",
"tileBatchSize": "TILES_MERGING_TILE_BATCH_SIZE",
"taskBatchSize": "TILES_MERGING_TASK_BATCH_SIZE",
"useNewTargetFlagInUpdate": {
"__name": "TILES_MERGING_USE_NEW_TARGET_FLAG",
"__format": "boolean"
}
}
}
}
}
}
15 changes: 8 additions & 7 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"telemetry": {
"logger": {
"level": "info",
"prettyPrint": false
"prettyPrint": false,
"pinoCaller": false
},
"tracing": {
"enabled": "true",
Expand All @@ -27,14 +28,14 @@
"enabled": true,
"options": null
}
},
"httpRetry": {
"attempts": 5,
"delay": "exponential",
"shouldResetTimeout": true,
"disableHttpClientLogs": true
}
},
"httpRetry": {
"attempts": 5,
"delay": "exponential",
"shouldResetTimeout": true
},
"disableHttpClientLogs": true,
"mapServerCacheType": "FS",
"jobManagement": {
"config": {
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: ts-server-boilerplate
description: A Helm chart for ts-server-boilerplate service
name: overseer
description: Helm chart for overseer service
type: application
version: 1.0.0
appVersion: 1.0.0
Expand Down
74 changes: 40 additions & 34 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "overseer.name" -}}
{{- default .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ts-server-boilerplate.labels" -}}
helm.sh/chart: {{ include "ts-server-boilerplate.chart" . }}
{{ include "ts-server-boilerplate.selectorLabels" . }}
{{- define "overseer.labels" -}}
helm.sh/chart: {{ include "overseer.chart" . }}
{{ include "overseer.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -13,22 +20,22 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Returns the tag of the chart.
*/}}
{{- define "ts-server-boilerplate.tag" -}}
{{- define "overseer.tag" -}}
{{- default (printf "v%s" .Chart.AppVersion) .Values.image.tag }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ts-server-boilerplate.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ts-server-boilerplate.name" . }}
{{- define "overseer.selectorLabels" -}}
app.kubernetes.io/name: {{ include "overseer.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Returns the environment from global if exists or from the chart's values, defaults to development
*/}}
{{- define "ts-server-boilerplate.environment" -}}
{{- define "overseer.environment" -}}
{{- if .Values.global.environment }}
{{- .Values.global.environment -}}
{{- else -}}
Expand All @@ -37,74 +44,73 @@ Returns the environment from global if exists or from the chart's values, defaul
{{- end -}}
{{/*
Returns the tracing url from global if exists or from the chart's values
Returns the cloud provider image pull secret name from global if exists or from the chart's values
*/}}
{{- define "ts-server-boilerplate.tracingUrl" -}}
{{- if .Values.global.tracing.url }}
{{- .Values.global.tracing.url -}}
{{- else if .Values.env.tracing.url -}}
{{- .Values.env.tracing.url -}}
{{- define "overseer.cloudProviderImagePullSecretName" -}}
{{- if .Values.global.cloudProvider.imagePullSecretName }}
{{- .Values.global.cloudProvider.imagePullSecretName -}}
{{- else if .Values.cloudProvider.imagePullSecretName -}}
{{- .Values.cloudProvider.imagePullSecretName -}}
{{- end -}}
{{- end -}}

{{/*
Returns the tracing url from global if exists or from the chart's values
Returns the cloud provider docker registry url from global if exists or from the chart's values
*/}}
{{- define "ts-server-boilerplate.metricsUrl" -}}
{{- if .Values.global.metrics.url }}
{{- .Values.global.metrics.url -}}
{{- define "overseer.cloudProviderDockerRegistryUrl" -}}
{{- if .Values.global.cloudProvider.dockerRegistryUrl }}
{{- printf "%s/" .Values.global.cloudProvider.dockerRegistryUrl -}}
{{- else if .Values.cloudProvider.dockerRegistryUrl -}}
{{- printf "%s/" .Values.cloudProvider.dockerRegistryUrl -}}
{{- else -}}
{{- .Values.env.metrics.url -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper image name
*/}}
{{- define "ts-server-boilerplate.image" -}}
{{- define "overseer.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "ts-server-boilerplate.imagePullSecrets" -}}
{{- define "overseer.imagePullSecrets" -}}
{{ include "common.images.renderPullSecrets" (dict "images" (list .Values.image) "context" $) }}
{{- end -}}
{{/*
Return the proper image pullPolicy
*/}}
{{- define "ts-server-boilerplate.pullPolicy" -}}
{{- define "overseer.pullPolicy" -}}
{{ include "common.images.pullPolicy" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper image deploymentFlavor
Returns the cloud provider name from global if exists or from the chart's values, defaults to minikube
*/}}
{{- define "ts-server-boilerplate.deploymentFlavor" -}}
{{ include "common.images.deploymentFlavor" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- define "overseer.cloudProviderFlavor" -}}
{{- if .Values.global.cloudProvider.flavor }}
{{- .Values.global.cloudProvider.flavor -}}
{{- else if .Values.cloudProvider -}}
{{- .Values.cloudProvider.flavor | default "minikube" -}}
{{- else -}}
{{ "minikube" }}
{{- end -}}
{{- end -}}

{{/*
Return the proper fully qualified app name
*/}}
{{- define "ts-server-boilerplate.fullname" -}}
{{- define "overseer.fullname" -}}
{{ include "common.names.fullname" . }}
{{- end -}}

{{/*
Return the proper chart name
*/}}
{{- define "ts-server-boilerplate.name" -}}
{{ include "common.names.name" . }}
{{- end -}}
{{/*
Return the proper chart name
*/}}
{{- define "ts-server-boilerplate.chart" -}}
{{- define "overseer.chart" -}}
{{ include "common.names.chart" . }}
{{- end -}}
20 changes: 20 additions & 0 deletions helm/templates/_resources.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{/*
Create service name as used by the service name label.
*/}}
{{- define "service.fullname" -}}
{{- printf "%s-%s-%s" .Release.Name .Chart.Name "service" | indent 1 }}
{{- end }}

{{/*
Create configmap name as used by the service name label.
*/}}
{{- define "configmap.fullname" -}}
{{- printf "%s-%s-%s" .Release.Name .Chart.Name "configmap" | indent 1 }}
{{- end }}

{{/*
Create deployment name as used by the service name label.
*/}}
{{- define "deployment.fullname" -}}
{{- printf "%s-%s-%s" .Release.Name .Chart.Name "deployment" | indent 1 }}
{{- end }}
59 changes: 59 additions & 0 deletions helm/templates/_tplValues.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{/*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{/* vim: set filetype=mustache: */}}
{{/*
Renders a value that contains template perhaps with scope if the scope is present.
Usage:
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
*/}}
{{- define "common.tplvalues.render" -}}
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
{{- if contains "{{" (toJson .value) }}
{{- if .scope }}
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
{{- else }}
{{- tpl $value .context }}
{{- end }}
{{- else }}
{{- $value }}
{{- end }}
{{- end -}}

{{/*
Merge a list of values that contains template after rendering them.
Merge precedence is consistent with http://masterminds.github.io/sprig/dicts.html#merge-mustmerge
Usage:
{{ include "common.tplvalues.merge" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
*/}}
{{- define "common.tplvalues.merge" -}}
{{- $dst := dict -}}
{{- range .values -}}
{{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst -}}
{{- end -}}
{{ $dst | toYaml }}
{{- end -}}

{{/*
End of usage example
*/}}

{{/*
Custom definitions
*/}}


{{- define "common.tracing.merged" -}}
{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.tracing .Values.global.tracing ) "context" . ) }}
{{- end -}}

{{- define "common.metrics.merged" -}}
{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics .Values.global.metrics ) "context" . ) }}
{{- end -}}

{{- define "common.serviceUrls.merged" -}}
{{- include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceUrls .Values.global.serviceUrls ) "context" . ) }}
{{- end -}}
Loading

0 comments on commit ff513ec

Please sign in to comment.