Started to use python client

This commit is contained in:
Jonathan Ervine 2020-12-15 22:58:35 +08:00
parent 04b96d9442
commit 6770612d74
3 changed files with 8 additions and 16 deletions

View File

@ -8,7 +8,7 @@ from wtforms.validators import InputRequired, Email, Length
from flask_bootstrap import Bootstrap
class deploySelectForm(FlaskForm):
tiller_ns = SelectField('tiller_ns', choices=[], coerce=str)
ns = SelectField('ns', choices=[], coerce=str)
chart = SelectField('chart', choices=[])
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'])

16
main.py
View File

@ -19,19 +19,11 @@ app.register_blueprint(routes)
def get_namespaces():
config.load_incluster_config()
v1 = client.Corev1Api()
v1 = client.CoreV1Api()
ns = v1.list_namespace()
print(ns)
command = "/usr/local/bin/kubectl get ns -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
for namespace in ns.items:
print("%s" % (namespace.metadata.name))
return ns
def get_tiller_namespaces():
command = "/usr/local/bin/kubectl get deploy --all-namespaces -l name=tiller -ojson"

View File

@ -7,10 +7,10 @@ import json
@routes.route('/', methods=['GET', 'POST'])
def index():
tiller_ns = get_tiller_namespaces()
ns = get_namespaces()
form = deploySelectForm()
form.tiller_ns.choices = [(name['metadata']['namespace'], name['metadata']['namespace']) for name in tiller_ns['items']]
return render_template('nameChartSelect.html', tiller_ns=tiller_ns, form=form)
form.ns.choices = [(name['metadata']['name'], name['metadata']['name']) for name in ns['items']]
return render_template('nameChartSelect.html', ns=ns, form=form)
@routes.route('/chartSelect', methods=['POST'])
def chartVersions():