Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MDM Lab
Website
Commits
bd7ab0c0
Commit
bd7ab0c0
authored
1 year ago
by
Remi PLANEL
Browse files
Options
Downloads
Patches
Plain Diff
add sidecar cron
parent
f222abff
No related branches found
No related tags found
1 merge request
!14
Draft: Resolve "Kube: create sidecar container to clean uploaded file"
Pipeline
#125248
passed
1 year ago
Stage: delete-release
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/Dockerfile
+12
-4
12 additions, 4 deletions
backend/Dockerfile
backend/docker-cron/clean.cron
+1
-0
1 addition, 0 deletions
backend/docker-cron/clean.cron
deploy/charts/djangoninja/templates/deployment.yaml
+56
-0
56 additions, 0 deletions
deploy/charts/djangoninja/templates/deployment.yaml
with
69 additions
and
4 deletions
backend/Dockerfile
+
12
−
4
View file @
bd7ab0c0
...
@@ -12,22 +12,30 @@ COPY ./pyproject.toml ./poetry.lock* /tmp/
...
@@ -12,22 +12,30 @@ COPY ./pyproject.toml ./poetry.lock* /tmp/
RUN
poetry
export
-f
requirements.txt
--output
requirements.txt
--without-hashes
RUN
poetry
export
-f
requirements.txt
--output
requirements.txt
--without-hashes
FROM
python:3.11.4-slim-bookworm
FROM
python:3.11.4-slim-bookworm
as
django
RUN
apt update
-y
&&
apt upgrade
-y
&&
apt
install
-y
python3-dev libpq-dev cron
RUN
apt update
-y
&&
apt upgrade
-y
&&
apt
install
-y
python3-dev libpq-dev cron
RUN
useradd
-ms
/bin/bash worker
RUN
useradd
-ms
/bin/bash worker
USER
worker
WORKDIR
/code
COPY
docker-cron/clean.cron /etc/cron.d/clean-session
WORKDIR
/code
RUN
crontab
-u
worker /etc/cron.d/clean-session
COPY
--chown=worker:worker --from=requirements-stage /tmp/requirements.txt /code/requirements.txt
COPY
--chown=worker:worker --from=requirements-stage /tmp/requirements.txt /code/requirements.txt
USER
worker
RUN
pip
install
--user
--no-cache-dir
--upgrade
-r
/code/requirements.txt
RUN
pip
install
--user
--no-cache-dir
--upgrade
-r
/code/requirements.txt
COPY
--chown=worker:worker . ./
COPY
--chown=worker:worker . ./
EXPOSE
8000
EXPOSE
8000
# CMD ["service", "cron", "start"]
CMD
["gunicorn", "--timeout", "120", "--bind", ":8000", "defense_finder_api.wsgi:application"]
CMD
["gunicorn", "--timeout", "120", "--bind", ":8000", "defense_finder_api.wsgi:application"]
This diff is collapsed.
Click to expand it.
backend/docker-cron/clean.cron
0 → 100644
+
1
−
0
View file @
bd7ab0c0
*/5 * * * * python /code/manage.py clear-sessions-history
This diff is collapsed.
Click to expand it.
deploy/charts/djangoninja/templates/deployment.yaml
+
56
−
0
View file @
bd7ab0c0
...
@@ -93,6 +93,62 @@ spec:
...
@@ -93,6 +93,62 @@ spec:
# name: server-static
# name: server-static
-
mountPath
:
/uploaded-files
-
mountPath
:
/uploaded-files
name
:
uploaded-files
name
:
uploaded-files
-
name
:
"
{{
.Chart.Name
}}-cron"
securityContext
:
{{
- toYaml .Values.securityContext | nindent 12
}}
image
:
"
{{
.Values.image.repository
}}:{{
.Values.image.tag
|
default
.Chart.AppVersion
}}"
imagePullPolicy
:
{{
.Values.image.pullPolicy
}}
command
:
-
service
args
:
-
cron
-
start
envFrom
:
-
configMapRef
:
name
:
galaxy-config-map
env
:
-
name
:
DEBUG
value
:
"
True"
-
name
:
SECRET_KEY
value
:
{{
.Values.django.secret
}}
-
name
:
GALAXY_API_KEY
valueFrom
:
secretKeyRef
:
name
:
galaxy-secret
key
:
galaxy_key
-
name
:
DF_HOSTNAME
value
:
{{
.Release.Name
}}
-
name
:
POSTGRES_PASSWORD
valueFrom
:
secretKeyRef
:
name
:
"
{{
.Values.postgresql.user
}}.{{
.Values.postgresql.teamId
}}-postgresql.credentials.postgresql.acid.zalan.do"
key
:
password
-
name
:
POSTGRES_USER
valueFrom
:
secretKeyRef
:
name
:
"
{{
.Values.postgresql.user
}}.{{
.Values.postgresql.teamId
}}-postgresql.credentials.postgresql.acid.zalan.do"
key
:
username
-
name
:
POSTGRES_DB
value
:
{{
.Values.postgresql.name
}}
-
name
:
DATABASE_URL
value
:
"
psql://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@{{
.Values.postgresql.teamId
}}-postgresql:5432/$(POSTGRES_DB)"
# livenessProbe:
# httpGet:
# path: /
# port: 8000
# readinessProbe:
# httpGet:
# path: /
# port: 8000
resources
:
{{
- toYaml .Values.resources | nindent 12
}}
volumeMounts
:
# - mountPath: /code/public/static
# name: server-static
-
mountPath
:
/uploaded-files
name
:
uploaded-files
{{
- with .Values.nodeSelector
}}
{{
- with .Values.nodeSelector
}}
nodeSelector
:
nodeSelector
:
{{
- toYaml . | nindent 8
}}
{{
- toYaml . | nindent 8
}}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment