Use a PVC for the Odoo filestore

This commit is contained in:
Stéphane Bidoul 2021-11-09 19:45:30 +01:00
parent 4263c5bcee
commit db51e28dbd
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
8 changed files with 36 additions and 4 deletions

View file

@ -188,6 +188,7 @@ def _render_kubefiles(deployment_vars: DeploymentVars) -> Generator[Path, None,
async def _kubectl(args: list[str]) -> None:
_logger.debug("kubectl %s", " ".join(args))
proc = await asyncio.create_subprocess_exec(
"kubectl", *args, stdout=subprocess.DEVNULL
)
@ -198,9 +199,10 @@ async def _kubectl(args: list[str]) -> None:
async def deploy(deployment_vars: DeploymentVars) -> None:
with _render_kubefiles(deployment_vars) as tmp_path:
# Dry-run first to avoid creaing some resources when the creation of the
# deployment fails. In such cases, we would have resource leak as the existence
# of deployment is how the controller knows it has something to manage.
# Dry-run first to avoid creating some resources when the creation of the
# deployment itself fails. In such cases, we would have resource leak as the
# existence of deployment is how the controller knows it has something to
# manage.
await _kubectl(
[
"apply",
@ -220,12 +222,13 @@ async def deploy(deployment_vars: DeploymentVars) -> None:
async def delete_resources(build_name: str) -> None:
# TODO delete all resources with runboat/build label
await _kubectl(
[
"-n",
settings.build_namespace,
"delete",
"configmap,deployment,ingress,job,secret,service",
"configmap,deployment,ingress,job,secret,service,pvc",
"-l",
f"runboat/build={build_name}",
"--wait=false",
@ -234,6 +237,7 @@ async def delete_resources(build_name: str) -> None:
async def delete_job(build_name: str, job_kind: DeploymentMode) -> None:
# TODO delete all resources with runboat/build and runboat/job-kind label
await _kubectl(
[
"-n",

View file

@ -23,6 +23,8 @@ spec:
volumeMounts:
- name: runboat-scripts
mountPath: /runboat
- name: odoo-data
mountPath: /opt/odoo-data
envFrom:
- secretRef:
name: odoosecretenv
@ -45,3 +47,6 @@ spec:
- name: runboat-scripts
configMap:
name: runboat-scripts
- name: odoo-data
persistentVolumeClaim:
claimName: odoo-data

View file

@ -13,6 +13,8 @@ spec:
volumeMounts:
- name: runboat-scripts
mountPath: /runboat
- name: odoo-data
mountPath: /opt/odoo-data
envFrom:
- secretRef:
name: odoosecretenv
@ -30,6 +32,9 @@ spec:
- name: runboat-scripts
configMap:
name: runboat-scripts
- name: odoo-data
persistentVolumeClaim:
claimName: odoo-data
restartPolicy: Never
backoffLimit: 0
activeDeadlineSeconds: 1200

View file

@ -1,9 +1,11 @@
resources:
{%- if mode == 'deployment' %}
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml
{%- elif mode == "initialize" %}
- pvc.yaml
- initialize.yaml
{%- elif mode == "cleanup" %}
- cleanup.yaml

View file

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: odoo-data
spec:
storageClassName: openebs-zfs-localpv-slow # TODO make this configurable
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
limits:
storage: 100Mi

View file

@ -16,6 +16,7 @@ dropdb --if-exists $PGDATABASE
ADDONS=$(addons --addons-dir ${ADDONS_DIR} --include "${INCLUDE}" --exclude "${EXCLUDE}" list)
unbuffer $(which odoo || which openerp-server) \
--data-dir=/opt/odoo-data \
-d ${PGDATABASE} \
-i ${ADDONS:-base} \
--stop-after-init

View file

@ -11,4 +11,5 @@ bash /runboat/runboat-clone-and-install.sh
oca_wait_for_postgres
unbuffer $(which odoo || which openerp-server) \
--data-dir=/opt/odoo-data \
-d ${PGDATABASE}

View file

@ -2,6 +2,7 @@ from runboat.k8s import DeploymentMode, _render_kubefiles, make_deployment_vars
EXPECTED = """\
resources:
- pvc.yaml
- deployment.yaml
- service.yaml
- ingress.yaml