Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRO-6845] TileGen API #552

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions charts/tilegen-api/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto
*.yaml text eol=lf
*.tpl text eol=lf
22 changes: 22 additions & 0 deletions charts/tilegen-api/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
13 changes: 13 additions & 0 deletions charts/tilegen-api/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: tilegen
description: API for generating vector tiles from user data

type: application

version: 0.0.1
appVersion: 0.0.1

maintainers:
- name: 2gis
url: https://github.com/2gis
email: [email protected]
114 changes: 114 additions & 0 deletions charts/tilegen-api/README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions charts/tilegen-api/templates/tilegen/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Release - {{ .Release.Name }}
Namespace - {{ .Release.Namespace }}
48 changes: 48 additions & 0 deletions charts/tilegen-api/templates/tilegen/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- define "api.name" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Values.appName .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "task-processor-job.name" -}}
{{- $name := default "task-processor" -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- define "api.service-account-name" -}}
{{- $name := default .Values.api.serviceAccount -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- define "app.chart" -}}
{{- printf "%s-%s" .Values.appName .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "api.selectorLabels" -}}
app.kubernetes.io/name: {{ include "api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{- define "api.labels" -}}
helm.sh/chart: {{ include "app.chart" . }}
{{ include "api.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
147 changes: 147 additions & 0 deletions charts/tilegen-api/templates/tilegen/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "api.name" . }}
{{- with .Values.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "api.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicaCount }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
{{- if .Values.strategy }}
strategy:
{{- toYaml .Values.strategy | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "api.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/tilegen/secrets.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "api.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: {{ .Values.priorityClassName }}
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
serviceAccountName: {{ include "api.service-account-name" . }}
volumes:
- name: temp-volume
emptyDir: {}
containers:
- name: {{ include "api.name" . }}
image: {{ required "A valid .Values.dgctlDockerRegistry entry required" $.Values.dgctlDockerRegistry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: "{{ .Values.api.tempPath }}"
name: temp-volume
livenessProbe:
httpGet:
path: /health/live
port: http
failureThreshold: 5
initialDelaySeconds: 5
periodSeconds: 15
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
httpGet:
path: /health/ready
port: http
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 5
startupProbe:
httpGet:
path: /health/live
port: http
failureThreshold: 20
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 5"]
env:
- name: DEBUG
value: "{{ .Values.api.debug }}"
- name: Processor__JobName
value: {{ include "task-processor-job.name" . }}
- name: Common__TempPath
value: "{{ .Values.api.tempPath }}"
- name: Common__AllowAnyOrigin
value: "{{ .Values.api.allowAnyOrigin }}"
- name: S3__Url
value: {{ required "A valid .Values.s3.host entry required" $.Values.s3.host }}
- name: S3__VectorTilesBucket
value: {{ required "A valid .Values.s3.vectorTilesBucket entry required" $.Values.s3.vectorTilesBucket }}
- name: S3__AccessKey
valueFrom:
secretKeyRef:
key: s3AccessKey
name: {{ include "api.name" . }}-secret
- name: S3__SecretKey
valueFrom:
secretKeyRef:
key: s3SecretKey
name: {{ include "api.name" . }}-secret
- name: Redis__Host
value: {{ required "A valid .Values.redis.host entry required" $.Values.redis.host }}
- name: Redis__Port
value: "{{ .Values.redis.port }}"
- name: Redis__DatabaseId
value: "{{ .Values.redis.databaseId }}"
- name: Redis__Username
value: {{ $.Values.redis.username }}
{{ if .Values.redis.password }}
- name: Redis__Password
valueFrom:
secretKeyRef:
key: redisPassword
name: {{ include "api.name" . }}-secret
{{- end }}
- name: Common__Logging__Format
value: "{{ .Values.api.logging.format }}"
41 changes: 41 additions & 0 deletions charts/tilegen-api/templates/tilegen/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "api.name" . -}}
{{- $svcPort := .Values.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "api.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/tilegen-api/templates/tilegen/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "api.service-account-name" . }}-role
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- list
- create
- watch
- delete
- apiGroups:
- batch
resources:
- jobs
- cronjobs
verbs:
- get
- list
- create
- watch
- delete
- apiGroups:
- batch
resources:
- jobs/status
verbs:
- get
11 changes: 11 additions & 0 deletions charts/tilegen-api/templates/tilegen/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "api.service-account-name" . }}-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "api.service-account-name" . }}-role
subjects:
- kind: ServiceAccount
name: {{ include "api.service-account-name" . }}
11 changes: 11 additions & 0 deletions charts/tilegen-api/templates/tilegen/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "api.name" . }}-secret
type: Opaque
data:
s3AccessKey: {{ required "Valid .Values.s3.accessKey required!" .Values.s3.accessKey | b64enc }}
s3SecretKey: {{ required "Valid .Values.s3.secretKey required!" .Values.s3.secretKey | b64enc }}
{{ if .Values.redis.password }}
redisPassword: {{ .Values.redis.password | b64enc }}
{{ end }}
4 changes: 4 additions & 0 deletions charts/tilegen-api/templates/tilegen/service-account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "api.service-account-name" . }}
23 changes: 23 additions & 0 deletions charts/tilegen-api/templates/tilegen/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "api.name" . }}
{{- if .Values.service.annotations }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
labels:
{{- include "api.labels" . | nindent 4 }}
{{- if .Values.service.labels }}
{{- toYaml .Values.service.labels | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
appProtocol: http
selector:
{{- include "api.selectorLabels" . | nindent 4 }}
Loading
Loading