Make filestore storage class configurable

Also, use kustomize patches instead of vars.
This commit is contained in:
Stéphane Bidoul 2021-11-09 20:03:05 +01:00
parent db51e28dbd
commit 801790ed05
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
9 changed files with 40 additions and 30 deletions

View file

@ -5,6 +5,7 @@ RUNBOAT_BUILD_NAMESPACE=runboat-builds
RUNBOAT_BUILD_DOMAIN=runboat-builds.odoo-community.org
RUNBOAT_BUILD_ENV={"PGHOST": "postgres14.runboat-builds-db", "PGPORT": "5432", "PGUSER": "runboat-build"}
RUNBOAT_BUILD_SECRET_ENV={"PGPASSWORD": "..."}
RUNBOAT_BUILD_TEMPLATE_VARS={"storageClassName": "my-storage-class"}
RUNBOAT_GITHUB_TOKEN=
RUNBOAT_LOG_CONFIG=log-config.yaml
RUNBOAT_BASE_URL=https://runboat.odoo-community.org

View file

@ -5,6 +5,7 @@ RUNBOAT_BUILD_NAMESPACE=runboat-builds
RUNBOAT_BUILD_DOMAIN=runboat.odoo-community.org
RUNBOAT_BUILD_ENV={}
RUNBOAT_BUILD_SECRET_ENV={"PGPASSWORD": "thepgpassword"}
RUNBOAT_BUILD_TEMPLATE_VARS={"storageClassName": "my-storage-class"}
RUNBOAT_GITHUB_TOKEN=
RUNBOAT_LOG_CONFIG=log-config.yaml
RUNBOAT_BUILD_IMAGES={"15.0": "ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest"}

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
tmp/
src/runboat/kubefiles/kustomization.yaml
# Byte-compiled / optimized / DLL files
__pycache__/

View file

@ -142,6 +142,7 @@ class DeploymentVars(BaseModel):
image_tag: str
build_env: dict[str, str]
build_secret_env: dict[str, str]
build_template_vars: dict[str, str]
def make_deployment_vars(
@ -169,6 +170,7 @@ def make_deployment_vars(
image_tag=image_tag,
build_env=settings.build_env or {},
build_secret_env=settings.build_secret_env or {},
build_template_vars=settings.build_template_vars or {},
)

View file

@ -4,8 +4,7 @@ metadata:
name: odoo
spec:
rules:
- host: $(HOSTNAME)
http:
- http:
paths:
- path: /
pathType: Prefix

View file

@ -52,22 +52,22 @@ configMapGenerator:
- runboat-initialize.sh
- runboat-cleanup.sh
- runboat-start.sh
{%- if mode == 'deployment' %}
- name: vars
literals:
- HOSTNAME={{ build_slug }}.{{ build_domain }}
{%- endif %}
generatorOptions:
disableNameSuffixHash: true
{% if mode == 'deployment' -%}
vars:
- name: HOSTNAME
objref:
name: vars
kind: ConfigMap
apiVersion: v1
fieldref:
fieldpath: data.HOSTNAME
{% endif %}
patches:
- target:
kind: PersistentVolumeClaim
name: odoo-data
patch: |-
- op: replace
path: /spec/storageClassName
value: {{ build_template_vars["storageClassName"] }}
- target:
kind: Ingress
name: odoo
patch: |-
- op: replace
path: /spec/rules/0/host
value: {{ build_slug }}.{{ build_domain }}

View file

@ -3,7 +3,6 @@ kind: PersistentVolumeClaim
metadata:
name: odoo-data
spec:
storageClassName: openebs-zfs-localpv-slow # TODO make this configurable
accessModes:
- ReadWriteOnce
resources:

View file

@ -24,6 +24,9 @@ class Settings(BaseSettings):
# A dictionary of secret environment variables to set in the build container and
# jobs.
build_secret_env: Optional[dict[str, str]]
# A dictionary of variables to be set in the jinja rendering context for the
# kubefiles.
build_template_vars: Optional[dict[str, str]]
# A mapping of main branch names to container images used to run the builds.
build_images: dict[str, str] = {
"15.0": "ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest",

View file

@ -43,21 +43,25 @@ configMapGenerator:
- runboat-initialize.sh
- runboat-cleanup.sh
- runboat-start.sh
- name: vars
literals:
- HOSTNAME=build-slug.runboat.odoo-community.org
generatorOptions:
disableNameSuffixHash: true
vars:
- name: HOSTNAME
objref:
name: vars
kind: ConfigMap
apiVersion: v1
fieldref:
fieldpath: data.HOSTNAME
patches:
- target:
kind: PersistentVolumeClaim
name: odoo-data
patch: |-
- op: replace
path: /spec/storageClassName
value: my-storage-class
- target:
kind: Ingress
name: odoo
patch: |-
- op: replace
path: /spec/rules/0/host
value: build-slug.runboat.odoo-community.org
"""
@ -76,4 +80,4 @@ def test_render_kubefiles():
assert (tmp_path / "kustomization.yaml").is_file()
assert (tmp_path / "deployment.yaml").is_file()
kustomization = (tmp_path / "kustomization.yaml").read_text()
assert kustomization == EXPECTED
assert kustomization.strip() == EXPECTED.strip()