Better docs leads to better code

This commit is contained in:
Stéphane Bidoul 2021-11-06 12:15:05 +01:00
parent cb7dfb4642
commit 61ec2f06a0
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
4 changed files with 15 additions and 14 deletions

View file

@ -88,20 +88,21 @@ it more robust. https://bugs.python.org/issue29309
## Kubernetes resources ## Kubernetes resources
All resources to be deployed in kubernetes for a build are in `src/runboat/kubefiles`. All resources to be deployed in kubernetes for a build are in
They are gathered together from a `kustomization.yaml` jinja template that leads to [src/runboat/kubefiles](./src/runboat/kubefiles). They are gathered together from a
three possible resource groups depending on a mode variable in the jinja rendering context: `kustomization.yaml` jinja template that leads to three possible resource groups
depending on a `mode` variable in the jinja rendering context:
- the deployment with its associated service and ingress; - `deployment` creates a kubernetes deployment with its associated service and ingress;
- the initialization job that creates the database; - `initialization` creates a job that creates the database;
- the cleanup job that drops the database; - `cleanup` creates a job that drops the database;
Besides the three modes, the controller has limited knowledge of what the kubefiles Besides the three modes, the controller has limited knowledge of what the kubefiles
actually deploy. It expects the following to hold true: actually deploy. It expects the following to hold true:
- the `runboat/build` label is set on all resources, with the unique build name as - the `runboat/build` label is set on all resources, with the unique build name as
value; value;
- a deployment starts with 0 replicas and must initially have a - a deployment starts with 0 replicas and is created with a
`runboat/init-status=todo` label, as well as a `runboat/cleanup` finalizer; `runboat/init-status=todo` label, as well as a `runboat/cleanup` finalizer;
- the intialization job has a `runboat/job-kind=initialize` label; - the intialization job has a `runboat/job-kind=initialize` label;
- the cleanup job has a `runboat/job-kind=cleanup` label. - the cleanup job has a `runboat/job-kind=cleanup` label.
@ -125,7 +126,7 @@ resources:
## TODO ## TODO
Prototype (min required to open the project): Advanced prototype (min required to open the project):
- plug it on a bunch of OCA and shopinvader repos to test load - plug it on a bunch of OCA and shopinvader repos to test load

View file

@ -119,7 +119,7 @@ def watch_jobs():
class DeploymentMode(str, Enum): class DeploymentMode(str, Enum):
deploy = "deploy" deployment = "deployment"
initialize = "initialize" initialize = "initialize"
cleanup = "cleanup" cleanup = "cleanup"

View file

@ -1,5 +1,5 @@
resources: resources:
{% if mode == 'deploy' -%} {% if mode == 'deployment' -%}
- deployment.yaml - deployment.yaml
- service.yaml - service.yaml
- ingress.yaml - ingress.yaml
@ -53,7 +53,7 @@ configMapGenerator:
- runboat-initialize.sh - runboat-initialize.sh
- runboat-cleanup.sh - runboat-cleanup.sh
- runboat-start.sh - runboat-start.sh
{% if mode == 'deploy' -%} {% if mode == 'deployment' -%}
- name: vars - name: vars
literals: literals:
- HOSTNAME={{ hostname }} - HOSTNAME={{ hostname }}
@ -62,7 +62,7 @@ configMapGenerator:
generatorOptions: generatorOptions:
disableNameSuffixHash: true disableNameSuffixHash: true
{% if mode == 'deploy' -%} {% if mode == 'deployment' -%}
vars: vars:
- name: HOSTNAME - name: HOSTNAME
objref: objref:

View file

@ -142,7 +142,7 @@ class Build(BaseModel):
_logger.info(f"Deploying {slug} ({name}).") _logger.info(f"Deploying {slug} ({name}).")
image = get_build_image(target_branch) image = get_build_image(target_branch)
deployment_vars = k8s.make_deployment_vars( deployment_vars = k8s.make_deployment_vars(
k8s.DeploymentMode.deploy, k8s.DeploymentMode.deployment,
name, name,
slug, slug,
repo.lower(), repo.lower(),