Automatisierung für Job-Erzeugung und -Ausführung in Kubernetes (#232)

* Add TODO

* Add link to example for in-cluster config

* Ignore .env files

* Mount green-directory clone as a volume

* Update kubectl context name

* Add a bit of instructions

* Let clone_data_directory return early if clone exists
This commit is contained in:
Marian Steinbach 2022-10-18 09:00:31 +02:00 committed by GitHub
parent fa2299c92d
commit 2da7c81b43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -26,6 +26,7 @@ services:
GIT_PASSWORD: ${GIT_PASSWORD}
volumes:
- ${PWD}/secrets:/secrets
- ${PWD}/cache/green-directory:/workdir/cache/green-directory
networks:
- internal_network
- external_network

View File

@ -1,3 +1,9 @@
# Howto:
#
# 1. source ./venv/bin/activate.fish
# 2. python cli.py manager
# 3. python k8s-job-manager.py
import config
import os
@ -11,6 +17,8 @@ import kubernetes
PENDING_LIMIT = 2
RUNNING_LIMIT = 4
KUBECONTEXT = 'gs-gollum-5jka7-clientcert'
INTERVAL = 10 # Seconds
def main():
@ -20,7 +28,11 @@ def main():
random.seed()
random.shuffle(jobs)
kubernetes.config.load_kube_config(context='gs-gollum-5jka7')
# TODO: change to work inside the cluster like shown in
# https://github.com/kubernetes-client/python/blob/master/examples/in_cluster_config.py#L55
#
kubernetes.config.load_kube_config(context=KUBECONTEXT)
v1client = kubernetes.client.CoreV1Api()
k8sclient = kubernetes.client.ApiClient()

View File

@ -28,7 +28,7 @@ def clone_data_directory():
into the local file system using git
"""
if os.path.exists(config.GREEN_DIRECTORY_LOCAL_PATH):
shutil.rmtree(config.GREEN_DIRECTORY_LOCAL_PATH)
return
Repo.clone_from(config.GREEN_DIRECTORY_REPO, config.GREEN_DIRECTORY_LOCAL_PATH)