Load in-cluster config is KUBECONFIG is not set

This commit is contained in:
Stéphane Bidoul 2021-11-07 12:47:05 +01:00
parent f012651501
commit 92c1d7da96
No known key found for this signature in database
GPG key ID: BCAB2555446B5B92
2 changed files with 9 additions and 4 deletions

View file

@ -58,9 +58,10 @@ For running the controller (runboat itself):
- Python 3.10
- `kubectl`
- A `KUBECONFIG` that provides access to the namespace where the builds are deployed,
with permissions to create and delete Service, Job, Deployment, Ingress, Secret and
ConfigMap resources.
- A `KUBECONFIG` or an in-cluster service account that provides access to the namespace
where the builds are deployed, with permissions to create and delete Service, Job,
Deployment, Ingress, Secret and ConfigMap resources as well as read and watch
Deployments and Jobs.
- Some sort of reverse proxy to expose the REST API.
The controller can be run outside the kubernetes cluster or deployed inside it, or even

View file

@ -1,5 +1,6 @@
import asyncio
import logging
import os
import shutil
import subprocess
import tempfile
@ -31,7 +32,10 @@ def _split_image_name_tag(img: str) -> tuple[str, str]:
@sync_to_async
def load_kube_config() -> None:
config.load_kube_config()
if "KUBECONFIG" in os.environ:
config.load_kube_config()
else:
config.load_incluster_config()
@sync_to_async