mirror of
https://github.com/netzbegruenung/green-spider.git
synced 2024-04-28 15:24:51 +02:00
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:
parent
fa2299c92d
commit
2da7c81b43
|
@ -26,6 +26,7 @@ services:
|
||||||
GIT_PASSWORD: ${GIT_PASSWORD}
|
GIT_PASSWORD: ${GIT_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
- ${PWD}/secrets:/secrets
|
- ${PWD}/secrets:/secrets
|
||||||
|
- ${PWD}/cache/green-directory:/workdir/cache/green-directory
|
||||||
networks:
|
networks:
|
||||||
- internal_network
|
- internal_network
|
||||||
- external_network
|
- external_network
|
||||||
|
|
|
@ -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 config
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -11,6 +17,8 @@ import kubernetes
|
||||||
PENDING_LIMIT = 2
|
PENDING_LIMIT = 2
|
||||||
RUNNING_LIMIT = 4
|
RUNNING_LIMIT = 4
|
||||||
|
|
||||||
|
KUBECONTEXT = 'gs-gollum-5jka7-clientcert'
|
||||||
|
|
||||||
INTERVAL = 10 # Seconds
|
INTERVAL = 10 # Seconds
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -20,7 +28,11 @@ def main():
|
||||||
random.seed()
|
random.seed()
|
||||||
random.shuffle(jobs)
|
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()
|
v1client = kubernetes.client.CoreV1Api()
|
||||||
k8sclient = kubernetes.client.ApiClient()
|
k8sclient = kubernetes.client.ApiClient()
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ def clone_data_directory():
|
||||||
into the local file system using git
|
into the local file system using git
|
||||||
"""
|
"""
|
||||||
if os.path.exists(config.GREEN_DIRECTORY_LOCAL_PATH):
|
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)
|
Repo.clone_from(config.GREEN_DIRECTORY_REPO, config.GREEN_DIRECTORY_LOCAL_PATH)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue