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_DOMAIN=runboat-builds.odoo-community.org
RUNBOAT_BUILD_ENV={"PGHOST": "postgres14.runboat-builds-db", "PGPORT": "5432", "PGUSER": "runboat-build"} RUNBOAT_BUILD_ENV={"PGHOST": "postgres14.runboat-builds-db", "PGPORT": "5432", "PGUSER": "runboat-build"}
RUNBOAT_BUILD_SECRET_ENV={"PGPASSWORD": "..."} RUNBOAT_BUILD_SECRET_ENV={"PGPASSWORD": "..."}
RUNBOAT_BUILD_TEMPLATE_VARS={"storageClassName": "my-storage-class"}
RUNBOAT_GITHUB_TOKEN= RUNBOAT_GITHUB_TOKEN=
RUNBOAT_LOG_CONFIG=log-config.yaml RUNBOAT_LOG_CONFIG=log-config.yaml
RUNBOAT_BASE_URL=https://runboat.odoo-community.org 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_DOMAIN=runboat.odoo-community.org
RUNBOAT_BUILD_ENV={} RUNBOAT_BUILD_ENV={}
RUNBOAT_BUILD_SECRET_ENV={"PGPASSWORD": "thepgpassword"} RUNBOAT_BUILD_SECRET_ENV={"PGPASSWORD": "thepgpassword"}
RUNBOAT_BUILD_TEMPLATE_VARS={"storageClassName": "my-storage-class"}
RUNBOAT_GITHUB_TOKEN= RUNBOAT_GITHUB_TOKEN=
RUNBOAT_LOG_CONFIG=log-config.yaml RUNBOAT_LOG_CONFIG=log-config.yaml
RUNBOAT_BUILD_IMAGES={"15.0": "ghcr.io/oca/oca-ci/py3.8-odoo15.0:latest"} 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/ tmp/
src/runboat/kubefiles/kustomization.yaml
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

View file

@ -142,6 +142,7 @@ class DeploymentVars(BaseModel):
image_tag: str image_tag: str
build_env: dict[str, str] build_env: dict[str, str]
build_secret_env: dict[str, str] build_secret_env: dict[str, str]
build_template_vars: dict[str, str]
def make_deployment_vars( def make_deployment_vars(
@ -169,6 +170,7 @@ def make_deployment_vars(
image_tag=image_tag, image_tag=image_tag,
build_env=settings.build_env or {}, build_env=settings.build_env or {},
build_secret_env=settings.build_secret_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 name: odoo
spec: spec:
rules: rules:
- host: $(HOSTNAME) - http:
http:
paths: paths:
- path: / - path: /
pathType: Prefix pathType: Prefix

View file

@ -52,22 +52,22 @@ configMapGenerator:
- runboat-initialize.sh - runboat-initialize.sh
- runboat-cleanup.sh - runboat-cleanup.sh
- runboat-start.sh - runboat-start.sh
{%- if mode == 'deployment' %}
- name: vars
literals:
- HOSTNAME={{ build_slug }}.{{ build_domain }}
{%- endif %}
generatorOptions: generatorOptions:
disableNameSuffixHash: true disableNameSuffixHash: true
{% if mode == 'deployment' -%} patches:
vars: - target:
- name: HOSTNAME kind: PersistentVolumeClaim
objref: name: odoo-data
name: vars patch: |-
kind: ConfigMap - op: replace
apiVersion: v1 path: /spec/storageClassName
fieldref: value: {{ build_template_vars["storageClassName"] }}
fieldpath: data.HOSTNAME - target:
{% endif %} 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: metadata:
name: odoo-data name: odoo-data
spec: spec:
storageClassName: openebs-zfs-localpv-slow # TODO make this configurable
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
resources: resources:

View file

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

View file

@ -43,21 +43,25 @@ configMapGenerator:
- runboat-initialize.sh - runboat-initialize.sh
- runboat-cleanup.sh - runboat-cleanup.sh
- runboat-start.sh - runboat-start.sh
- name: vars
literals:
- HOSTNAME=build-slug.runboat.odoo-community.org
generatorOptions: generatorOptions:
disableNameSuffixHash: true disableNameSuffixHash: true
vars: patches:
- name: HOSTNAME - target:
objref: kind: PersistentVolumeClaim
name: vars name: odoo-data
kind: ConfigMap patch: |-
apiVersion: v1 - op: replace
fieldref: path: /spec/storageClassName
fieldpath: data.HOSTNAME 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 / "kustomization.yaml").is_file()
assert (tmp_path / "deployment.yaml").is_file() assert (tmp_path / "deployment.yaml").is_file()
kustomization = (tmp_path / "kustomization.yaml").read_text() kustomization = (tmp_path / "kustomization.yaml").read_text()
assert kustomization == EXPECTED assert kustomization.strip() == EXPECTED.strip()