Skip to content

Commit

Permalink
[CITYLENS-728] Add citylens-routes-ui chart
Browse files Browse the repository at this point in the history
  • Loading branch information
xalvaine committed Dec 11, 2024
1 parent 1044386 commit 2372030
Show file tree
Hide file tree
Showing 14 changed files with 527 additions and 0 deletions.
2 changes: 2 additions & 0 deletions charts/citylens-routes-ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Chart.lock
charts/
22 changes: 22 additions & 0 deletions charts/citylens-routes-ui/.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/citylens-routes-ui/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v2
name: citylens-routes-ui
description: A Helm chart for Kubernetes to deploy Citylens UI service
type: application
version: 0.0.1
appVersion: '0.0.1'
dependencies:
- name: generic-chart
version: '*'
repository: file://../generic-chart
maintainers:
- name: 2gis
email: devops@2gis.ru
115 changes: 115 additions & 0 deletions charts/citylens-routes-ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
## Values

### Docker Registry settings

| Name | Description | Value |
| --------------------- | --------------------------------------------------------------------------------------- | -------------- |
| `dgctlDockerRegistry` | Docker Registry endpoint where On-Premise services' images reside. Format: `host:port`. | `""` |
| `imagePullPolicy` | Pull Policy | `IfNotPresent` |
| `imagePullSecrets` | Kubernetes image pull secrets. | `[]` |

### Strategy settings

| Name | Description | Value |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| `strategy.type` | Type of Kubernetes deployment. Can be `Recreate` or `RollingUpdate`. | `RollingUpdate` |
| `strategy.rollingUpdate.maxUnavailable` | Maximum number of pods that can be created over the desired number of pods when doing [rolling update](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#rolling-update-deployment). | `0` |
| `strategy.rollingUpdate.maxSurge` | Maximum number of pods that can be unavailable during the [rolling update](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#rolling-update-deployment) process. | `1` |

### Deployment settings

| Name | Description | Value |
| ------------------ | ----------- | ------------------------------------ |
| `image.repository` | Repository | `2gis-on-premise/citylens-routes-ui` |
| `image.tag` | Tag | `latest` |

### Environment

| Name | Description | Value |
| ----------------------------- | ------------------------------------------------- | ----- |
| `env.CATALOG_API_URL` | Catalog API base URL | `""` |
| `env.MAPGL_API_URL` | Map API base URL | `""` |
| `env.MAPGL_COPYRIGHT_VARIANT` | Copyright variant, can be '2gis', 'urbi' or empty | `""` |
| `env.MAPGL_KEY` | API key for mapgl | `""` |
| `env.MAPGL_STYLE_ID` | Map style ID | `""` |
| `env.ROUTES_API_URL` | Backend (citylens-routes-api) base URL | `""` |

### Common deployment settings

| Name | Description | Value |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
| `replicas` | A replica count for the pod. | `1` |
| `revisionHistoryLimit` | Revision history limit (used for [rolling back](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) a deployment). | `3` |
| `terminationGracePeriodSeconds` | Seconds pod needs to [terminate](https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods) gracefully | `60` |
| `nodeSelector` | Kubernetes [node selectors](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector). | `{}` |
| `affinity` | Kubernetes pod [affinity settings](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#node-affinity). | `{}` |
| `tolerations` | Kubernetes [tolerations](https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/) settings. | `[]` |
| `podAnnotations` | Kubernetes [pod annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` |
| `podLabels` | Kubernetes [pod labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). | `{}` |
| `annotations` | Kubernetes [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` |
| `labels` | Kubernetes [labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). | `{}` |
| `readinessProbe.enabled` | Enable [readinessProbe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes) on PRO UI containers | `false` |
| `livenessProbe.enabled` | Enable [livenessProbe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes) on PRO UI containers | `true` |
| `livenessProbe.healthcheckPath` | Application http path for health check | `/health` |
| `containerPort` | Port on which application listen connection in container | `3000` |

### Service settings

| Name | Description | Value |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------- |
| `service.annotations` | Kubernetes [service annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` |
| `service.labels` | Kubernetes [service labels](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/). | `{}` |
| `service.type` | Kubernetes [service type](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types). | `ClusterIP` |
| `service.port` | Service port. | `80` |

### Kubernetes [Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) settings

| Name | Description | Value |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------- | ------------------------- |
| `ingress.enabled` | If Ingress is enabled for the service. | `false` |
| `ingress.annotations` | Kubernetes [annotations](https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/). | `{}` |
| `ingress.className` | Name of the Ingress controller class. | `nginx` |
| `ingress.hosts[0].host` | Hostname for the Ingress service. | `citylens-ui.example.com` |
| `ingress.hosts[0].paths[0].path` | Path of the host for the Ingress service. | `/` |
| `ingress.hosts[0].paths[0].pathType` | Type of the path for the Ingress service. | `Prefix` |
| `ingress.tls` | TLS configuration | `[]` |

### Limits

| Name | Description | Value |
| --------------------------- | ----------------- | ------- |
| `resources.requests.cpu` | A CPU request. | `300m` |
| `resources.requests.memory` | A memory request. | `256Mi` |
| `resources.limits.cpu` | A CPU limit. | `1` |
| `resources.limits.memory` | A memory limit. | `384Mi` |

### Kubernetes [Pod Disruption Budget](https://kubernetes.io/docs/concepts/workloads/pods/disruptions/#pod-disruption-budgets) settings

| Name | Description | Value |
| -------------------- | --------------------------------------------------- | ------- |
| `pdb.enabled` | If PDB is enabled for the service | `false` |
| `pdb.minAvailable` | How many pods must be available after the eviction | `""` |
| `pdb.maxUnavailable` | How many pods can be unavailable after the eviction | `1` |

### Kubernetes [Horizontal Pod Autoscaling](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) settings

| Name | Description | Value |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `hpa.enabled` | If HPA is enabled for the service | `false` |
| `hpa.minReplicas` | Lower limit for the number of replicas to which the autoscaler can scale down | `1` |
| `hpa.maxReplicas` | Upper limit for the number of replicas to which the autoscaler can scale up | `100` |
| `hpa.scaleDownStabilizationWindowSeconds` | Scale-down window | `""` |
| `hpa.scaleUpStabilizationWindowSeconds` | Scale-up window | `""` |
| `hpa.targetCPUUtilizationPercentage` | Target average CPU utilization (represented as a percentage of requested CPU) over all the pods; if not specified the default autoscaling policy will be used | `80` |
| `hpa.targetMemoryUtilizationPercentage` | Target average memory utilization (represented as a percentage of requested memory) over all the pods; if not specified the default autoscaling policy will be used | `""` |

### Kubernetes [Vertical Pod Autoscaling](https://github.com/kubernetes/autoscaler/blob/master/vertical-pod-autoscaler/README.md) settings

| Name | Description | Value |
| ----------------------- | ------------------------------------------------------------------------------------------------------------ | ------- |
| `vpa.enabled` | If VPA is enabled for the service. | `false` |
| `vpa.updateMode` | VPA [update mode](https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler#quick-start). | `Auto` |
| `vpa.minAllowed.cpu` | Lower limit for the number of CPUs to which the autoscaler can scale down. | `500m` |
| `vpa.minAllowed.memory` | Lower limit for the RAM size to which the autoscaler can scale down. | `128Mi` |
| `vpa.maxAllowed.cpu` | Upper limit for the number of CPUs to which the autoscaler can scale up. | `2000` |
| `vpa.maxAllowed.memory` | Upper limit for the RAM size to which the autoscaler can scale up. | `512Mi` |
14 changes: 14 additions & 0 deletions charts/citylens-routes-ui/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ .Chart.Name }} is installed by release "{{ .Release.Name }}" at "{{ .Release.Namespace }}" namespace

You can check the status of the app using command

kubectl get pods -n {{ .Release.Namespace}} -l app.kubernetes.io/name={{ include "citylens-ui.name" . }} -l app.kubernetes.io/instance={{ .Release.Name }}

{{- if .Values.ingress.enabled }}
You can check service using curl
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ .host }}/
{{- end }}
{{- else }}
You should publish the service in your preferred way (ingress, balancer, etc).
{{- end }}
13 changes: 13 additions & 0 deletions charts/citylens-routes-ui/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- define "citylens-ui.name" -}}
{{- .Release.Name }}
{{- end }}

{{- define "citylens-ui.selectorLabels" -}}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "citylens-ui.labels" -}}
{{ include "citylens-ui.selectorLabels" . }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
91 changes: 91 additions & 0 deletions charts/citylens-routes-ui/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "citylens-ui.name" . }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.labels }}
labels:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicas }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
{{- if .Values.strategy }}
strategy:
{{- toYaml .Values.strategy | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "citylens-ui.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "citylens-ui.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
enableServiceLinks: false
containers:
- name: {{ include "citylens-ui.name" . }}
image: "{{ required "A valid .Values.dgctlDockerRegistry entry required" .Values.dgctlDockerRegistry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.imagePullPolicy }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
lifecycle:
preStop:
exec:
command: [ "/bin/sh", "-c", "sleep 5" ]
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 12 }}
{{- end }}
env:
- name: CATALOG_API_URL
value: {{ required "A valid .Values.env.CATALOG_API_URL entry required" .Values.env.CATALOG_API_URL | quote }}
- name: MAPGL_API_URL
value: {{ required "A valid .Values.env.MAPGL_API_URL entry required" .Values.env.MAPGL_API_URL | quote }}
- name: MAPGL_COPYRIGHT_VARIANT
value: {{ required "A valid .Values.env.MAPGL_COPYRIGHT_VARIANT entry required" .Values.env.MAPGL_COPYRIGHT_VARIANT | quote }}
- name: MAPGL_STYLE_ID
value: {{ .Values.env.MAPGL_STYLE_ID }}
- name: ROUTES_API_URL
value: {{ required "A valid .Values.env.ROUTES_API_URL entry required" .Values.env.ROUTES_API_URL | quote }}
- name: MAPGL_KEY
valueFrom:
secretKeyRef:
key: MAPGL_KEY
name: {{ include "citylens-ui.name" . }}-secret
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.healthcheckPath }}
port: http
{{- end }}

{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
{{- end }}
1 change: 1 addition & 0 deletions charts/citylens-routes-ui/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- template "generic-chart.hpa.tpl" . }}
45 changes: 45 additions & 0 deletions charts/citylens-routes-ui/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- with .Values.ingress }}
{{- if .enabled -}}
---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "citylens-ui.name" $ }}
labels:
{{- include "citylens-ui.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: Prefix
backend:
service:
name: {{ include "citylens-ui.name" $ }}
port:
number: {{ $.Values.service.port }}
{{- end }}
{{- end }}

{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/citylens-routes-ui/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{- template "generic-chart.pdb.tpl" . }}
Loading

0 comments on commit 2372030

Please sign in to comment.