Skip to content

Commit

Permalink
existing cluster now tested
Browse files Browse the repository at this point in the history
  • Loading branch information
3191110276 committed Jan 17, 2020
1 parent caf633a commit f5c907d
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 53 deletions.
71 changes: 34 additions & 37 deletions mla_app_code/mla_core_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def index():
##################################
@app.route("/clusterOverview", methods = ['GET'])
def clusterOverview():
session['sessionUUID'] = uuid.UUID(bytes=secrets.token_bytes(16))

kubeConfigDir = os.path.expanduser(config.KUBE_CONFIG_DIR)

files = [f for f in os.listdir(kubeConfigDir) if os.path.isfile(os.path.join(kubeConfigDir, f))]
Expand Down Expand Up @@ -487,34 +489,32 @@ def run_postInstallTasks():

@app.route("/mladeploymentstatus", methods = ['GET'])
def mladeploymentstatus():
if "mla_endpoint" not in session:
cluster = request.args.get('cluster')

if cluster == '' or cluster == None:
cluster = 'k8s_' + str(session["sessionUUID"])

kubeConfigDir = os.path.expanduser(config.KUBE_CONFIG_DIR)
kubeSessionEnv = {**os.environ, 'KUBECONFIG': "{}/{}".format(kubeConfigDir,session["sessionUUID"])}
kubeConfig.load_kube_config(config_file="{}/{}".format(kubeConfigDir,cluster))
cluster = request.args.get('cluster')

api_instance = kubernetes.client.CoreV1Api()

nodes = api_instance.list_node(watch=False)
for node in nodes.items:
for address in node.status.addresses:
if address.type == 'ExternalIP':
node_ip = address.address

services = api_instance.list_namespaced_service('default')
for service in services.items:
if service.metadata.name == 'mla-svc':
node_port = service.spec.ports[0].node_port

session["mla_endpoint"] = str(node_ip) + ':' + str(node_port)
if cluster == '' or cluster == None:
cluster = 'k8s_' + str(session["sessionUUID"])

kubeConfigDir = os.path.expanduser(config.KUBE_CONFIG_DIR)
kubeSessionEnv = {**os.environ, 'KUBECONFIG': "{}/{}".format(kubeConfigDir,session["sessionUUID"])}
kubeConfig.load_kube_config(config_file="{}/{}".format(kubeConfigDir,cluster))

api_instance = kubernetes.client.CoreV1Api()

nodes = api_instance.list_node(watch=False)
for node in nodes.items:
for address in node.status.addresses:
if address.type == 'ExternalIP':
node_ip = address.address

services = api_instance.list_namespaced_service('default')
for service in services.items:
if service.metadata.name == 'mla-svc':
node_port = service.spec.ports[0].node_port

session["mla_endpoint"] = str(node_ip) + ':' + str(node_port)

try:
status = requests.get("http://{}/status".format(session["mla_endpoint"]))
logging.warn(status.status_code)
except:
return 'Pod not reachable yet', 200

Expand All @@ -528,17 +528,17 @@ def mladeploymentstatus():
def run_vsphereProviders():

if request.method == 'GET':

if "ccpToken" in session and "x-auth-token" in session:

ccp = CCP(session['ccpURL'],"","",session['ccpToken'],session['x-auth-token'])
response = ccp.getProviderClientConfigs()

if response:
socketio.emit('consoleLog', {'loggingType': 'INFO','loggingMessage': config.INFO_VSPHERE_PROVIDERS })
return jsonify(response)
else:
return [config.ERROR_VSPHERE_PROVIDERS]
return config.ERROR_VSPHERE_PROVIDERS, 400

@app.route("/vsphereDatacenters", methods = ['POST', 'GET'])
def run_vsphereDatacenters():
Expand Down Expand Up @@ -835,17 +835,14 @@ def getIngressDetails():
return jsonify({"ACCESSTYPE": "NodePort", "IP":"{}:{}".format(workerAddress,workerPort)})


@app.route('/downloadKubeconfig/<filename>', defaults={'filename': 'kubeconfig.yaml'}, methods=['GET', 'POST'])
@app.route('/downloadKubeconfig/<filename>', defaults={'filename': None}, methods=['GET'])
def downloadKubeconfig(filename):

if request.method == 'GET':

if "ccpToken" in session and "x-auth-token" in session:
socketio.emit('consoleLog', {'loggingType': 'INFO','loggingMessage': config.INFO_DOWNLOAD_KUBECONFIG })
kubeConfigDir = os.path.expanduser(config.KUBE_CONFIG_DIR)
return send_file("{}/{}".format(kubeConfigDir,'k8s_' + str(session["sessionUUID"])))
else:
return render_template('clusterOverview.html')
if "customCluster" in session or ("ccpToken" in session and "x-auth-token" in session):
socketio.emit('consoleLog', {'loggingType': 'INFO','loggingMessage': config.INFO_DOWNLOAD_KUBECONFIG })
kubeConfigDir = os.path.expanduser(config.KUBE_CONFIG_DIR)
return send_file("{}/{}".format(kubeConfigDir,'k8s_' + str(session["sessionUUID"])))
else:
return "Not found", 400


def allowed_file(filename):
Expand Down
27 changes: 17 additions & 10 deletions mla_app_code/static/js/postInstallation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
post_install_stage = 1
var kflink = ""

$(document).ready(function(){

Expand All @@ -12,8 +12,9 @@ $(document).ready(function(){
})

$('#gotokf').on('click', function(event) {
event.preventDefault();
viewPods();
event.preventDefault();
link = 'http://' + kflink
window.open(link, '_blank')
})

setUpPage()
Expand All @@ -29,7 +30,7 @@ row_template =
<div class="col-md-7" style="margin: 0 auto;">
<div>
<div class="alert alert--info">
<div class="alert__icon"></div>
<div class="alert__icon icon-no-outline"></div>
<div class="alert__message">{replace-text}</div>
</div>
</div>
Expand Down Expand Up @@ -88,7 +89,6 @@ function verifyPostInstall() {
if(response != 'Pod not reachable yet') {
var logs = JSON.parse(response)

steps = []
for(var i=0;i<logs.length;i++) {
if(/-------------- [A-Z a-z ]* --------------/.test(logs[i])) {
steps.push({
Expand All @@ -100,16 +100,23 @@ function verifyPostInstall() {
}
}
}

for(var i=0;i<steps.length;i++){
if(i == steps.length-1) {
console.log('LAST ELEMENT!')
if(steps[i]['name'].startsWith('Done')) {
kflink = steps[i]['entries'][0].replace(/(\r\n|\n|\r)/gm, "");
$("#gotokf").prop("disabled", false);
} else {
$('#installprogress').children()[i].children[0].children[0].children[0].classList.replace("alert--info", "alert--warning");
$('#installprogress').children()[i].children[0].children[0].children[0].children[0].classList.replace("icon-no-outline", "icon-error-outline");
}
} else {
console.log('FINISHED ELEMENT!')
$('#installprogress').children()[i].children[0].children[0].children[0].classList.replace("alert--info", "alert--success");
$('#installprogress').children()[i].children[0].children[0].children[0].classList.replace("alert--warning", "alert--success");
$('#installprogress').children()[i].children[0].children[0].children[0].children[0].classList.replace("icon-no-outline", "icon-check-outline");
$('#installprogress').children()[i].children[0].children[0].children[0].children[0].classList.replace("icon-error-outline", "icon-check-outline");
}
console.log($('#installprogress').children()[i].children[0].children[0].children[0])
}

console.log(steps[steps.length-1])
},
error: function(error) {
$("#alertBox").html(
Expand Down
2 changes: 1 addition & 1 deletion mla_app_code/templates/ccpClusterCreation.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1 class="page-title">ML Anywhere Deployment</h1>
<div class="ui-steps">
<div class="ui-step active">
<div class="step__icon ">1</div>
<div class="step__label">Select Cluster</div>
<div class="step__label">Select Kubernetes Cluster</div>
</div>
<div class="ui-step">
<div class="step__icon">2</div>
Expand Down
2 changes: 1 addition & 1 deletion mla_app_code/templates/ccpLogin.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ <h1 class="page-title">ML Anywhere Deployment</h1>
<div class="ui-steps">
<div class="ui-step active">
<div class="step__icon ">1</div>
<div class="step__label">Select Cluster</div>
<div class="step__label">Select Kubernetes Cluster</div>
</div>
<div class="ui-step">
<div class="step__icon">2</div>
Expand Down
2 changes: 1 addition & 1 deletion mla_app_code/templates/clusterOverview.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h1 class="page-title">ML Anywhere Deployment</h1>
<div class="ui-steps">
<div class="ui-step active">
<div class="step__icon ">1</div>
<div class="step__label">Select Cluster</div>
<div class="step__label">Select Kubernetes Cluster</div>
</div>
<div class="ui-step">
<div class="step__icon">2</div>
Expand Down
2 changes: 1 addition & 1 deletion mla_app_code/templates/deployKubeflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h1 class="page-title">ML Anywhere Deployment</h1>
<div class="ui-steps">
<div class="ui-step">
<div class="step__icon ">1</div>
<div class="step__label">Select Cluster</div>
<div class="step__label">Select Kubernetes Cluster</div>
</div>
<div class="ui-step active">
<div class="step__icon">2</div>
Expand Down
2 changes: 1 addition & 1 deletion mla_app_code/templates/existingClusterUpload.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h1 class="page-title">ML Anywhere Deployment</h1>
<div class="ui-steps">
<div class="ui-step active">
<div class="step__icon ">1</div>
<div class="step__label">Select Cluster</div>
<div class="step__label">Select Kubernetes Cluster</div>
</div>
<div class="ui-step">
<div class="step__icon">2</div>
Expand Down
2 changes: 1 addition & 1 deletion mla_app_code/templates/postInstallTasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h1 class="page-title">ML Anywhere Deployment</h1>
<div class="ui-steps">
<div class="ui-step">
<div class="step__icon ">1</div>
<div class="step__label">Select Cluster</div>
<div class="step__label">Select Kubernetes Cluster</div>
</div>
<div class="ui-step">
<div class="step__icon">2</div>
Expand Down

0 comments on commit f5c907d

Please sign in to comment.