Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87a5e40e3e | ||
|
|
bf7f831c42 | ||
|
|
f74a1a7076 | ||
|
|
6c9c0ffad2 | ||
|
|
4b1d75b1ba | ||
|
|
6f06f7d657 | ||
|
|
91c4928ec7 |
@@ -1,288 +1,288 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<title>Scaled up</title>
|
<title>Scaled up</title>
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto|Varela+Round">
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@charset "UTF-8";
|
@charset "UTF-8";
|
||||||
.m-b-xs {
|
.m-b-xs {
|
||||||
margin-bottom: 2%;
|
margin-bottom: 2%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.m-b-md {
|
.m-b-md {
|
||||||
margin-bottom: 10%;
|
margin-bottom: 10%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.m-t-xs {
|
.m-t-xs {
|
||||||
margin-top: 2%;
|
margin-top: 2%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.m-t-sm {
|
.m-t-sm {
|
||||||
margin-top: 5%;
|
margin-top: 5%;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
outline: 0 !important;
|
outline: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
padding: 2% 0;
|
padding: 2% 0;
|
||||||
background-color: #37404a;
|
background-color: #37404a;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-family: "Roboto", sans-serif;
|
font-family: "Roboto", sans-serif;
|
||||||
font-size: 2.2em;
|
font-size: 2.2em;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
color: #85ffc7;
|
color: #85ffc7;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
font-family: "Roboto", sans-serif;
|
font-family: "Roboto", sans-serif;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
a:hover {
|
a:hover {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
#survey-form label,
|
#survey-form label,
|
||||||
#survey-form .labels {
|
#survey-form .labels {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 2%;
|
margin-bottom: 2%;
|
||||||
font-family: "Roboto", sans-serif;
|
font-family: "Roboto", sans-serif;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
letter-spacing: 0.5px;
|
letter-spacing: 0.5px;
|
||||||
}
|
}
|
||||||
#survey-form input::-webkit-input-placeholder {
|
#survey-form input::-webkit-input-placeholder {
|
||||||
color: transparent !important;
|
color: transparent !important;
|
||||||
}
|
}
|
||||||
#survey-form input::-moz-placeholder {
|
#survey-form input::-moz-placeholder {
|
||||||
color: transparent !important;
|
color: transparent !important;
|
||||||
}
|
}
|
||||||
#survey-form input:-ms-input-placeholder {
|
#survey-form input:-ms-input-placeholder {
|
||||||
color: transparent !important;
|
color: transparent !important;
|
||||||
}
|
}
|
||||||
#survey-form input:-moz-placeholder {
|
#survey-form input:-moz-placeholder {
|
||||||
color: transparent !important;
|
color: transparent !important;
|
||||||
}
|
}
|
||||||
#survey-form input,
|
#survey-form input,
|
||||||
#survey-form select {
|
#survey-form select {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
outline: none;
|
outline: none;
|
||||||
border: 2px solid #333;
|
border: 2px solid #333;
|
||||||
}
|
}
|
||||||
#survey-form input {
|
#survey-form input {
|
||||||
margin-top: 1.5%;
|
margin-top: 1.5%;
|
||||||
padding: 0 0 5px 0;
|
padding: 0 0 5px 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
border-bottom: 2px solid #fff;
|
border-bottom: 2px solid #fff;
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
color: #85ffc7;
|
color: #85ffc7;
|
||||||
}
|
}
|
||||||
#survey-form input:focus {
|
#survey-form input:focus {
|
||||||
border-color: #85ffc7;
|
border-color: #85ffc7;
|
||||||
}
|
}
|
||||||
#survey-form [type=checkbox],
|
#survey-form [type=checkbox],
|
||||||
#survey-form [type=radio] {
|
#survey-form [type=radio] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: auto;
|
width: auto;
|
||||||
margin: 0px 10px 0 0;
|
margin: 0px 10px 0 0;
|
||||||
}
|
}
|
||||||
#survey-form [type=checkbox],
|
#survey-form [type=checkbox],
|
||||||
#survey-form [type=radio] {
|
#survey-form [type=radio] {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0 10px 0 0 !important;
|
margin: 0 10px 0 0 !important;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
-o-appearance: none;
|
-o-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
width: 23px;
|
width: 23px;
|
||||||
transition: all 0.15s ease-out 0s;
|
transition: all 0.15s ease-out 0s;
|
||||||
background: #37404a;
|
background: #37404a;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
outline: none;
|
outline: none;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
border: 1px solid #fff;
|
border: 1px solid #fff;
|
||||||
}
|
}
|
||||||
#survey-form [type=checkbox]:hover,
|
#survey-form [type=checkbox]:hover,
|
||||||
#survey-form [type=radio]:hover {
|
#survey-form [type=radio]:hover {
|
||||||
border-color: #85ffc7;
|
border-color: #85ffc7;
|
||||||
}
|
}
|
||||||
#survey-form [type=checkbox]:checked:before,
|
#survey-form [type=checkbox]:checked:before,
|
||||||
#survey-form [type=radio]:checked:before {
|
#survey-form [type=radio]:checked:before {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 21px;
|
height: 21px;
|
||||||
width: 21px;
|
width: 21px;
|
||||||
position: relative;
|
position: relative;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
content: "";
|
content: "";
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-family: "Glyphicons Halflings";
|
font-family: "Glyphicons Halflings";
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: #85ffc7;
|
color: #85ffc7;
|
||||||
}
|
}
|
||||||
#survey-form [type=checkbox]:focus,
|
#survey-form [type=checkbox]:focus,
|
||||||
#survey-form [type=radio]:focus {
|
#survey-form [type=radio]:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
border-color: #fff;
|
border-color: #fff;
|
||||||
}
|
}
|
||||||
#survey-form [type=radio] {
|
#survey-form [type=radio] {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
#survey-form [type=radio]:after {
|
#survey-form [type=radio]:after {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
#survey-form [type=number] {
|
#survey-form [type=number] {
|
||||||
width: 45px;
|
width: 45px;
|
||||||
}
|
}
|
||||||
#survey-form [type=number]::-webkit-inner-spin-button, #survey-form [type=number]::-webkit-outer-spin-button {
|
#survey-form [type=number]::-webkit-inner-spin-button, #survey-form [type=number]::-webkit-outer-spin-button {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
-moz-appearance: none;
|
-moz-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
#survey-form select {
|
#survey-form select {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
background-color: #37404a;
|
background-color: #37404a;
|
||||||
border: 2px solid #fff;
|
border: 2px solid #fff;
|
||||||
color: #85ffc7;
|
color: #85ffc7;
|
||||||
}
|
}
|
||||||
#survey-form select option {
|
#survey-form select option {
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
#survey-form select option:hover {
|
#survey-form select option:hover {
|
||||||
background-color: #85ffc7;
|
background-color: #85ffc7;
|
||||||
}
|
}
|
||||||
#survey-form textarea {
|
#survey-form textarea {
|
||||||
resize: none;
|
resize: none;
|
||||||
margin-top: 2%;
|
margin-top: 2%;
|
||||||
padding: 10px 10px 0px 20px;
|
padding: 10px 10px 0px 20px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 90px;
|
height: 90px;
|
||||||
color: #85ffc7;
|
color: #85ffc7;
|
||||||
background-color: #37404a;
|
background-color: #37404a;
|
||||||
border: 2px solid #fff;
|
border: 2px solid #fff;
|
||||||
}
|
}
|
||||||
#survey-form .btn {
|
#survey-form .btn {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 3% 0 0 0;
|
margin: 3% 0 0 0;
|
||||||
height: 45px;
|
height: 45px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border: 3px solid #85ffc7;
|
border: 3px solid #85ffc7;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
color: #85ffc7;
|
color: #85ffc7;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background: none;
|
background: none;
|
||||||
transition: color 0.25s ease;
|
transition: color 0.25s ease;
|
||||||
}
|
}
|
||||||
#survey-form .btn:after {
|
#survey-form .btn:after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
content: "";
|
content: "";
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #85ffc7;
|
background-color: #85ffc7;
|
||||||
transform-origin: left;
|
transform-origin: left;
|
||||||
transition: width 0.5s ease;
|
transition: width 0.5s ease;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
#survey-form .btn:hover {
|
#survey-form .btn:hover {
|
||||||
color: #37404a;
|
color: #37404a;
|
||||||
}
|
}
|
||||||
#survey-form .btn:hover:after {
|
#survey-form .btn:hover:after {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
#survey-form fieldset {
|
#survey-form fieldset {
|
||||||
margin: 5% 0 0 0;
|
margin: 5% 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.copyright {
|
.copyright {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
.copyright i {
|
.copyright i {
|
||||||
color: #ef5350;
|
color: #ef5350;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
body {
|
body {
|
||||||
padding: 8% 0;
|
padding: 8% 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<main id="main" class="container">
|
<main id="main" class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12 col-lg-offset-3 col-lg-6">
|
<div class="col-xs-12 col-lg-offset-3 col-lg-6">
|
||||||
<div class="m-b-md text-center">
|
<div class="m-b-md text-center">
|
||||||
<h1 id="title">Stash Form</h1>
|
<h1 id="title">Stash Form</h1>
|
||||||
<p id="description" class="description" class="text-center">Download form</p>
|
<p id="description" class="description" class="text-center">Download form</p>
|
||||||
</div>
|
</div>
|
||||||
<form method="GET" action="/stash/submit-form/" id="survey-form" name="survey-form">
|
<form method="GET" action="/stash/submit-form/" id="survey-form" name="survey-form">
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="name" id="name-label">
|
<label for="name" id="name-label">
|
||||||
Name *
|
Name *
|
||||||
<input class="" type="text" id="name" name="name" placeholder="Enter your name (required)" required />
|
<input class="" type="text" id="name" name="name" placeholder="Enter your name (required)" required />
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="url" id="url-label">
|
<label for="url" id="url-label">
|
||||||
URL *
|
URL *
|
||||||
<input class="" type="url" id="url" name="url" placeholder="Enter the URL (required)" required />
|
<input class="" type="url" id="url" name="url" placeholder="Enter the URL (required)" required />
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label for="survey-form-suggestions">
|
<label for="external_galleries">
|
||||||
Any Comments or Suggestions?
|
Any external galleries ?
|
||||||
<textarea id="survey-form-suggestions" maxlength="194"></textarea>
|
<textarea id="external_galleries" maxlength="194"></textarea>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button id="submit" type="submit" class="btn">Submit the form</button>
|
<button id="submit" type="submit" class="btn">Submit the form</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from jinja2 import Environment, FileSystemLoader
|
|||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from kubernetes import client, config
|
from kubernetes import client, config
|
||||||
|
|
||||||
#from django.template.loader import render_to_string
|
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
import mimetypes
|
import mimetypes
|
||||||
@@ -22,130 +21,29 @@ def form(request):
|
|||||||
def handle_survey_form(request):
|
def handle_survey_form(request):
|
||||||
config.load_kube_config(config_file='/kubeconfig/config')
|
config.load_kube_config(config_file='/kubeconfig/config')
|
||||||
v1 = client.BatchV1Api()
|
v1 = client.BatchV1Api()
|
||||||
|
|
||||||
name = request.GET.get('name')
|
name = request.GET.get('name')
|
||||||
url = request.GET.get('url')
|
url = request.GET.get('url')
|
||||||
|
external_galleries = request.GET.get('external_galleries')
|
||||||
|
|
||||||
environment = Environment(loader=FileSystemLoader("django_code/stash_management/templates/"))
|
with open('django_code/stash_management/templates/template.stash-pornpics-dowloader.job.yml', 'r') as file:
|
||||||
template = environment.get_template("template.stash-pornpics-dowloader.job.yml")
|
#get the manifest in a variable template_manifest from the manifest file
|
||||||
pod_manifest_job = template.render(name=name, url=url)
|
template_manifest = yaml.safe_load(file)
|
||||||
|
|
||||||
|
#edit the container name
|
||||||
|
template_manifest['metadata']['name'] ="stash-pornpics-dowloader"+name
|
||||||
|
template_manifest['spec']['template']['spec']['containers'][0]['name'] ="stash-pornpics-dowloader-"+name
|
||||||
|
|
||||||
|
#edit the command based on the input
|
||||||
|
command=['bash', '/config/download.sh', '--http_proxy', 'http://gluetun-svc.gluetun.svc:8888', '--BASE_URL', url, '--pornstars', name,'--external_gallery', external_galleries]
|
||||||
|
template_manifest['spec']['template']['spec']['containers'][0]['command']=command
|
||||||
|
|
||||||
|
|
||||||
|
#execute based on the value
|
||||||
|
api_response = v1.create_namespaced_job(body=template_manifest,namespace='stash')
|
||||||
|
|
||||||
api_response = v1.create_namespaced_job(body=pod_manifest_job)
|
|
||||||
return HttpResponse(api_response)
|
|
||||||
|
|
||||||
# You can now process or store the data
|
|
||||||
#return HttpResponse(f"Received: {name}, {url}")
|
|
||||||
#return HttpResponse(content)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def scale_up(request,namespace_name,deploy_name):
|
|
||||||
config.load_kube_config(config_file='/kubeconfig/config')
|
|
||||||
api = client.AppsV1Api()
|
|
||||||
deployment = api.read_namespaced_deployment(name=deploy_name, namespace=namespace_name)
|
|
||||||
deployment.spec.replicas = 1
|
|
||||||
resp = api.patch_namespaced_deployment(
|
|
||||||
name=deploy_name, namespace=namespace_name, body=deployment);
|
|
||||||
#return HttpResponse('<h1>Scaled up !</h1>')
|
|
||||||
return render(request, 'start.html', {'namespace':namespace_name,'deployment': deploy_name, 'url': 'https://namespace.com'})
|
|
||||||
|
|
||||||
|
|
||||||
def scale_down(request,namespace_name,deploy_name):
|
|
||||||
config.load_kube_config(config_file='/kubeconfig/config')
|
|
||||||
api = client.AppsV1Api()
|
|
||||||
deployment = api.read_namespaced_deployment(name=deploy_name, namespace=namespace_name)
|
|
||||||
deployment.spec.replicas = 0
|
|
||||||
resp = api.patch_namespaced_deployment(
|
|
||||||
name=deploy_name, namespace=namespace_name, body=deployment);
|
|
||||||
#return HttpResponse('<h1>Scaled down !</h1>')
|
|
||||||
return render(request, 'shutdown.html',
|
|
||||||
{'namespace': namespace_name, 'deployment': deploy_name, 'url': 'https://namespace.com'})
|
|
||||||
|
|
||||||
def nodes(request):
|
|
||||||
config.load_kube_config(config_file='/code/kubeconfig')
|
|
||||||
v1 = client.CoreV1Api()
|
|
||||||
# v1.list_node()
|
|
||||||
pod_manifest = {
|
|
||||||
'apiVersion': 'v1',
|
|
||||||
'kind': 'Pod',
|
|
||||||
'metadata': {
|
|
||||||
'labels': {
|
|
||||||
'bot': 'current-bot'
|
|
||||||
},
|
|
||||||
'name': 'podname',
|
|
||||||
'namespace': 'echo-server'
|
|
||||||
|
|
||||||
},
|
|
||||||
'spec': {
|
|
||||||
|
|
||||||
'containers': [{
|
|
||||||
'image': 'gitea.tryton.geeraert.eu/pi-ux-ce/bitwarden_cli:1.0.1',
|
|
||||||
# 'pod-running-timeout': '5m0s',
|
|
||||||
'name': 'testpython',
|
|
||||||
'env': [
|
|
||||||
{'name': 'env_variable', 'value': 'env_value'},
|
|
||||||
]
|
|
||||||
}],
|
|
||||||
'restartPolicy': 'Always',
|
|
||||||
# 'serviceAccountName': 'bots-service-account'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# print(f'POD MANIFEST:\n{pod_manifest}')
|
|
||||||
api_response = v1.create_namespaced_pod(body=pod_manifest,namespace='echo-server')
|
|
||||||
return HttpResponse(api_response)
|
|
||||||
|
|
||||||
def backup_job(request):
|
|
||||||
config.load_kube_config(config_file='/code/kubeconfig')
|
|
||||||
v1 = client.CoreV1Api()
|
|
||||||
#v1 = client.BatchV1Api()
|
|
||||||
# v1.list_node()
|
|
||||||
pod_manifest_job = {
|
|
||||||
'apiVersion': 'batch/v1',
|
|
||||||
'kind': 'Job',
|
|
||||||
'metadata': {
|
|
||||||
'name': 'bitwarden-backup-django',
|
|
||||||
'namespace': 'bwbackup'
|
|
||||||
|
|
||||||
},
|
|
||||||
'spec': {
|
|
||||||
'template': {
|
|
||||||
'spec': {
|
|
||||||
|
|
||||||
'containers': [{
|
|
||||||
'image': 'gitea.tryton.geeraert.eu/pi-ux-ce/bitwarden_cli:1.0.1',
|
|
||||||
'name': 'testpython',
|
|
||||||
'command': ['/bin/sh -c /config/export_bitwarden.sh'],
|
|
||||||
'env': [
|
|
||||||
{'name': 'env_variable', 'value': 'env_value'},
|
|
||||||
],
|
|
||||||
'volumeMounts': [
|
|
||||||
{'name': 'scripts', 'configMap': [{'name':'bitwarden-export-scripts'},]},
|
|
||||||
]
|
|
||||||
}],
|
|
||||||
'restartPolicy': 'Always',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
api_response = v1.create_namespaced_job(body=pod_manifest_job)
|
|
||||||
return HttpResponse(api_response)
|
return HttpResponse(api_response)
|
||||||
|
|
||||||
|
|
||||||
#help with yaml import
|
|
||||||
#https://github.com/kubernetes-client/python/issues/589
|
|
||||||
|
|
||||||
def backup_job_yaml(request,sync_target):
|
|
||||||
config.load_kube_config(config_file='/code/kubeconfig')
|
|
||||||
v1 = client.BatchV1Api()
|
|
||||||
|
|
||||||
yaml_location = {
|
|
||||||
"synology" : "https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/synology_pod.yaml",
|
|
||||||
"openmediavault":"https://gitea.tryton.geeraert.eu/pi-ux-ce/Backup_kube/raw/branch/main/Infrequent_access/openmediavault_pod.yaml"
|
|
||||||
}
|
|
||||||
print(yaml_location[sync_target])
|
|
||||||
url_to_select=yaml_location[sync_target]
|
|
||||||
api_response = v1.create_namespaced_job(body=pod_manifest_job)
|
|
||||||
|
|
||||||
return HttpResponse(api_response)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user