Update code
This commit is contained in:
parent
7e98a6023f
commit
6b8562662c
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Base on latest alpine image
|
||||||
|
FROM alpine
|
||||||
|
LABEL MAINTAINER="Jonathan Ervine <jonathan.ervine@gogox.com>"
|
||||||
|
|
||||||
|
# Install updates
|
||||||
|
ENV LANG='en_US.UTF-8' \
|
||||||
|
LANGUAGE='en_US.UTF-8' \
|
||||||
|
FLASK_APP=/data/app-dev/app.py \
|
||||||
|
VERSION=1.1.4
|
||||||
|
|
||||||
|
RUN apk update && \
|
||||||
|
apk -U upgrade --ignore alpine-baselayout && \
|
||||||
|
apk -U add python3 gcc py3-pip python3-dev musl-dev libffi-dev git curl && \
|
||||||
|
adduser -D python && \
|
||||||
|
mkdir /data && cd /data && git clone --single-branch --branch master https://github.com/jervine-gogo/python-helm-web /data && \
|
||||||
|
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 && \
|
||||||
|
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/*
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
#USER python
|
||||||
|
|
||||||
|
CMD [ "/usr/bin/python3", "/data/main.py" ]
|
||||||
221
LICENSE
221
LICENSE
@ -1,208 +1,21 @@
|
|||||||
Apache License
|
MIT License
|
||||||
|
|
||||||
Version 2.0, January 2004
|
Copyright (c) 2020 Jonathan Ervine
|
||||||
|
|
||||||
http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION,
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
AND DISTRIBUTION
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
1. Definitions.
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
"License" shall mean the terms and conditions for use, reproduction, and distribution
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
as defined by Sections 1 through 9 of this document.
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
||||||
owner that is granting the License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
||||||
that control, are controlled by, or are under common control with that entity.
|
|
||||||
For the purposes of this definition, "control" means (i) the power, direct
|
|
||||||
or indirect, to cause the direction or management of such entity, whether
|
|
||||||
by contract or otherwise, or (ii) ownership of fifty percent (50%) or more
|
|
||||||
of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions
|
|
||||||
granted by this License.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications, including
|
|
||||||
but not limited to software source code, documentation source, and configuration
|
|
||||||
files.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical transformation
|
|
||||||
or translation of a Source form, including but not limited to compiled object
|
|
||||||
code, generated documentation, and conversions to other media types.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
||||||
made available under the License, as indicated by a copyright notice that
|
|
||||||
is included in or attached to the work (an example is provided in the Appendix
|
|
||||||
below).
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object form,
|
|
||||||
that is based on (or derived from) the Work and for which the editorial revisions,
|
|
||||||
annotations, elaborations, or other modifications represent, as a whole, an
|
|
||||||
original work of authorship. For the purposes of this License, Derivative
|
|
||||||
Works shall not include works that remain separable from, or merely link (or
|
|
||||||
bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including the original version
|
|
||||||
of the Work and any modifications or additions to that Work or Derivative
|
|
||||||
Works thereof, that is intentionally submitted to Licensor for inclusion in
|
|
||||||
the Work by the copyright owner or by an individual or Legal Entity authorized
|
|
||||||
to submit on behalf of the copyright owner. For the purposes of this definition,
|
|
||||||
"submitted" means any form of electronic, verbal, or written communication
|
|
||||||
sent to the Licensor or its representatives, including but not limited to
|
|
||||||
communication on electronic mailing lists, source code control systems, and
|
|
||||||
issue tracking systems that are managed by, or on behalf of, the Licensor
|
|
||||||
for the purpose of discussing and improving the Work, but excluding communication
|
|
||||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
||||||
owner as "Not a Contribution."
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
||||||
of whom a Contribution has been received by Licensor and subsequently incorporated
|
|
||||||
within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
||||||
License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
||||||
no-charge, royalty-free, irrevocable copyright license to reproduce, prepare
|
|
||||||
Derivative Works of, publicly display, publicly perform, sublicense, and distribute
|
|
||||||
the Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
||||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
||||||
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
|
||||||
license to make, have made, use, offer to sell, sell, import, and otherwise
|
|
||||||
transfer the Work, where such license applies only to those patent claims
|
|
||||||
licensable by such Contributor that are necessarily infringed by their Contribution(s)
|
|
||||||
alone or by combination of their Contribution(s) with the Work to which such
|
|
||||||
Contribution(s) was submitted. If You institute patent litigation against
|
|
||||||
any entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
|
||||||
that the Work or a Contribution incorporated within the Work constitutes direct
|
|
||||||
or contributory patent infringement, then any patent licenses granted to You
|
|
||||||
under this License for that Work shall terminate as of the date such litigation
|
|
||||||
is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
||||||
Derivative Works thereof in any medium, with or without modifications, and
|
|
||||||
in Source or Object form, provided that You meet the following conditions:
|
|
||||||
|
|
||||||
(a) You must give any other recipients of the Work or Derivative Works a copy
|
|
||||||
of this License; and
|
|
||||||
|
|
||||||
(b) You must cause any modified files to carry prominent notices stating that
|
|
||||||
You changed the files; and
|
|
||||||
|
|
||||||
(c) You must retain, in the Source form of any Derivative Works that You distribute,
|
|
||||||
all copyright, patent, trademark, and attribution notices from the Source
|
|
||||||
form of the Work, excluding those notices that do not pertain to any part
|
|
||||||
of the Derivative Works; and
|
|
||||||
|
|
||||||
(d) If the Work includes a "NOTICE" text file as part of its distribution,
|
|
||||||
then any Derivative Works that You distribute must include a readable copy
|
|
||||||
of the attribution notices contained within such NOTICE file, excluding those
|
|
||||||
notices that do not pertain to any part of the Derivative Works, in at least
|
|
||||||
one of the following places: within a NOTICE text file distributed as part
|
|
||||||
of the Derivative Works; within the Source form or documentation, if provided
|
|
||||||
along with the Derivative Works; or, within a display generated by the Derivative
|
|
||||||
Works, if and wherever such third-party notices normally appear. The contents
|
|
||||||
of the NOTICE file are for informational purposes only and do not modify the
|
|
||||||
License. You may add Your own attribution notices within Derivative Works
|
|
||||||
that You distribute, alongside or as an addendum to the NOTICE text from the
|
|
||||||
Work, provided that such additional attribution notices cannot be construed
|
|
||||||
as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and may provide
|
|
||||||
additional or different license terms and conditions for use, reproduction,
|
|
||||||
or distribution of Your modifications, or for any such Derivative Works as
|
|
||||||
a whole, provided Your use, reproduction, and distribution of the Work otherwise
|
|
||||||
complies with the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
||||||
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
||||||
Licensor shall be under the terms and conditions of this License, without
|
|
||||||
any additional terms or conditions. Notwithstanding the above, nothing herein
|
|
||||||
shall supersede or modify the terms of any separate license agreement you
|
|
||||||
may have executed with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade names,
|
|
||||||
trademarks, service marks, or product names of the Licensor, except as required
|
|
||||||
for reasonable and customary use in describing the origin of the Work and
|
|
||||||
reproducing the content of the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to
|
|
||||||
in writing, Licensor provides the Work (and each Contributor provides its
|
|
||||||
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
KIND, either express or implied, including, without limitation, any warranties
|
|
||||||
or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness
|
|
||||||
of using or redistributing the Work and assume any risks associated with Your
|
|
||||||
exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory, whether
|
|
||||||
in tort (including negligence), contract, or otherwise, unless required by
|
|
||||||
applicable law (such as deliberate and grossly negligent acts) or agreed to
|
|
||||||
in writing, shall any Contributor be liable to You for damages, including
|
|
||||||
any direct, indirect, special, incidental, or consequential damages of any
|
|
||||||
character arising as a result of this License or out of the use or inability
|
|
||||||
to use the Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all other commercial
|
|
||||||
damages or losses), even if such Contributor has been advised of the possibility
|
|
||||||
of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing the Work
|
|
||||||
or Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
||||||
acceptance of support, warranty, indemnity, or other liability obligations
|
|
||||||
and/or rights consistent with this License. However, in accepting such obligations,
|
|
||||||
You may act only on Your own behalf and on Your sole responsibility, not on
|
|
||||||
behalf of any other Contributor, and only if You agree to indemnify, defend,
|
|
||||||
and hold each Contributor harmless for any liability incurred by, or claims
|
|
||||||
asserted against, such Contributor by reason of your accepting any such warranty
|
|
||||||
or additional liability. END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
APPENDIX: How to apply the Apache License to your work.
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following boilerplate
|
|
||||||
notice, with the fields enclosed by brackets "[]" replaced with your own identifying
|
|
||||||
information. (Don't include the brackets!) The text should be enclosed in
|
|
||||||
the appropriate comment syntax for the file format. We also recommend that
|
|
||||||
a file or class name and description of purpose be included on the same "printed
|
|
||||||
page" as the copyright notice for easier identification within third-party
|
|
||||||
archives.
|
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
|
|
||||||
limitations under the License.
|
|
||||||
|
|||||||
23
README.md
23
README.md
@ -1,3 +1,22 @@
|
|||||||
# flask-python-helm
|
# **Python Flask web application for helm releases**
|
||||||
|
|
||||||
Python flask web app to view/manage helm releases.
|
This flask based web application will allow a user to select an existing helm revision to rollback or forward to.
|
||||||
|
|
||||||
|
# Basic Requirements
|
||||||
|
The expectation is that the application will run in a pod on a kubernetes cluster. As such the pod will run with a service account that provides sufficient privileges to perform helm commands based upon the helm releases that it finds.
|
||||||
|
|
||||||
|
The initial (front) page should look similar to the image below. For helm version 2, the namespace selector does not require a value, as managing helm 2 revisions does not require a namespace to be provided.
|
||||||
|

|
||||||
|
|
||||||
|
The code itself downloads kubectl and helm (version 2.13.1) and will perform commands against these utilities. The tiller namespace dropdown is populated by the following command in the code:
|
||||||
|
```kubectl get deploy --all-namespaces -l name=tiller```
|
||||||
|
The Chart dropdown is then filled with the helm charts deployed by the tiller instance that is selected in the Tiller Namespace dropdown. *Some Javascript code is executed to detect that the elementID for the tiller namespace has changed, and the code then populates the Chart dropdown.*
|
||||||
|
|
||||||
|
Upon hitting submit the application will then execute a helm history against the selected Chart, and a table is constructed which should look similar to the below image
|
||||||
|

|
||||||
|
|
||||||
|
The Namespace has been added to the usual output that the 'helm history' command would return. A hidden field containing the Chart name is also included.
|
||||||
|
|
||||||
|
*At the moment, the namespace field is unnecessary, however when/if the application is deployed against a helm version 3 environment, the namespace will be important.*
|
||||||
|
|
||||||
|
Each deployment revision is displayed, with the most recent revision displayed at the bottom of the table. Hitting the 'Deploy' button will trigger helm to rollback (or forward) to the revision selected.
|
||||||
|
|||||||
5
forms.py
5
forms.py
@ -7,10 +7,9 @@ from wtforms import validators, ValidationError
|
|||||||
from wtforms.validators import InputRequired, Email, Length
|
from wtforms.validators import InputRequired, Email, Length
|
||||||
from flask_bootstrap import Bootstrap
|
from flask_bootstrap import Bootstrap
|
||||||
|
|
||||||
|
|
||||||
class deploySelectForm(FlaskForm):
|
class deploySelectForm(FlaskForm):
|
||||||
tiller_ns = SelectField('tiller_ns', choices=[], coerce=str)
|
tiller_ns = SelectField('tiller_ns', 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') # Added if/when I want to add additional helm version options
|
||||||
|
records = SelectField('records', choices=[('10', '10'), ('20', '20'), ('30', '30'), ('40', '40'), ('50', '50'), ('100', '100'), ('150', '150'), ('200', '200'), ('256', '256 (max)')], default=['10'])
|
||||||
submitButton = SubmitField("Submit")
|
submitButton = SubmitField("Submit")
|
||||||
30
main.py
30
main.py
@ -29,7 +29,7 @@ def get_namespaces():
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def get_tiller_namespaces():
|
def get_tiller_namespaces():
|
||||||
command = "/usr/local/bin/kubectl get po --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}")
|
||||||
try:
|
try:
|
||||||
output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
|
output = check_output(command.split(" "), stderr=STDOUT).decode("utf-8")
|
||||||
@ -53,7 +53,7 @@ def get_deployments(namespace):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
def get_charts(tiller_ns, namespace):
|
def get_charts(tiller_ns, namespace):
|
||||||
command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " list -ojson" #helm2
|
command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " list --output json" #helm2
|
||||||
#command = "/usr/local/bin/helm -n " + namespace + " list -ojson" #helm3
|
#command = "/usr/local/bin/helm -n " + namespace + " list -ojson" #helm3
|
||||||
info(f"Running command: {command}")
|
info(f"Running command: {command}")
|
||||||
try:
|
try:
|
||||||
@ -62,14 +62,19 @@ def get_charts(tiller_ns, namespace):
|
|||||||
error(err.output.decode("utf-8"))
|
error(err.output.decode("utf-8"))
|
||||||
raise err
|
raise err
|
||||||
info(f"Output from command:\n{output}")
|
info(f"Output from command:\n{output}")
|
||||||
|
if output:
|
||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
|
else:
|
||||||
|
data = 'EMPTY'
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_chartdata(tiller_ns, namespace, chart):
|
def sortRevision(n):
|
||||||
command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " history " + chart + " -ojson" #helm2
|
return n['revision']
|
||||||
|
|
||||||
|
def get_chartdata(tiller_ns, namespace, chart, records):
|
||||||
|
command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " history " + chart + " --max " + records + " --output json" #helm2
|
||||||
#command = "/usr/local/bin/helm -n " + namespace + " history " + chart + " -ojson" #helm3
|
#command = "/usr/local/bin/helm -n " + namespace + " history " + chart + " -ojson" #helm3
|
||||||
info(f"Running command: {command}")
|
info(f"Running command: {command}")
|
||||||
print(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")
|
||||||
except CalledProcessError as err:
|
except CalledProcessError as err:
|
||||||
@ -77,10 +82,23 @@ def get_chartdata(tiller_ns, namespace, chart):
|
|||||||
raise err
|
raise err
|
||||||
info(f"Output from command:\n{output}")
|
info(f"Output from command:\n{output}")
|
||||||
data = json.loads(output)
|
data = json.loads(output)
|
||||||
|
data.sort(reverse=True, key=sortRevision)
|
||||||
for revision in data:
|
for revision in data:
|
||||||
|
revision['chartName'] = chart
|
||||||
revision["namespace"] = namespace
|
revision["namespace"] = namespace
|
||||||
print(data[0])
|
revision["tiller_ns"] = tiller_ns
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def chartRollback(revision, chart, tiller_ns):
|
||||||
|
command = "/usr/local/bin/helm --tiller-namespace " + tiller_ns + " rollback " + chart + " " + revision # helm2
|
||||||
|
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}")
|
||||||
|
return output
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host='0.0.0.0', port=3000, debug=True)
|
app.run(host='0.0.0.0', port=3000, debug=True)
|
||||||
@ -1,11 +1,6 @@
|
|||||||
Flask
|
Flask
|
||||||
Werkzeug
|
Werkzeug
|
||||||
email-validator
|
|
||||||
flask_table
|
flask_table
|
||||||
flask-mysql
|
|
||||||
flask_login
|
|
||||||
Flask-BasicAuth
|
|
||||||
Flask-Bootstrap
|
Flask-Bootstrap
|
||||||
flask_wtf
|
flask_wtf
|
||||||
wtforms_components
|
wtforms_components
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@ -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
|
from main import get_namespaces, get_charts, get_chartdata, get_tiller_namespaces, chartRollback
|
||||||
from . import routes
|
from . import routes
|
||||||
from tables import chartVersionTable
|
from tables import chartVersionTable
|
||||||
import json
|
import json
|
||||||
@ -8,33 +8,29 @@ import json
|
|||||||
@routes.route('/', methods=['GET', 'POST'])
|
@routes.route('/', methods=['GET', 'POST'])
|
||||||
def index():
|
def index():
|
||||||
tiller_ns = get_tiller_namespaces()
|
tiller_ns = get_tiller_namespaces()
|
||||||
namespaces = get_namespaces()
|
|
||||||
form = deploySelectForm()
|
form = deploySelectForm()
|
||||||
form.tiller_ns.choices = [(name['metadata']['namespace'], name['metadata']['namespace']) for name in tiller_ns['items']]
|
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']]
|
return render_template('nameChartSelect.html', tiller_ns=tiller_ns, 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']
|
|
||||||
tiller_ns = request.form['tiller_ns']
|
tiller_ns = request.form['tiller_ns']
|
||||||
chart = request.form['chart']
|
chart = request.form['chart']
|
||||||
chartVersions = get_chartdata(tiller_ns, namespace, chart)
|
records = request.form['records']
|
||||||
|
namespace = 'default'
|
||||||
|
chartVersions = get_chartdata(tiller_ns, namespace, 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, namespace=namespace)
|
return render_template('chartRevisionList.html', table=table)
|
||||||
|
|
||||||
|
|
||||||
@routes.route('/nsLookup/<tiller>/<namespace>')
|
@routes.route('/nsLookup/<tiller_ns>/<namespace>')
|
||||||
def namespaceLookup(tiller, namespace):
|
def namespaceLookup(tiller_ns, namespace):
|
||||||
charts = get_charts(tiller, namespace)
|
charts = get_charts(tiller_ns, namespace)
|
||||||
return jsonify(charts)
|
return jsonify(charts)
|
||||||
|
|
||||||
@routes.route('/deployChartRevision/<revision>/<chart>/<namespace>', methods=['POST'])
|
@routes.route('/deployChartRevision/<revision>/<chart>/<tiller_ns>', methods=['POST'])
|
||||||
def deployChartRevision(revision, chart, namespace):
|
def deployChartRevision(revision, chart, tiller_ns):
|
||||||
print(revision)
|
rollback = chartRollback(revision, chart, tiller_ns)
|
||||||
print(chart)
|
return rollback
|
||||||
print(namespace)
|
|
||||||
charts = get_charts(namespace)
|
|
||||||
return jsonify(charts)
|
|
||||||
@ -4,8 +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')
|
||||||
namespace = Col('Namespace')
|
tiller_ns = Col('Tiiler Namespace')
|
||||||
chart = Col('Chart Version')
|
chart = Col('Chart Version')
|
||||||
app_version = Col('Application Version')
|
|
||||||
description = Col('Description')
|
description = Col('Description')
|
||||||
deploy = ButtonCol('Deploy', 'routes.deployChartRevision', url_kwargs=dict(revision='revision', chart='chart', namespace='namespace'), button_attrs={"type" : "submit", "class" : "btn btn-danger"})
|
deploy = ButtonCol('Deploy', 'routes.deployChartRevision', url_kwargs=dict(revision='revision', chart='chartName', tiller_ns='tiller_ns'), button_attrs={"type" : "submit", "class" : "btn btn-danger"})
|
||||||
@ -20,7 +20,6 @@
|
|||||||
{% endwith %}
|
{% endwith %}
|
||||||
</p>
|
</p>
|
||||||
<table class="table table-bordered">
|
<table class="table table-bordered">
|
||||||
<input id="namespace" name="namespace" type="hidden" value="{{ namespace }}">
|
|
||||||
{{ table }}
|
{{ table }}
|
||||||
</table>
|
</table>
|
||||||
<a class="btn btn-primary" href="/" role="button">Home</a>
|
<a class="btn btn-primary" href="/" role="button">Home</a>
|
||||||
|
|||||||
@ -22,12 +22,6 @@
|
|||||||
{{ form.tiller_ns(class_="form-control") }}
|
{{ form.tiller_ns(class_="form-control") }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class = "col-sm-6">
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-addon" id="basic-addon2">Namespace:</span>
|
|
||||||
{{ form.namespace(class_="form-control") }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class = "row">
|
<div class = "row">
|
||||||
<div class = "col-sm-12">
|
<div class = "col-sm-12">
|
||||||
@ -37,6 +31,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class = "row">
|
||||||
|
<div class = "col-sm-6">
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-addon" id="basic-addon3">Maximum Revisions to display:</span>
|
||||||
|
{{ form.records(class_="form-control") }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<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>
|
||||||
@ -49,26 +51,27 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
var tillerSelect = document.getElementById("tiller_ns");
|
var tillerSelect = document.getElementById("tiller_ns");
|
||||||
var namespaceSelect = document.getElementById("namespace");
|
|
||||||
var chartSelect = document.getElementById("chart");
|
var chartSelect = document.getElementById("chart");
|
||||||
|
|
||||||
tillerSelect.onchange = function() {myFunction()};
|
tillerSelect.onchange = function() {myFunction()};
|
||||||
namespaceSelect.onchange = function() {myFunction()};
|
|
||||||
|
|
||||||
function myFunction() {
|
function myFunction() {
|
||||||
|
|
||||||
tiller_ns = tillerSelect.value;
|
tiller_ns = tillerSelect.value;
|
||||||
namespace = namespaceSelect.value;
|
|
||||||
|
|
||||||
fetch('/nsLookup/' + tiller_ns + '/' + namespace).then(function(response) {
|
fetch('/nsLookup/' + tiller_ns + '/default').then(function(response) {
|
||||||
response.json().then(function(data) {
|
response.json().then(function(data) {
|
||||||
|
if (data != 'EMPTY') {
|
||||||
var optionHTML = '';
|
var optionHTML = '';
|
||||||
for (var chart of data) {
|
for (var chart of data.Releases) {
|
||||||
optionHTML += '<option value="' + chart.name + '">' + chart.name + '</option>';
|
optionHTML += '<option value="' + chart.Name + '">' + chart.Name + '</option>';
|
||||||
}
|
}
|
||||||
chartSelect.innerHTML = optionHTML;
|
chartSelect.innerHTML = optionHTML;
|
||||||
})
|
}
|
||||||
|
else {
|
||||||
|
chartSelect.innerHTML = "";
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user