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
All resources to be deployed in kubernetes for a build are in `src/runboat/kubefiles`.
They are gathered together from a `kustomization.yaml` jinja template that leads to
three possible resource groups depending on a mode variable in the jinja rendering context:
All resources to be deployed in kubernetes for a build are in
[src/runboat/kubefiles](./src/runboat/kubefiles). They are gathered together from a
`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;
- the initialization job that creates the database;
- the cleanup job that drops the database;
- `deployment` creates a kubernetes deployment with its associated service and ingress;
- `initialization` creates a job that creates the database;
- `cleanup` creates a job that drops the database;
Besides the three modes, the controller has limited knowledge of what the kubefiles
actually deploy. It expects the following to hold true:
- the `runboat/build` label is set on all resources, with the unique build name as
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;
- the intialization job has a `runboat/job-kind=initialize` label;
- the cleanup job has a `runboat/job-kind=cleanup` label.
@ -125,7 +126,7 @@ resources:
## 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

View file

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

View file

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

View file

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