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

add chart for citylens-routes-api #495

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 21 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
187 changes: 186 additions & 1 deletion charts/citylens/README.md

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions charts/citylens/templates/helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,72 @@ S3 key templates for frames & frames crops
{{- define "citylens.s3_constants.crop_frame_key_template" -}}
{track_uuid}/{frame_timestamp_ms}_{theta}.jpg
{{- end -}}

{{/*
Citylens routes chart name
*/}}

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

{{/*
Citylens routes name defines
*/}}

{{- define "citylens.routes" -}}
{{ include "citylens.name" . }}-routes
{{- end -}}

{{- define "citylens.routes.api.name" -}}
{{ include "citylens.routes" . }}{{- printf "-%s-%s" "api" .Values.routes.environment | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "citylens.routes.worker.name" -}}
{{ include "citylens.routes" . }}{{- printf "-%s-%s" "worker" .Values.routes.environment | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "citylens.routes.migration.name" -}}
{{ include "citylens.routes" . }}{{- printf "-%s-%s" "migration" .Values.routes.environment | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Citylens routes deployment labels
*/}}

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

{{- define "citylens.routes.worker.selectorLabels" -}}
app.kubernetes.io/name: {{ .Release.Name | quote }}
app.kubernetes.io/instance: {{ include "citylens.routes.worker.name" . | quote }}
{{- end -}}

{{- define "citylens.routes.api.labels" -}}
helm.sh/chart: {{ include "app.chart" . }}
{{ include "citylens.routes.api.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
{{- end -}}

{{- define "citylens.routes.worker.labels" -}}
helm.sh/chart: {{ include "app.chart" . }}
{{ include "citylens.routes.worker.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
{{- end -}}

{{- define "citylens.routes.migration.labels" -}}
app.kubernetes.io/name: {{ .Release.Name | quote }}
app.kubernetes.io/instance: {{ include "citylens.routes.migration.name" . | quote }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
{{- end -}}
166 changes: 166 additions & 0 deletions charts/citylens/templates/routes-api/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "citylens.routes.api.name" . }}
{{- with .Values.routes.api.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "citylens.routes.api.labels" . | nindent 4 }}
{{- with .Values.routes.api.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.routes.api.replicaCount }}
revisionHistoryLimit: {{ .Values.routes.api.revisionHistoryLimit }}
{{- if .Values.routes.strategy }}
strategy:
{{- toYaml .Values.routes.strategy | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "citylens.routes.api.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/secrets.routes.yaml") . | sha256sum }}
{{- with .Values.routes.api.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "citylens.routes.api.labels" . | nindent 8 }}
{{- with .Values.routes.api.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.routes.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.routes.api.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.routes.api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.routes.api.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.routes.terminationGracePeriodSeconds }}
volumes:
- name: temp-volume
emptyDir: { }
containers:
- name: {{ include "citylens.routes.api.name" . }}
image: {{ required "A valid .Values.dgctlDockerRegistry entry required" $.Values.dgctlDockerRegistry }}/{{ .Values.routes.api.image.repository }}:{{ .Values.routes.api.image.tag }}
imagePullPolicy: {{ .Values.routes.api.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: "{{ .Values.routes.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.routes.api.resources | nindent 12 }}
lifecycle:
preStop:
exec:
command: [ "/bin/sh", "-c", "sleep 5" ]
env:
- name: Common__TempPath
value: "{{ .Values.routes.api.tempPath }}"

- name: Common__Logging__LogLevel
value: "{{ .Values.routes.api.logging.level }}"

- name: PgSettings__Host
value: "{{ required "A valid .Values.postgres.host entry required" $.Values.postgres.host }}"
- name: PgSettings__Port
value: "{{ required "A valid .Values.postgres.port entry required" $.Values.postgres.port }}"
- name: PgSettings__UserName
value: "{{ required "A valid .Values.postgres.username entry required" $.Values.postgres.username }}"
- name: PgSettings__Password
valueFrom:
secretKeyRef:
key: postgresPassword
name: {{ include "citylens.routes.api.name" . }}-secret

- name: PgSettings__Api__Database
value: "{{ required "A valid .Values.routes.postgres.database entry required" $.Values.routes.postgres.database }}"
- name: PgSettings__Api__Timeout
value: "{{ $.Values.routes.postgres.timeout }}"
- name: PgSettings__Api__CommandTimeout
value: "{{ $.Values.routes.postgres.commandTimeout }}"
- name: PgSettings__Api__MaxPoolSize
value: "{{ $.Values.routes.postgres.maxPoolSize }}"
- name: PgSettings__Api__Pooling
value: "{{ $.Values.routes.postgres.pooling }}"

- name: PgSettings__Hangfire__Database
value: "{{ required "A valid .Values.routes.hangfire.postgres.database entry required" $.Values.routes.hangfire.postgres.database }}"
- name: PgSettings__Hangfire__Timeout
value: "{{ $.Values.routes.hangfire.postgres.timeout }}"
- name: PgSettings__Hangfire__CommandTimeout
value: "{{ $.Values.routes.hangfire.postgres.commandTimeout }}"
- name: PgSettings__Hangfire__MaxPoolSize
value: "{{ $.Values.routes.hangfire.postgres.maxPoolSize }}"
- name: PgSettings__Hangfire__Pooling
value: "{{ $.Values.routes.hangfire.postgres.pooling }}"

- name: S3__BucketPrefix
value: "{{ required "A valid .Values.s3.bucketPrefix entry required" $.Values.s3.bucketPrefix }}"
- name: S3__LogsBucketPrefix
value: "{{ required "A valid .Values.s3.logsBucketPrefix entry required" $.Values.s3.logsBucketPrefix }}"
- name: S3__AccessKey
valueFrom:
secretKeyRef:
key: s3AccessKey
name: {{ include "citylens.routes.api.name" . }}-secret
- name: S3__SecretAccessKey
valueFrom:
secretKeyRef:
key: s3SecretAccessKey
name: {{ include "citylens.routes.api.name" . }}-secret
- name: S3__Region
value: "{{ $.Values.s3.region }}"

- name: Clients__Navigation__Enabled
value: "true"
- name: Clients__Navigation__Url
value: "{{ $.Values.routes.navi.url }}"

- name: Clients__Gefest__Enabled
value: "true"
- name: Clients__Gefest__Url
value: "{{ $.Values.routes.gefest.url }}"
42 changes: 42 additions & 0 deletions charts/citylens/templates/routes-api/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- with .Values.routes.api }}
{{- if .hpa.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "citylens.routes.api.name" $ }}
labels:
{{- include "citylens.routes.api.labels" $ | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "citylens.routes.api.name" $ }}
minReplicas: {{ .hpa.minReplicas }}
maxReplicas: {{ .hpa.maxReplicas }}
behavior:
scaleUp:
stabilizationWindowSeconds: {{ .hpa.scaleUpStabilizationWindowSeconds }}
scaleDown:
stabilizationWindowSeconds: {{ .hpa.scaleDownStabilizationWindowSeconds }}
metrics:
{{- with .hpa.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .hpa.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- end }}
{{- end }}
47 changes: 47 additions & 0 deletions charts/citylens/templates/routes-api/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- with .Values.routes.api.ingress }}
{{- if .enabled -}}
{{- $fullName := include "citylens.routes.api.name" $ -}}
---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "citylens.routes.api.labels" $ | nindent 4 }}

{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}

spec:
ingressClassName: {{ .className }}
{{- if .tls }}
tls:
{{- range .tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ $fullName }}
port:
number: {{ $.Values.routes.api.service.port }}
{{- end }}
{{- end }}

{{- end }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/citylens/templates/routes-api/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- with .Values.routes.api }}
{{- if .pdb.enabled }}

---

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "citylens.routes.api.name" $ }}
labels:
{{- include "citylens.routes.api.labels" $ | nindent 4 }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .pdb.minAvailable }}
minAvailable: {{ .pdb.minAvailable }}
{{- end }}
{{- if .pdb.maxUnavailable }}
maxUnavailable: {{ .pdb.maxUnavailable }}
{{- end }}
selector:
matchLabels:
{{- include "citylens.routes.api.selectorLabels" $ | nindent 6 }}

{{- end }}
{{- end }}
33 changes: 33 additions & 0 deletions charts/citylens/templates/routes-api/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- with .Values.routes.api.service }}
---
apiVersion: v1
kind: Service

metadata:
name: {{ include "citylens.routes.api.name" $ }}

annotations:
router.deis.io/domains: {{ include "citylens.routes.api.name" $ }}
{{- if .annotations }}
{{- toYaml .annotations | nindent 4 }}
{{- end }}

labels:
{{- include "citylens.routes.api.labels" $ | nindent 4 }}
{{- if .labels }}
{{- toYaml .labels | nindent 4 }}
{{- end }}

spec:
type: {{ .type }}
ports:
- port: {{ .port }}
targetPort: http
protocol: TCP
name: http
appProtocol: http

selector:
{{- include "citylens.routes.api.selectorLabels" $ | nindent 4 }}

{{- end }}
Loading
Loading