Kubectl tab

This commit is contained in:
Vincent Fiduccia 2016-02-24 00:31:11 -07:00
parent 67ddccaabc
commit 81a99dea66
13 changed files with 91 additions and 8 deletions

View File

@ -1,5 +1,5 @@
{{#if model.length}}
<table class="table fixed no-lines r-mb0">
<table class="grid fixed no-lines r-mb0">
<thead>
<tr>
<th>Container Name</th>

View File

@ -20,7 +20,7 @@
</td>
</tr>
{{#if expanded}}
<tr>
<tr class="nohover">
<td colspan="6" class="subtable">
{{k8s/container-section model=model.displayContainers}}
</td>

View File

@ -1,8 +1,13 @@
import Ember from 'ember';
const DEFAULT_COMMAND = ["/bin/sh","-c",'TERM=xterm-256color; export TERM; [ -x /bin/bash ] && ([ -x /usr/bin/script ] && /usr/bin/script -q -c "/bin/bash" /dev/null || exec /bin/bash) || exec /bin/sh'];
export default Ember.Component.extend({
originalModel: null,
instance: Ember.computed.alias('originalModel'),
command: null, // defaults to DEFAULT_COMMAND
showHeader: true,
showClose: true,
status: 'Connecting...',
socket: null,
@ -28,7 +33,7 @@ export default Ember.Component.extend({
attachStdin: true,
attachStdout: true,
tty: true,
command: ["/bin/sh","-c",'TERM=xterm-256color; export TERM; [ -x /bin/bash ] && ([ -x /usr/bin/script ] && /usr/bin/script -q -c "/bin/bash" /dev/null || exec /bin/bash) || exec /bin/sh'],
command: this.get('command') || DEFAULT_COMMAND,
};
instance.doAction('execute',opt).then((exec) => {

View File

@ -1,7 +1,13 @@
{{#if showHeader}}
<h2><i class="icon icon-terminal"></i> Shell: {{instance.displayName}}</h2>
{{else}}
{{yield}}
{{/if}}
<div class="shell-body clearfix">
</div>
<div class="footer-actions">
<div class="console-status text-muted">{{status}}</div>
<button {{action "cancel"}} class="btn btn-primary">Close</button>
{{#if showClose}}
<button {{action "cancel"}} class="btn btn-primary">Close</button>
{{/if}}
</div>

View File

@ -26,6 +26,11 @@ export default Ember.Component.extend({
},
show(node) {
if ( this._state === 'destroying' )
{
return;
}
var svc = this.get('tooltipService');
this.set('showTimer', null);

View File

@ -0,0 +1,38 @@
import Ember from 'ember';
import C from 'ui/utils/constants';
export default Ember.Route.extend({
k8s: Ember.inject.service(),
model() {
return this.get('store').findAll('container').then((containers) => {
let inst = null;
for ( let i = 0 ; i < containers.get('length') ; i++)
{
let container = containers.objectAt(i);
if ( container.get('state') !== 'running' )
{
continue;
}
var labels = container.get('labels')||{};
if ( labels[C.LABEL.K8S_KUBECTL]+'' === 'true' )
{
inst = container;
break;
}
}
if ( inst )
{
return Ember.Object.create({
instance: inst,
});
}
else
{
return Ember.RSVP.reject('Unable to find an active kubectld container');
}
});
},
});

View File

@ -0,0 +1,11 @@
<section class="header">
<h1 style="display: block">kubectl</h1>
<p class="help-block">Use this shell to directly execute <code>kubectl</code> commands.</p>
</section>
<div class="r-m20">
{{modal-shell
originalModel=model.instance
showHeader=false
showClose=false
}}
</div>

View File

@ -14,11 +14,11 @@
</section>
<section>
<ul class="nav nav-tabs nav-tabs-well shadowed">
<ul class="nav nav-tabs nav-tabs-well">
<li role="presentation" class="tab" data-section="containers" {{action "selectTab" "containers" target="view"}}><a href="#">Containers</a></li>
</ul>
<div class="horizontal-form well">
<div class="horizontal-form well nav-well">
<div class="section container-fluid" data-section="containers">
{{k8s/container-section model=model.displayContainers}}
</div>

View File

@ -0,0 +1,8 @@
import Ember from 'ember';
import SelectTab from 'ui/mixins/select-tab';
export default Ember.View.extend(SelectTab, {
didInsertElement() {
this.send('selectTab', 'containers');
},
});

View File

@ -0,0 +1,8 @@
import Ember from 'ember';
import SelectTab from 'ui/mixins/select-tab';
export default Ember.View.extend(SelectTab, {
didInsertElement() {
this.send('selectTab', 'pods');
},
});

View File

@ -33,13 +33,13 @@
</section>
<section>
<ul class="nav nav-tabs nav-tabs-well shadowed">
<ul class="nav nav-tabs nav-tabs-well">
<li role="presentation" class="tab" data-section="pods" {{action "selectTab" "pods" target="view"}}><a href="#">Pods</a></li>
<li role="presentation" class="tab" data-section="labels" {{action "selectTab" "labels" target="view"}}><a href="#">Labels</a></li>
<li role="presentation" class="tab" data-section="ports" {{action "selectTab" "ports" target="view"}}><a href="#">Ports</a></li>
</ul>
<div class="horizontal-form well">
<div class="horizontal-form well nav-well">
<div class="section container-fluid" data-section="pods">
{{k8s/pod-section model=model.selectedPods}}
</div>

View File

@ -145,6 +145,7 @@ Router.map(function() {
this.route('index', {path: '/'});
this.route('apply', {path: '/apply'});
this.route('kubectl', {path: '/kubectl'});
this.route('namespaces', {path: '/namespaces'}, function() {
this.route('index', {path: '/'});

View File

@ -1,3 +1,4 @@
{{#link-to "k8s-tab.namespace.services" namespace.id}}<i class="icon icon-compass"></i>Services{{/link-to}}
{{#link-to "k8s-tab.namespace.rcs" namespace.id}}<i class="icon icon-tachometer"></i>RCs{{/link-to}}
{{#link-to "k8s-tab.namespace.pods" namespace.id}}<i class="icon icon-containers"></i>Pods{{/link-to}}
{{#link-to "k8s-tab.kubectl"}}<i class="icon icon-terminal"></i>kubectl{{/link-to}}