Merge branch 'master' of ssh://git.ervine.org/jonny/flask-python-helm
This commit is contained in:
commit
e021f099a8
@ -6,16 +6,14 @@ LABEL MAINTAINER="Jonathan Ervine <jonathan.ervine@gogox.com>"
|
|||||||
ENV LANG='en_US.UTF-8' \
|
ENV LANG='en_US.UTF-8' \
|
||||||
LANGUAGE='en_US.UTF-8' \
|
LANGUAGE='en_US.UTF-8' \
|
||||||
FLASK_APP=/data/app-dev/app.py \
|
FLASK_APP=/data/app-dev/app.py \
|
||||||
VERSION=1.1.4
|
VERSION=1.1.5
|
||||||
|
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk -U upgrade --ignore alpine-baselayout && \
|
apk -U upgrade --ignore alpine-baselayout && \
|
||||||
apk -U add python3 gcc py3-pip python3-dev musl-dev libffi-dev git curl && \
|
apk -U add python3 gcc py3-pip python3-dev musl-dev libffi-dev git curl && \
|
||||||
adduser -D python && \
|
adduser -D python && \
|
||||||
mkdir /data && cd /data && git clone --single-branch --branch master https://github.com/jervine-gogo/python-helm-web /data && \
|
mkdir /data && cd /data && git clone --single-branch --branch issue-#2 https://github.com/jervine-gogo/python-helm-web /data && \
|
||||||
pip3 install -r /data/requirements.txt && \
|
pip3 install -r /data/requirements.txt && \
|
||||||
curl -L "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl && \
|
|
||||||
chmod 755 /usr/local/bin/kubectl && \
|
|
||||||
curl -L https://get.helm.sh/helm-v2.13.1-linux-amd64.tar.gz -o /tmp/helm-2.13.1.tgz && \
|
curl -L https://get.helm.sh/helm-v2.13.1-linux-amd64.tar.gz -o /tmp/helm-2.13.1.tgz && \
|
||||||
tar -zxvf /tmp/helm-2.13.1.tgz --strip-components=1 -C /usr/local/bin linux-amd64/helm && \
|
tar -zxvf /tmp/helm-2.13.1.tgz --strip-components=1 -C /usr/local/bin linux-amd64/helm && \
|
||||||
rm -rf /tmp/src && rm -rf /var/cache/apk/*
|
rm -rf /tmp/src && rm -rf /var/cache/apk/*
|
||||||
|
|||||||
17
main.py
17
main.py
@ -21,10 +21,9 @@ def get_namespaces():
|
|||||||
config.load_incluster_config()
|
config.load_incluster_config()
|
||||||
v1 = client.CoreV1Api()
|
v1 = client.CoreV1Api()
|
||||||
ns = v1.list_namespace()
|
ns = v1.list_namespace()
|
||||||
for namespace in ns.items:
|
|
||||||
print("%s" % (namespace.metadata.name))
|
|
||||||
return ns
|
return ns
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
def get_tiller_namespaces():
|
def get_tiller_namespaces():
|
||||||
command = "/usr/local/bin/kubectl get deploy --all-namespaces -l name=tiller -ojson"
|
command = "/usr/local/bin/kubectl get deploy --all-namespaces -l name=tiller -ojson"
|
||||||
info(f"Running command: {command}")
|
info(f"Running command: {command}")
|
||||||
@ -49,6 +48,8 @@ def get_deployments(namespace):
|
|||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> a7df40eb7710553f5d0185c3fa04ea6991c06f89
|
||||||
def get_charts(ns):
|
def get_charts(ns):
|
||||||
command = "/usr/local/bin/helm -n " + ns + " list -ojson" #helm3
|
command = "/usr/local/bin/helm -n " + ns + " list -ojson" #helm3
|
||||||
info(f"Running command: {command}")
|
info(f"Running command: {command}")
|
||||||
@ -67,9 +68,8 @@ def get_charts(ns):
|
|||||||
def sortRevision(n):
|
def sortRevision(n):
|
||||||
return n['revision']
|
return n['revision']
|
||||||
|
|
||||||
def get_chartdata(tiller_ns, namespace, chart, records):
|
def get_chartdata(ns, chart, records):
|
||||||
command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " history " + chart + " --max " + records + " --output json" #helm2
|
command = "/usr/local/bin/helm -n " + ns + " history " + chart + " --max " + records + " -ojson" #helm3
|
||||||
#command = "/usr/local/bin/helm -n " + namespace + " history " + chart + " -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")
|
||||||
@ -81,12 +81,11 @@ def get_chartdata(tiller_ns, namespace, chart, records):
|
|||||||
data.sort(reverse=True, key=sortRevision)
|
data.sort(reverse=True, key=sortRevision)
|
||||||
for revision in data:
|
for revision in data:
|
||||||
revision['chartName'] = chart
|
revision['chartName'] = chart
|
||||||
revision["namespace"] = namespace
|
revision["ns"] = ns
|
||||||
revision["tiller_ns"] = tiller_ns
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def chartRollback(revision, chart, tiller_ns):
|
def chartRollback(revision, chart, ns):
|
||||||
command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " rollback " + chart + " " + revision # helm2
|
command = "/usr/local/bin/helm -n " + ns + " rollback " + chart + " " + revision # 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")
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
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, get_tiller_namespaces, chartRollback
|
from main import get_namespaces, get_charts, get_chartdata, chartRollback
|
||||||
from . import routes
|
from . import routes
|
||||||
from tables import chartVersionTable
|
from tables import chartVersionTable
|
||||||
import json
|
import json
|
||||||
@ -14,23 +14,26 @@ def index():
|
|||||||
|
|
||||||
@routes.route('/chartSelect', methods=['POST'])
|
@routes.route('/chartSelect', methods=['POST'])
|
||||||
def chartVersions():
|
def chartVersions():
|
||||||
tiller_ns = request.form['tiller_ns']
|
|
||||||
chart = request.form['chart']
|
chart = request.form['chart']
|
||||||
records = request.form['records']
|
records = request.form['records']
|
||||||
namespace = 'default'
|
ns = request.form['ns']
|
||||||
chartVersions = get_chartdata(tiller_ns, namespace, chart, records)
|
chartVersions = get_chartdata(ns, chart, records)
|
||||||
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)
|
return render_template('chartRevisionList.html', table=table)
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
@routes.route('/nsLookup/<ns>/<namespace>')
|
@routes.route('/nsLookup/<ns>/<namespace>')
|
||||||
|
=======
|
||||||
|
@routes.route('/nsLookup/<ns>')
|
||||||
|
>>>>>>> a7df40eb7710553f5d0185c3fa04ea6991c06f89
|
||||||
def namespaceLookup(ns):
|
def namespaceLookup(ns):
|
||||||
charts = get_charts(ns)
|
charts = get_charts(ns)
|
||||||
return jsonify(charts)
|
return jsonify(charts)
|
||||||
|
|
||||||
@routes.route('/deployChartRevision/<revision>/<chart>/<tiller_ns>', methods=['POST'])
|
@routes.route('/deployChartRevision/<revision>/<chart>/<ns>', methods=['POST'])
|
||||||
def deployChartRevision(revision, chart, tiller_ns):
|
def deployChartRevision(revision, chart, tiller_ns):
|
||||||
rollback = chartRollback(revision, chart, tiller_ns)
|
rollback = chartRollback(revision, chart, ns)
|
||||||
return rollback
|
return rollback
|
||||||
@ -4,7 +4,7 @@ class chartVersionTable(Table):
|
|||||||
revision = Col('Chart Revision')
|
revision = Col('Chart Revision')
|
||||||
updated = Col('Updated')
|
updated = Col('Updated')
|
||||||
status = Col('Status')
|
status = Col('Status')
|
||||||
tiller_ns = Col('Tiiler Namespace')
|
ns = Col('Namespace')
|
||||||
chart = Col('Chart Version')
|
chart = Col('Chart Version')
|
||||||
description = Col('Description')
|
description = Col('Description')
|
||||||
deploy = ButtonCol('Deploy', 'routes.deployChartRevision', url_kwargs=dict(revision='revision', chart='chartName', tiller_ns='tiller_ns'), button_attrs={"type" : "submit", "class" : "btn btn-danger"})
|
deploy = ButtonCol('Deploy', 'routes.deployChartRevision', url_kwargs=dict(revision='revision', chart='chartName', ns='ns'), button_attrs={"type" : "submit", "class" : "btn btn-danger"})
|
||||||
@ -23,4 +23,6 @@
|
|||||||
{{ table }}
|
{{ table }}
|
||||||
</table>
|
</table>
|
||||||
<a class="btn btn-primary" href="/" role="button">Home</a>
|
<a class="btn btn-primary" href="/" role="button">Home</a>
|
||||||
</body>
|
<br>
|
||||||
|
<a class="btn btn-primary" href="/oauth2/sign_out" role="button">Log Off</a>
|
||||||
|
</body>
|
||||||
|
|||||||
@ -43,6 +43,8 @@
|
|||||||
{{ form.submitButton(class_="btn btn-success") }}
|
{{ form.submitButton(class_="btn btn-success") }}
|
||||||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
||||||
</p>
|
</p>
|
||||||
|
<br>
|
||||||
|
<a class="btn btn-primary" href="/oauth2/sign_out" role="button">Log Off</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -59,12 +61,12 @@
|
|||||||
|
|
||||||
ns = nsSelect.value;
|
ns = nsSelect.value;
|
||||||
|
|
||||||
fetch('/nsLookup/' + ns + '/default').then(function(response) {
|
fetch('/nsLookup/' + ns).then(function(response) {
|
||||||
response.json().then(function(data) {
|
response.json().then(function(data) {
|
||||||
if (data != 'EMPTY') {
|
if (data != 'EMPTY') {
|
||||||
var optionHTML = '';
|
var optionHTML = '';
|
||||||
for (var chart of data.Releases) {
|
for (var chart of data) {
|
||||||
optionHTML += '<option value="' + chart.Name + '">' + chart.Name + '</option>';
|
optionHTML += '<option value="' + chart.name + '">' + chart.name + '</option>';
|
||||||
}
|
}
|
||||||
chartSelect.innerHTML = optionHTML;
|
chartSelect.innerHTML = optionHTML;
|
||||||
}
|
}
|
||||||
@ -76,4 +78,4 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -32,7 +32,9 @@
|
|||||||
<p>
|
<p>
|
||||||
{{ form.submitButton(class_="btn btn-success") }}
|
{{ form.submitButton(class_="btn btn-success") }}
|
||||||
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
<a class="btn btn-danger" href="/" role="button">Cancel</a>
|
||||||
</p>
|
<br>
|
||||||
|
<a class="btn btn-primary" href="/oauth2/sign_out" role="button">Log Off</a>
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -62,4 +64,4 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user