Skip to content

Commit

Permalink
addd basic cvat deployment k8s templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Langhalsdino committed Feb 28, 2021
1 parent dff57eb commit a29c880
Show file tree
Hide file tree
Showing 17 changed files with 591 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Pre-built [cvat_server](https://hub.docker.com/r/openvino/cvat_server) and
[cvat_ui](https://hub.docker.com/r/openvino/cvat_ui) images were published on DockerHub (<https://github.com/openvinotoolkit/cvat/pull/2766>)
- Project task subsets (<https://github.com/openvinotoolkit/cvat/pull/2774>)
- Kubernetes templates and guide for their deployment (<https://github.com/openvinotoolkit/cvat/pull/1962>)

### Changed

Expand Down
4 changes: 4 additions & 0 deletions kubernetes-templates/01_namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: cvat
12 changes: 12 additions & 0 deletions kubernetes-templates/02_cvat_backend_storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cvat-backend-data
namespace: cvat
spec:
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
requests:
storage: 20Gi
13 changes: 13 additions & 0 deletions kubernetes-templates/02_database_secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: cvat-postgres-secret
namespace: cvat
labels:
app: cvat-app
tier: db
stringData:
POSTGRES_DB: cvat
POSTGRES_USER: root
POSTGRES_PASSWORD: POSTGRES_ADMIN_PW
12 changes: 12 additions & 0 deletions kubernetes-templates/02_database_storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cvat-postgres-data
namespace: cvat
spec:
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
requests:
storage: 20Gi
61 changes: 61 additions & 0 deletions kubernetes-templates/03_database_deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cvat-postgres
namespace: cvat
labels:
app: cvat-app
tier: db
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: cvat-app
tier: db
template:
metadata:
labels:
app: cvat-app
tier: db
spec:
containers:
- name: cvat-postgres
image: postgres:10.3-alpine
imagePullPolicy: "IfNotPresent"
env:
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: cvat-postgres-secret
key: POSTGRES_DB
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: cvat-postgres-secret
key: POSTGRES_USER
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: cvat-postgres-secret
key: POSTGRES_PASSWORD
ports:
- containerPort: 5432
readinessProbe:
exec:
command:
- sh
- -c
- su - postgres -c "pg_isready --host=$POD_IP"
initialDelaySeconds: 15
timeoutSeconds: 2
resources: {}
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
subPath: postgres
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: cvat-postgres-data
29 changes: 29 additions & 0 deletions kubernetes-templates/03_redis_deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cvat-redis
namespace: cvat
labels:
app: cvat-app
tier: redis-app
spec:
replicas: 1
selector:
matchLabels:
app: cvat-app
tier: redis-app
template:
metadata:
labels:
app: cvat-app
tier: redis-app
spec:
containers:
- image: redis:4.0.5-alpine
name: cvat-redis
imagePullPolicy: Always
ports:
- containerPort: 6379
resources:
limits:
cpu: "0.1"
96 changes: 96 additions & 0 deletions kubernetes-templates/04_cvat_backend_deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cvat-backend
namespace: cvat
labels:
app: cvat-app
tier: backend
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: cvat-app
tier: backend
template:
metadata:
labels:
app: cvat-app
tier: backend
spec:
containers:
- name: cvat-backend-app-container
image: {my.registry.backend.image:develop}
imagePullPolicy: Always
resources:
requests:
cpu: 10m
memory: 100Mi
env:
- name: DJANGO_MODWSGI_EXTRA_ARGS
value: ""
- name: UI_PORT
value: "80"
- name: UI_HOST
value: "cvat-frontend-service"
- name: ALLOWED_HOSTS
value: "{MY_SERVER_URL_COM}"
- name: CVAT_REDIS_HOST
value: "cvat-redis-service"
- name: CVAT_POSTGRES_HOST
value: "cvat-postgres-service"
- name: CVAT_POSTGRES_USER
valueFrom:
secretKeyRef:
name: cvat-postgres-secret
key: POSTGRES_USER
- name: CVAT_POSTGRES_DBNAME
valueFrom:
secretKeyRef:
name: cvat-postgres-secret
key: POSTGRES_DB
- name: CVAT_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: cvat-postgres-secret
key: POSTGRES_PASSWORD
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
initContainers:
- name: user-data-permission-fix
image: busybox
command: ["/bin/chmod", "-R", "777", "/home/django"]
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
volumes:
- name: cvat-backend-data
persistentVolumeClaim:
claimName: cvat-backend-data
imagePullSecrets:
- name: gitlab-registry
36 changes: 36 additions & 0 deletions kubernetes-templates/04_cvat_frontend_deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: cvat-frontend
namespace: cvat
labels:
app: cvat-app
tier: frontend
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: cvat-app
tier: frontend
template:
metadata:
labels:
app: cvat-app
tier: frontend
spec:
containers:
- name: cvat-frontend-app-container
image: {my.registry.fronend.image:develop}
imagePullPolicy: always
env:
- name: REACT_APP_API_PROTOCOL
value: "http"
- name: REACT_APP_API_HOST
value: "{MY_SERVER_URL_COM}"
- name: REACT_APP_API_PORT
value: "8080"
ports:
- containerPort: 80
resources: {}
18 changes: 18 additions & 0 deletions kubernetes-templates/04_database_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: cvat-postgres-service
namespace: cvat
labels:
app: cvat-app
tier: db
spec:
type: ClusterIP
selector:
app: cvat-app
tier: db
ports:
- port: 5432
targetPort: 5432
protocol: TCP
name: http
18 changes: 18 additions & 0 deletions kubernetes-templates/04_redis_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: cvat-redis-service
namespace: cvat
labels:
app: cvat-app
tier: redis-app
spec:
type: ClusterIP
selector:
app: cvat-app
tier: redis-app
ports:
- port: 6379
targetPort: 6379
protocol: TCP
name: http
18 changes: 18 additions & 0 deletions kubernetes-templates/05_cvat_backend_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: cvat-backend-service
namespace: cvat
labels:
app: cvat-app
tier: backend
spec:
type: ClusterIP
selector:
app: cvat-app
tier: backend
ports:
- port: 8080
targetPort: 8080
protocol: TCP
name: http
18 changes: 18 additions & 0 deletions kubernetes-templates/05_cvat_frontend_service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: cvat-frontend-service
namespace: cvat
labels:
app: cvat-app
tier: frontend
spec:
type: ClusterIP
selector:
app: cvat-app
tier: frontend
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
Loading

0 comments on commit a29c880

Please sign in to comment.