-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kirpichev Michael
authored
Apr 27, 2021
1 parent
1790800
commit fe31e61
Showing
14 changed files
with
671 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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 | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apiVersion: v2 | ||
name: cvat | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
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 | ||
|
||
# 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 | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: latest | ||
# We dont use it, so you can override it using values.override.yaml | ||
|
||
dependencies: | ||
- name: redis | ||
version: "12.9.*" | ||
repository: https://charts.bitnami.com/bitnami | ||
condition: redis.enabled | ||
- name: postgresql | ||
version: "10.3.*" | ||
repository: https://charts.bitnami.com/bitnami | ||
condition: postgresql.enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# FAQ | ||
## What should be configured before installation? | ||
1. You should have configured connection to existed k8s cluster | ||
2. Helm must be installed | ||
3. You should download chart external dependencies, using following commands: | ||
``` | ||
helm repo add bitnami https://charts.bitnami.com/bitnami | ||
helm repo update | ||
helm dependency update | ||
``` | ||
4. (Optional) Install ingress of your choice (for example: https://github.com/kubernetes/ingress-nginx) | ||
5. (Optional) Create certificates for https (for example: https://github.com/jetstack/cert-manager/ ) | ||
6. (Optional) Create values.override.yaml and override there parameters you want | ||
7. Change postgresql password as described below | ||
8. Add ingress to values.override.yaml(example also below) | ||
7. Deploy cvat using command below | ||
## How to deploy new version of chart to cluster? | ||
Execute following command: | ||
```helm upgrade <release_name> --install ./helm-chart -f ./helm-chart/values.yaml -f values.override.yaml(if exists) --namespace <desired namespace>``` | ||
## How to create superuser? | ||
``` | ||
HELM_RELEASE_NAMESPACE="<insert>" &&\ | ||
HELM_RELEASE_NAME="<insert>" &&\ | ||
BACKEND_POD_NAME=$(kubectl get pod --namespace $HELM_RELEASE_NAMESPACE -l tier=backend,app.kubernetes.io/instance=$HELM_RELEASE_NAME -o jsonpath='{.items[0].metadata.name}') &&\ | ||
kubectl exec -it --namespace $HELM_RELEASE_NAMESPACE $BACKEND_POD_NAME -c cvat-backend-app-container -- python manage.py createsuperuser | ||
``` | ||
## How to change embedded postgresql password? | ||
There are several passwords used here, for security reasons - better change them all. | ||
``` | ||
postgresql: | ||
secret: | ||
password: cvat_postgresql | ||
postgres_password: cvat_postgresql_postgres | ||
replication_password: cvat_postgresql_replica | ||
``` | ||
Or, if you know how to work with k8s - you could create your own secret and use it here: | ||
``` | ||
postgresql: | ||
global: | ||
postgresql: | ||
existingSecret: cvat-postgres-secret | ||
``` | ||
## How to describe ingress: | ||
Just set `ingress.enabled:` to `true`, then copy example, uncomment it and change values there | ||
## How to understand what diff will be inflicted by 'helm upgrade'? | ||
You can use https://github.com/databus23/helm-diff#install for that | ||
## I want to use my own postgresql/redis with your chart. | ||
Just set `postgresql.enabled` or `redis.enabled` to `false`, as described below. | ||
Then - put your instance params to "external" field | ||
## I want to override some settings in values.yaml. | ||
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 | ||
## What is kubernetes and how it is working? | ||
See https://kubernetes.io/ | ||
## What is helm and how it is working? | ||
See https://helm.sh/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "cvat.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "cvat.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .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 }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "cvat.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "cvat.labels" -}} | ||
helm.sh/chart: {{ include "cvat.chart" . }} | ||
{{ include "cvat.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "cvat.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "cvat.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "cvat.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "cvat.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if .Values.postgresql.secret.create }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: "{{ .Release.Name }}-{{ .Values.postgresql.secret.name }}" | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "cvat.labels" . | nindent 4 }} | ||
type: generic | ||
stringData: | ||
postgresql-hostname: "{{ .Release.Name }}-postgresql" | ||
postgresql-database: {{ .Values.postgresql.postgresqlDatabase }} | ||
postgresql-username: {{ .Values.postgresql.postgresqlUsername }} | ||
postgresql-password: {{ .Values.postgresql.secret.password }} | ||
postgresql-postgres-password: {{ .Values.postgresql.secret.postgres_password }} | ||
postgresql-replication-password: {{ .Values.postgresql.secret.replication_password }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ .Release.Name }}-backend | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app: cvat-app | ||
tier: backend | ||
{{- include "cvat.labels" . | nindent 4 }} | ||
{{- with .Values.cvat.backend.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with .Values.cvat.backend.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
replicas: {{ .Values.cvat.backend.replicas }} | ||
strategy: | ||
type: Recreate | ||
selector: | ||
matchLabels: | ||
{{- include "cvat.labels" . | nindent 6 }} | ||
{{- with .Values.cvat.backend.labels }} | ||
{{- toYaml . | nindent 6 }} | ||
{{- end }} | ||
app: cvat-app | ||
tier: backend | ||
template: | ||
metadata: | ||
labels: | ||
app: cvat-app | ||
tier: backend | ||
{{- include "cvat.labels" . | nindent 8 }} | ||
{{- with .Values.cvat.backend.labels }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.cvat.backend.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
containers: | ||
- name: cvat-backend-app-container | ||
image: {{ .Values.cvat.backend.image }}:{{ .Values.cvat.backend.tag }} | ||
{{- with .Values.cvat.backend.resources }} | ||
resources: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
env: | ||
- name: DJANGO_MODWSGI_EXTRA_ARGS | ||
value: {{ .Values.cvat.backend.envs.DJANGO_MODWSGI_EXTRA_ARGS}} | ||
- name: ALLOWED_HOSTS | ||
value: {{ .Values.cvat.backend.envs.ALLOWED_HOSTS | squote}} | ||
- name: UI_HOST | ||
value: "{{ .Release.Name }}-frontend-service" | ||
- name: UI_PORT | ||
value: "{{ .Values.cvat.frontend.service.ports }}" | ||
{{- if .Values.redis.enabled }} | ||
- name: CVAT_REDIS_HOST | ||
value: "{{ .Release.Name }}-redis-master" | ||
{{- else }} | ||
- name: CVAT_REDIS_HOST | ||
value: "{{ .Values.redis.external.host }}" | ||
{{- end }} | ||
- name: CVAT_POSTGRES_HOST | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ .Release.Name }}-{{ .Values.postgresql.secret.name }}" | ||
key: postgresql-hostname | ||
- name: CVAT_POSTGRES_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ .Release.Name }}-{{ .Values.postgresql.secret.name }}" | ||
key: postgresql-username | ||
- name: CVAT_POSTGRES_DBNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ .Release.Name }}-{{ .Values.postgresql.secret.name }}" | ||
key: postgresql-database | ||
- name: CVAT_POSTGRES_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ .Release.Name }}-{{ .Values.postgresql.secret.name }}" | ||
key: postgresql-password | ||
{{- with .Values.cvat.backend.additionalEnv }} | ||
{{- toYaml . | nindent 10 }} | ||
{{- end }} | ||
ports: | ||
- containerPort: 8080 | ||
volumeMounts: | ||
- mountPath: /home/django/data | ||
name: cvat-backend-data | ||
subPath: data | ||
- mountPath: /home/django/keys | ||
name: cvat-backend-data | ||
subPath: keys | ||
- mountPath: /home/django/logs | ||
name: cvat-backend-data | ||
subPath: logs | ||
- mountPath: /home/django/models | ||
name: cvat-backend-data | ||
subPath: models | ||
{{- with .Values.cvat.backend.additionalVolumeMounts }} | ||
{{- toYaml . | nindent 10 }} | ||
{{- end }} | ||
initContainers: | ||
- name: user-data-permission-fix | ||
image: busybox | ||
command: ["/bin/chmod", "-R", "777", "/home/django"] | ||
{{- with .Values.cvat.backend.resources }} | ||
resources: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
volumeMounts: | ||
{{- if .Values.cvat.backend.defaultStorage.enabled }} | ||
- mountPath: /home/django/data | ||
name: cvat-backend-data | ||
subPath: data | ||
- mountPath: /home/django/keys | ||
name: cvat-backend-data | ||
subPath: keys | ||
- mountPath: /home/django/logs | ||
name: cvat-backend-data | ||
subPath: logs | ||
- mountPath: /home/django/models | ||
name: cvat-backend-data | ||
subPath: models | ||
{{- end }} | ||
{{- with .Values.cvat.backend.additionalVolumeMounts }} | ||
{{- toYaml . | nindent 10 }} | ||
{{- end }} | ||
{{- with .Values.cvat.frontend.affinity }} | ||
affinity: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
volumes: | ||
{{- if .Values.cvat.backend.defaultStorage.enabled }} | ||
- name: cvat-backend-data | ||
persistentVolumeClaim: | ||
claimName: "{{ .Release.Name }}-backend-data" | ||
{{- end }} | ||
{{- with .Values.cvat.backend.additionalVolumes }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ .Release.Name }}-backend-service | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "cvat.labels" . | nindent 4 }} | ||
app: cvat-app | ||
tier: backend | ||
spec: | ||
selector: | ||
app: cvat-app | ||
tier: backend | ||
{{- include "cvat.labels" . | nindent 4 }} | ||
{{- with .Values.cvat.backend.service }} | ||
{{- toYaml . | nindent 2 }} | ||
{{- end }} |
Oops, something went wrong.