Update to support helm2
This commit is contained in:
parent
d9de373d3c
commit
f66b447e0c
1
forms.py
1
forms.py
@ -9,6 +9,7 @@ from flask_bootstrap import Bootstrap
|
|||||||
|
|
||||||
|
|
||||||
class deploySelectForm(FlaskForm):
|
class deploySelectForm(FlaskForm):
|
||||||
|
tiller_ns = SelectField('tiller_ns', choices=[], coerce=str)
|
||||||
namespace = SelectField('namespace', choices=[], coerce=str)
|
namespace = SelectField('namespace', choices=[], coerce=str)
|
||||||
chart = SelectField('chart', choices=[])
|
chart = SelectField('chart', choices=[])
|
||||||
version = SelectField('remember me')
|
version = SelectField('remember me')
|
||||||
|
|||||||
22
main.py
22
main.py
@ -28,6 +28,18 @@ def get_namespaces():
|
|||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def get_tiller_namespaces():
|
||||||
|
command = "/usr/local/bin/kubectl get po --all-namespaces -l name=tiller -ojson"
|
||||||
|
info(f"Running command: {command}")
|
||||||
|
try:
|
||||||
|
output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
|
||||||
|
except CalledProcessError as err:
|
||||||
|
error(err.output.decode("utf-8"))
|
||||||
|
raise err
|
||||||
|
info(f"Output from command:\n{output}")
|
||||||
|
data = json.loads(output)
|
||||||
|
return data
|
||||||
|
|
||||||
def get_deployments(namespace):
|
def get_deployments(namespace):
|
||||||
command = "/usr/local/bin/kubectl -n " + namespace + " get deploy -ojson"
|
command = "/usr/local/bin/kubectl -n " + namespace + " get deploy -ojson"
|
||||||
info(f"Running command: {command}")
|
info(f"Running command: {command}")
|
||||||
@ -40,8 +52,9 @@ def get_deployments(namespace):
|
|||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_charts(namespace):
|
def get_charts(tiller_ns, namespace):
|
||||||
command = "/usr/bin/helm -n " + namespace + " list -ojson"
|
command = "/usr/bin/helm --tiller-namespace " + tiller_ns + " list -ojson" #helm2
|
||||||
|
#command = "/usr/bin/helm -n " + namespace + " list -ojson" #helm3
|
||||||
info(f"Running command: {command}")
|
info(f"Running command: {command}")
|
||||||
try:
|
try:
|
||||||
output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
|
output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
|
||||||
@ -52,8 +65,9 @@ def get_charts(namespace):
|
|||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_chartdata(namespace, chart):
|
def get_chartdata(tiller_ns, namespace, chart):
|
||||||
command = "/usr//bin/helm -n " + namespace + " history " + chart + " -ojson"
|
command = "/usr/bin/helm --tiller-namespace " + tiller_ns + " history " + chart + " -ojson" #helm2
|
||||||
|
#command = "/usr/bin/helm -n " + namespace + " history " + chart + " -ojson" #helm3
|
||||||
info(f"Running command: {command}")
|
info(f"Running command: {command}")
|
||||||
print(f"Running command: {command}")
|
print(f"Running command: {command}")
|
||||||
try:
|
try:
|
||||||
|
|||||||
BIN
routes/.nfs0000000000029d2200000001
Normal file
BIN
routes/.nfs0000000000029d2200000001
Normal file
Binary file not shown.
BIN
routes/.nfs0000000000029d2f00000002
Normal file
BIN
routes/.nfs0000000000029d2f00000002
Normal file
Binary file not shown.
@ -1,32 +1,34 @@
|
|||||||
from flask import render_template, request, jsonify
|
from flask import render_template, request, jsonify
|
||||||
from forms import deploySelectForm
|
from forms import deploySelectForm
|
||||||
from main import get_namespaces, get_charts, get_chartdata
|
from main import get_namespaces, get_charts, get_chartdata, get_tiller_namespaces
|
||||||
from . import routes
|
from . import routes
|
||||||
from tables import chartVersionTable
|
from tables import chartVersionTable
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@routes.route('/', methods=['GET', 'POST'])
|
@routes.route('/', methods=['GET', 'POST'])
|
||||||
def index():
|
def index():
|
||||||
|
tiller_ns = get_tiller_namespaces()
|
||||||
namespaces = get_namespaces()
|
namespaces = get_namespaces()
|
||||||
print(namespaces)
|
|
||||||
form = deploySelectForm()
|
form = deploySelectForm()
|
||||||
|
form.tiller_ns.choices = [(name['metadata']['namespace'], name['metadata']['namespace']) for name in tiller_ns['items']]
|
||||||
form.namespace.choices = [(name['metadata']['name'], name['metadata']['name']) for name in namespaces['items']]
|
form.namespace.choices = [(name['metadata']['name'], name['metadata']['name']) for name in namespaces['items']]
|
||||||
return render_template('nameChartSelect.html', namespaces=namespaces, form=form)
|
return render_template('nameChartSelect.html', namespaces=namespaces, tiller_ns=tiller_ns, form=form)
|
||||||
|
|
||||||
@routes.route('/chartSelect', methods=['POST'])
|
@routes.route('/chartSelect', methods=['POST'])
|
||||||
def chartVersions():
|
def chartVersions():
|
||||||
namespace = request.form['namespace']
|
namespace = request.form['namespace']
|
||||||
|
tiller_ns = request.form['tiller_ns']
|
||||||
chart = request.form['chart']
|
chart = request.form['chart']
|
||||||
chartVersions = get_chartdata(namespace, chart)
|
chartVersions = get_chartdata(tiller_ns, namespace, chart)
|
||||||
table = chartVersionTable(chartVersions)
|
table = chartVersionTable(chartVersions)
|
||||||
table.border = True
|
table.border = True
|
||||||
table.classes = ['table-striped', 'table-condensed', 'table-hover']
|
table.classes = ['table-striped', 'table-condensed', 'table-hover']
|
||||||
return render_template('chartRevisionList.html', table=table, namespace=namespace)
|
return render_template('chartRevisionList.html', table=table, namespace=namespace)
|
||||||
|
|
||||||
|
|
||||||
@routes.route('/nsLookup/<namespace>')
|
@routes.route('/nsLookup/<tiller>/<namespace>')
|
||||||
def namespaceLookup(namespace):
|
def namespaceLookup(tiller, namespace):
|
||||||
charts = get_charts(namespace)
|
charts = get_charts(tiller, namespace)
|
||||||
return jsonify(charts)
|
return jsonify(charts)
|
||||||
|
|
||||||
@routes.route('/deployChartRevision/<revision>/<chart>/<namespace>', methods=['POST'])
|
@routes.route('/deployChartRevision/<revision>/<chart>/<namespace>', methods=['POST'])
|
||||||
|
|||||||
@ -18,13 +18,21 @@
|
|||||||
<div class = "row">
|
<div class = "row">
|
||||||
<div class = "col-sm-6">
|
<div class = "col-sm-6">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon" id="basic-addon1">Namespace:</span>
|
<span class="input-group-addon" id="basic-addon1">Tiller Namespace:</span>
|
||||||
{{ form.namespace(class_="form-control") }}
|
{{ form.tiller_ns(class_="form-control") }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class = "col-sm-6">
|
<div class = "col-sm-6">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon" id="basic-addon2">Chart:</span>
|
<span class="input-group-addon" id="basic-addon2">Namespace:</span>
|
||||||
|
{{ form.namespace(class_="form-control") }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class = "row">
|
||||||
|
<div class = "col-sm-12">
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-addon" id="basic-addon3">Chart:</span>
|
||||||
{{ form.chart(class_="form-control") }}
|
{{ form.chart(class_="form-control") }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -36,20 +44,24 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
dd
|
||||||
</p>
|
</p>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
var tillerSelect = document.getElementById(tiller_ns");
|
||||||
var namespaceSelect = document.getElementById("namespace");
|
var namespaceSelect = document.getElementById("namespace");
|
||||||
var chartSelect = document.getElementById("chart");
|
var chartSelect = document.getElementById("chart");
|
||||||
|
|
||||||
|
tillerSelect.onchange = function() {myFunction()};
|
||||||
namespaceSelect.onchange = function() {myFunction()};
|
namespaceSelect.onchange = function() {myFunction()};
|
||||||
|
|
||||||
function myFunction() {
|
function myFunction() {
|
||||||
|
|
||||||
|
tiller_ns = tillerSelect.value;
|
||||||
namespace = namespaceSelect.value;
|
namespace = namespaceSelect.value;
|
||||||
|
|
||||||
fetch('/nsLookup/' + namespace).then(function(response) {
|
fetch('/nsLookup/' + tiller_ns + '/' + namespace).then(function(response) {
|
||||||
response.json().then(function(data) {
|
response.json().then(function(data) {
|
||||||
var optionHTML = '';
|
var optionHTML = '';
|
||||||
for (var chart of data) {
|
for (var chart of data) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user