change to an URL instead
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 41s

This commit is contained in:
2024-11-12 11:02:28 +00:00
parent c7e5afc750
commit ccad16f38c
4 changed files with 5 additions and 13 deletions
+4 -12
View File
@@ -12,6 +12,8 @@ import random
import mimetypes
import ruamel.yaml
import yaml
import urllib.request
def hello(request):
return HttpResponse('<h1>Hello k8s!</h1>')
@@ -111,23 +113,13 @@ def backup_job(request):
def backup_job_yaml(request):
config.load_kube_config(config_file='/code/kubeconfig')
# v1 = client.CoreV1Api()
v1 = client.BatchV1Api()
# v1.list_node()
# pod_manifest_job = {
with urllib.request.urlopen("https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Django/pod.yaml") as fo:
with open('/code/pod.yaml') as fo:
# yaml = YAML(typ='rt')
#yaml.load(...)
# job = ruamel.yaml.load(fo)
# with open('/code/pod.yaml') as fo:
job = yaml.safe_load(fo)
v1.create_namespaced_job(
job['metadata']['namespace'], job, pretty=True
# _request_timeout=(settings.CONNECTION_TIMEOUT_SECONDS, settings.READ_TIMEOUT_SECONDS
)
return HttpResponse(job['metadata']['namespace'])