Search…
Helm
When working with Helm you can keep your Velocity Annotations in a separate Helm Values file. Then, before importing to Velocity, you need to generate K8s YAML files that include Velocity Annotations.
A typical Helm setup includes:
  1. 1.
    A Helm chart that specifies the basic application configurations. The chart must include an added section that enables overriding annotations from a separate Values file, as seen in the example below.
  2. 2.
    A Values file with all the production configurations that is used when deploying to production
  3. 3.
    A Values file for Velocity, which overrides your production configurations with dev/test configurations. This file will include the added Velocity Annotations.

Generating K8s resource files for Velocity

With the above setup, running the following command will create a template from the Helm Chart, inject the production configuration, and add the required values for Velocity. resulting in a K8s resource file that can be read by Velocity.
helm template <chart name> -f values/prod.yaml -f values/velocity.yaml

Example: A Helm Chart that specifies the basic application configurations.

Pay attention to lines 5-8 which enable overriding annotations from a separate Values file.
1
apiVersion: apps/v1
2
kind: Deployment
3
metadata:
4
name: {{ include "chart.fullname" . }}
5
{{- with .Values.annotations }}
6
annotations:
7
{{- toYaml . | nindent 4 }}
8
{{- end }}
9
spec:
10
selector:
11
matchLabels:
12
{{- include "chart.selectorLabels" . | nindent 6 }}
13
template:
14
metadata:
15
{{- with .Values.podAnnotations }}
16
annotations:
17
{{- toYaml . | nindent 8 }}
18
{{- end }}
19
spec:
20
containers:
21
- name: {{ .Chart.Name }}
22
securityContext:
23
{{- toYaml .Values.securityContext | nindent 12 }}
24
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
25
imagePullPolicy: {{ .Values.image.pullPolicy }}
26
envFrom:
27
- secretRef:
28
name: db-credentials
29
optional: false
30
env:
31
{{- include "chart.env" . | indent 12 }}
32
ports:
33
- name: http
34
containerPort: 3000
35
protocol: TCP
36
resources:
37
{{- toYaml .Values.resources | nindent 12 }}
38
39
---
40
apiVersion: v1
41
kind: Secret
42
metadata:
43
name: db-credentials
44
type: Opaque
45
data:
46
DB_USER: {{ .Values.postgres_user | b64enc }}
47
DB_PASSWORD: {{ .Values.postgres_pass | b64enc }}
Copied!

A Values file for Velocity

1
annotations:
2
velocity.tech.v1/id: backend
3
velocity.tech.v1/dependsOn: mysql-database, postgres
4
5
env:
6
SECRET_KEY_BASE: "{velocity.v1.generate:random}"
7
RABBITMQ_URL: "{velocity.v1:backend-queue.exposures(port=rabbitport).uri}"
8
RESULT_CREATE_TOKEN: "{velocity.v1.generate:random}"
9
CALLBACK_URL: "{velocity.v1:backend.exposures(port=http).public.uri}"
10
MYSQL_DATABASE_URL: "{velocity.v1:mysql-database.exposures(port=mysqlport).uri}/{velocity.v1:mysql-database.exports.dbname}"
11
ANALYTICS_URL: "{velocity.v1:analytics.exposures(port=analyticsport).uri}"
12
REDIS_URL: "{velocity.v1:backend-cache.exposures(port=redisport).uri}"
13
POSTGRES_DATABASE_URL: "{velocity.v1:postgres.exposures(port=postgresport).uri}"
14
15
16
postgres_user: "{velocity.v1:postgres.exposures(port=postgresport).user}"
17
postgres_pass: "{velocity.v1:postgres.exposures(port=postgresport).password}"
Copied!
Copy link
Contents