Skip to content
Snippets Groups Projects
Commit bd7ab0c0 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

add sidecar cron

parent f222abff
No related branches found
No related tags found
1 merge request!14Draft: Resolve "Kube: create sidecar container to clean uploaded file"
Pipeline #125248 passed
This commit is part of merge request !14. Comments created here will be created in the context of that merge request.
...@@ -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"]
*/5 * * * * python /code/manage.py clear-sessions-history
...@@ -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 }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment