Skip to content

Commit

Permalink
Merge pull request spinnaker#2076 from lwander/kubernetes-probes
Browse files Browse the repository at this point in the history
provider/kubernetes: Probe dialogs & info being surfaced
  • Loading branch information
lwander committed Mar 11, 2016
2 parents ca765dd + 2242fec commit 59bdf98
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 41 deletions.
8 changes: 8 additions & 0 deletions app/scripts/modules/core/help/helpContents.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@
<help-field key="kubernetes.containers.ports.protocol"></help-field>
</div>
<div class="col-md-2">
<select class="form-control input-sm"
ng-model="port.protocol">
<option ng-repeat="protocol in containerController.protocols"
value="{{protocol}}"
<select class="form-control input-sm" ng-model="port.protocol">
<option ng-repeat="protocol in containerController.protocols" value="{{protocol}}"
ng-selected="port.protocol === protocol">{{protocol}}</option>
</select>
</div>
Expand All @@ -137,4 +135,9 @@
class="glyphicon glyphicon-plus-sign"></span> Add New Port
</button>
</collapsible-section>
<collapsible-section heading="Probes" expanded="false">
<kubernetes-container-probe container="container" command="command" probetype="'readinessProbe'" heading="'Readiness'"></kubernetes-container-probe>
<hr>
<kubernetes-container-probe container="container" command="command" probetype="'livenessProbe'" heading="'Liveness'"></kubernetes-container-probe>
</collabsible-section>
</div>
135 changes: 135 additions & 0 deletions app/scripts/modules/kubernetes/container/probe.directive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<form ng-controller="kubernetesContainerProbeController as probeController" class="container-fluid form-horizontal" name="containers" novalidate>
<div class="form-group">
<button class="add-new col-md-12" ng-click="probeController.addProbe()" ng-hide="probeController.probe"><span class="glyphicon glyphicon-plus-sign"></span> Enable {{probeController.heading}} Probe</button>
</div>

<div ng-hide="!probeController.probe">
<div class="form-group">
<div class="col-md-3 sm-label-right">
{{probeController.heading}} Probe
<help-field key="kubernetes.containers.probes.type"></help-field>
</div>
<div class="col-md-4">
<select class="form-control input-sm" ng-model="probeController.probe.handler.type">
<option ng-repeat="type in probeController.handlers" value="{{type}}"
ng-selected="probeController.probe.type === type">{{type}}</option>
</select>
</div>
<div class="col-md-1">
<a class="btn sm-label" ng-click="probeController.deleteProbe()">
<span class="glyphicon glyphicon-trash"></span> Delete Probe</a>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-md-3 sm-label-right">
Initial Delay
<help-field key="kubernetes.containers.probes.initialDelay"></help-field>
</div>
<div class="col-md-2">
<input type="number" class="form-control input-sm" name="details" ng-model="probeController.probe.initialDelaySeconds"
min="0"/>
</div>
<div class="col-md-4 sm-label-right">
Success Threshold
<help-field key="kubernetes.containers.probes.successThreshold"></help-field>
</div>
<div class="col-md-2">
<input type="number" class="form-control input-sm" name="details" ng-model="probeController.probe.successThreshold" ng-disabled="probeController.probetype === 'livenessProbe'"
min="1"/>
</div>
</div>
<div class="form-group">
<div class="col-md-3 sm-label-right">
Period
<help-field key="kubernetes.containers.probes.period"></help-field>
</div>
<div class="col-md-2">
<input type="number" class="form-control input-sm" name="details" ng-model="probeController.probe.periodSeconds"
min="1"/>
</div>
<div class="col-md-4 sm-label-right">
Failure Threshold
<help-field key="kubernetes.containers.probes.failureThreshold"></help-field>
</div>
<div class="col-md-2">
<input type="number" class="form-control input-sm" name="details" ng-model="probeController.probe.failureThreshold"
min="1"/>
</div>
</div>
<div class="form-group">
<div class="col-md-3 sm-label-right">
Timeout
<help-field key="kubernetes.containers.probes.timeout"></help-field>
</div>
<div class="col-md-2">
<input type="number" class="form-control input-sm" name="details" ng-model="probeController.probe.timeoutSeconds"
min="1"/>
</div>
</div>
<div ng-hide="probeController.probe.handler.type !== 'EXEC'">
<div class="form-group">
<div class="col-md-12">
<table class="table table-condensed packed tags">
<b>Commands</b>
<tr ng-repeat="command in probeController.probe.handler.execAction.commands track by $index">
<td><input class="form-control input-sm" type="text"
ng-model="probeController.probe.handler.execAction.commands[$index]"></td>
<td><a class="btn btn-link sm-label"
ng-click="probeController.removeCommand($index)"><span
class="glyphicon glyphicon-trash"></span></a></td>
</tr>
<tfoot>
<tr>
<td colspan="1">
<button class="add-new col-md-12" ng-click="probeController.addCommand()"><span
class="glyphicon glyphicon-plus-sign"></span> Add Command
</button>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div ng-hide="probeController.probe.handler.type !== 'TCP'">
<div class="form-group">
<div class="col-md-3 sm-label-right">
Port
</div>
<div class="col-md-2">
<input type="number" class="form-control input-sm" name="details" ng-model="probeController.probe.handler.tcpSocketAction.port"
min="1" max="probeController.maxPort"/>
</div>
</div>
</div>
<div ng-hide="probeController.probe.handler.type !== 'HTTP'">
<div class="form-group">
<div class="col-md-3 sm-label-right">
Port
</div>
<div class="col-md-2">
<input type="number" class="form-control input-sm" name="details" ng-model="probeController.probe.handler.httpGetAction.port"
min="1" max="probeController.maxPort"/>
</div>
<div class="col-md-2 sm-label-right">
Path
</div>
<div class="col-md-4">
<input type="text" class="form-control input-sm" name="details" ng-model="probeController.probe.handler.httpGetAction.path"/>
</div>
</div>
<div class="form-group">
<div class="col-md-3 sm-label-right">
URI Scheme
</div>
<div class="col-md-2">
<select class="form-control input-sm" ng-model="probeController.probe.handler.httpGetAction.uriScheme">
<option ng-repeat="scheme in probeController.uriSchemes" value="{{scheme}}"
ng-selected="probeController.probe.handler.httpGetAction.uriScheme === scheme">{{scheme}}</option>
</select>
</div>
</div>
</div>
</div>
</form>
94 changes: 94 additions & 0 deletions app/scripts/modules/kubernetes/container/probe.directive.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
'use strict';

let angular = require('angular');

module.exports = angular.module('spinnaker.kubernetes.container.probe.directive', [])
.directive('kubernetesContainerProbe', function () {
return {
restrict: 'E',
templateUrl: require('./probe.directive.html'),
scope: {
container: '=',
command: '=',
probetype: '=',
heading: '=',
}
};
})
.controller('kubernetesContainerProbeController', function($scope) {
this.uriSchemes = ['HTTP', 'HTTPS'];
this.maxPort = 65535;
this.handlers = ['EXEC', 'HTTP', 'TCP'];

this.heading = $scope.heading;
this.probe = $scope.container[$scope.probetype];
this.probetype = $scope.probetype;

function defaultExecAction() {
return { commands: [], };
}

function defaultHttpGetAction() {
return {
path: '/',
port: 80,
uriScheme: 'HTTP',
};
}

function defaultTcpSocketAction() {
return { port: 80, };
}

this.defaultProbe = function() {
return {
initialDelaySeconds: 0,
timeoutSeconds: 1,
periodSeconds: 10,
successThreshold: 1,
failureThreshold: 3,
handler: {
type: this.handlers[1],
execAction: defaultExecAction(),
httpGetAction: defaultHttpGetAction(),
tcpSocketAction: defaultTcpSocketAction(),
},
};
};

this.addProbe = function() {
$scope.container[$scope.probetype] = this.defaultProbe();
this.probe = $scope.container[$scope.probetype];
};

this.deleteProbe = function() {
delete $scope.container[$scope.probetype];
this.probe = null;
};

this.removeCommand = function(index) {
this.probe.handler.execAction.commands.splice(index, 1);
};

this.addCommand = function() {
this.probe.handler.execAction.commands.push('');
};

this.prepareProbe = function() {
if (this.probe) {
if (!this.probe.handler.execAction) {
this.probe.handler.execAction = defaultExecAction();
}

if (!this.probe.handler.httpGetAction) {
this.probe.handler.httpGetAction = defaultHttpGetAction();
}

if (!this.probe.handler.tcpSocketAction) {
this.probe.handler.tcpSocketAction = defaultTcpSocketAction();
}
}
};

this.prepareProbe();
});
20 changes: 5 additions & 15 deletions app/scripts/modules/kubernetes/instance/details/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ <h3 select-on-dbl-click>
<span class="glyphicon glyphicon-{{metric.state}}-triangle"></span>
{{metric.state | robotToHuman}}
</span>
<span class="pad-left small">
<a ng-if="metric.healthCheckUrl" target="_blank" href="{{metric.healthCheckUrl}}">Health Check</a>
<span ng-if="metric.healthCheckUrl && metric.statusPageUrl"> | </span>
<a ng-if="metric.statusPageUrl" target="_blank" href="{{metric.statusPageUrl}}">Status</a>
</span>
</div>
<div ng-if="metric.type === 'LoadBalancer' && metric.loadBalancers.length" ng-repeat="loadBalancer in metric.loadBalancers">
<instance-load-balancer-health load-balancer="loadBalancer"></instance-load-balancer-health>
</div>
</dd>
{{instance.phase}}
Expand Down Expand Up @@ -131,13 +123,13 @@ <h3 select-on-dbl-click>
</dl>
</collapsible-section>
<collapsible-section ng-if="!instance.notFound" heading="Labels">
<dl ng-repeat="(key, value) in instance.metadata.labels" class="dl-horizontal"
<div ng-repeat="(key, value) in instance.metadata.labels" class="dl-horizontal"
ng-class="InsightFilterStateModel.filtersExpanded ? 'dl-narrow' : 'dl-wide'">
{{key}}: {{value}}
</dl>
</div>
</collapsible-section>
<dl ng-repeat="container in instance.containers" ng-class="InsightFilterStateModel.filtersExpanded ? '' : 'dl-horizontal'">
<collapsible-section heading="Container {{container.image}}">
<div ng-repeat="container in instance.containers" ng-class="InsightFilterStateModel.filtersExpanded ? '' : 'dl-horizontal'">
<collapsible-section heading="Container {{container.name}}">
<dt>Name</dt>
<dd>{{container.name}}</dd>
<dt>Image</dt>
Expand Down Expand Up @@ -206,8 +198,6 @@ <h3 select-on-dbl-click>
</dd>
</div>
</collapsible-section>
</dl>
<collapsible-section heading="Logs">
</collapsible-section>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions app/scripts/modules/kubernetes/kubernetes.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = angular.module('spinnaker.kubernetes', [
require('../core/pipeline/config/stages/resizeAsg/kubernetes/resizeStage.js'),
require('./cache/configurer.service.js'),
require('./container/configurer.directive.js'),
require('./container/probe.directive.js'),
require('./instance/details/details.kubernetes.module.js'),
require('./loadBalancer/configure/configure.kubernetes.module.js'),
require('./loadBalancer/details/details.kubernetes.module.js'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module.exports = angular.module('spinnaker.serverGroup.configure.kubernetes.conf
hostIp: null,
}
],
livenessProbe: null,
readinessProbe: null,
};
};
}
Expand Down
Loading

0 comments on commit 59bdf98

Please sign in to comment.