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

Support CVAT 2.X deployment using helm #4448

Merged
merged 5 commits into from
Mar 27, 2022
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Added missing geos dependency into Dockerfile (<https://github.com/openvinotoolkit/cvat/pull/4451>)
- Improved helm chart readme (<https://github.com/openvinotoolkit/cvat/pull/4366>)
- Added helm chart support for CVAT 2.X and made ingress compatible with Kubernetes >=1.22 (<https://github.com/openvinotoolkit/cvat/pull/4448>)

### Deprecated
- TDB
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should match chart version with CVAT's release version?


# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
14 changes: 12 additions & 2 deletions helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ helm dependency update
1. Create `values.override.yaml` file inside `helm-chart` directory.
2. Fill `values.override.yaml` with new parameters for chart.
3. Override [postgresql password](#postgresql-password)
4. (Optional) Add [ingress parameters](#ingress-parameters)
4. Create a rules.tar.gz archive containing all OPA rules inside this `helm-chart` directory.
```sh
find ../cvat/apps/iam/rules -name "*.rego" -and ! -name '*test*' -exec basename {} \; | tar -czf rules.tar.gz -C ../cvat/apps/iam/rules/ -T -
```
5. (Optional) Add [ingress parameters](#ingress-parameters)

### Postgresql password?
Put below into your `values.override.yaml`
Expand Down Expand Up @@ -99,6 +103,12 @@ ingress:
## Deployment
Make sure you are using correct kubernetes context. You can check it with `kubectl config current-context`.

> **Warning:** The k8s service name of Open Policy Agent is fixed to opa by default.
This is done to be compatible with CVAT 2.0 but limits this helm chart to a single release per namespace.
The OPA url currently can´t be set as an environment variable.
As soon as this is possible you can set cvat.opa.composeCompatibleServiceName
to false in your value.override.yaml and configure the opa url as additional env.

Execute following command from repo root directory
### With overrides:
```helm upgrade -n <desired_namespace> <release_name> -i --create-namespace ./helm-chart -f ./helm-chart/values.yaml -f ./helm-chart/values.override.yaml```
Expand Down Expand Up @@ -135,4 +145,4 @@ Then - put your instance params to "external" field
Just create file `values.override.yaml` and place your changes here, using same structure as in `values.yaml`.
Then reference it in helm update/install command using `-f` flag
### Why you used external charts to provide redis and postgres?
Because they definitely know what they do better then we are, so we are getting more quality and less support
Because they definitely know what they do better then we are, so we are getting more quality and less support
6 changes: 3 additions & 3 deletions helm-chart/templates/cvat_frontend/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ spec:
{{- include "cvat.labels" . | nindent 8 }}
app: cvat-app
tier: frontend
{{- with .Values.cvat.backend.labels }}
{{- with .Values.cvat.frontend.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cvat.backend.annotations }}
{{- with .Values.cvat.frontend.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
Expand Down Expand Up @@ -62,4 +62,4 @@ spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions helm-chart/templates/cvat_opa/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.cvat.opa.defaultStorage.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-opa-rules
namespace: {{ .Release.Namespace }}
labels:
{{- include "cvat.labels" . | nindent 4 }}
app: cvat-app
tier: opa
{{- if semverCompare ">=1.21-0" .Capabilities.KubeVersion.GitVersion }}
immutable: true
{{- end }}
binaryData:
rules.tar.gz: |-
{{ .Files.Get "rules.tar.gz" | b64enc }}
{{- end}}
82 changes: 82 additions & 0 deletions helm-chart/templates/cvat_opa/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-opa
namespace: {{ .Release.Namespace }}
labels:
{{- include "cvat.labels" . | nindent 4 }}
app: cvat-app
tier: opa
spec:
replicas: {{ .Values.cvat.opa.replicas }}
strategy:
type: Recreate
selector:
matchLabels:
{{- include "cvat.labels" . | nindent 6 }}
app: cvat-app
tier: opa
template:
metadata:
labels:
{{- include "cvat.labels" . | nindent 8 }}
app: cvat-app
tier: opa
{{- with .Values.cvat.opa.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cvat.opa.annotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: cvat-opa-app-container
image: {{ .Values.cvat.opa.image }}:{{ .Values.cvat.opa.tag }}
args:
- run
- --server
- --addr
- :8181
- --set=decision_logs.console=true
- /rules/rules.tar.gz
{{- with .Values.cvat.opa.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- containerPort: 8181
{{- with .Values.cvat.opa.additionalEnv }}
env:
{{- toYaml . | nindent 10 }}
{{- end }}
volumeMounts:
- mountPath: /rules
name: cvat-opa-rules
{{- with .Values.cvat.opa.additionalVolumeMounts }}
{{- toYaml . | nindent 10 }}
{{- end }}
volumes:
{{- if .Values.cvat.opa.defaultStorage.enabled }}
- name: cvat-opa-rules
configMap:
name: "{{ .Release.Name }}-opa-rules"
items:
- key: "rules.tar.gz"
path: "rules.tar.gz"
{{- end }}
{{- with .Values.cvat.opa.additionalVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cvat.opa.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.cvat.opa.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
21 changes: 21 additions & 0 deletions helm-chart/templates/cvat_opa/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Service
metadata:
{{- if .Values.cvat.opa.composeCompatibleServiceName }}
name: opa
{{- else }}
name: {{ .Release.Name }}-opa-service
{{- end }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "cvat.labels" . | nindent 4 }}
app: cvat-app
tier: opa
spec:
selector:
app: cvat-app
tier: opa
{{- include "cvat.labels" . | nindent 4 }}
{{- with .Values.cvat.opa.service }}
{{- toYaml . | nindent 2 }}
{{- end }}
16 changes: 15 additions & 1 deletion helm-chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{{- $version := .Capabilities.KubeVersion.GitVersion -}}
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "cvat.fullname" . -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- if semverCompare ">=1.19-0" $version -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" $version -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
Expand All @@ -16,6 +19,9 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if semverCompare ">=1.19-0" $version }}
ingressClassName: nginx
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
Expand All @@ -36,9 +42,17 @@ spec:
{{- if .pathType }}
pathType: {{ .pathType }}
{{- end }}
{{- if semverCompare ">=1.19-0" $version }}
backend:
service:
name: {{ .service.name }}
port:
number: {{ .service.port }}
{{- else }}
backend:
serviceName: {{ .service.name }}
servicePort: {{ .service.port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
45 changes: 45 additions & 0 deletions helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,51 @@ cvat:
targetPort: 80
protocol: TCP
name: http
opa:
replicas: 1
image: openpolicyagent/opa
tag: 0.34.2-rootless
labels: {}
# test: test
annotations: {}
# test.io/test: test
resources: {}
affinity: {}
tolerations: []
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: kubernetes.io/e2e-az-name
# operator: In
# values:
# - e2e-az1
# - e2e-az2
additionalEnv: []
# Example:
# - name: volume-from-secret
# - name: TEST
# value: "test"
additionalVolumes: []
# Example(assumes that pvc was already created):
# - name: tmp
# persistentVolumeClaim:
# claimName: tmp
additionalVolumeMounts: []
# Example:
# - mountPath: /tmp
# name: tmp
# subPath: test
composeCompatibleServiceName: true # Sets service name to opa in order to be docker-compose compatible. Necessary because changing IAM_OPA_DATA_URL via environment variables in current images. Hinders multiple deployment due to duplicate name
service:
type: ClusterIP
ports:
- port: 8181
targetPort: 8181
protocol: TCP
name: http
defaultStorage:
enabled: true

postgresql:
#See https://github.com/bitnami/charts/blob/master/bitnami/postgresql/ for more info
Expand Down