mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 21:35:23 +02:00
feat(k8s/application): add the ability to set the auto-scale policy of an application (#4118)
* feat(application): add horizontalpodautoscaler creation * feat(application): Add the ability to set the auto-scale policy of an application * feat(k8s/application): minor UI update * fix(application): set api version and prevent to use hpa with global deployment type * feat(settings): add a switch to enable features based on server metrics * feat(k8s/applications): minor UI update Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
parent
909e1ef02c
commit
6756b04b67
16 changed files with 534 additions and 84 deletions
|
@ -635,7 +635,13 @@
|
|||
</label>
|
||||
</div>
|
||||
<div ng-if="ctrl.supportGlobalDeployment()">
|
||||
<input type="radio" id="deployment_global" ng-value="ctrl.ApplicationDeploymentTypes.GLOBAL" ng-model="ctrl.formValues.DeploymentType" />
|
||||
<input
|
||||
type="radio"
|
||||
id="deployment_global"
|
||||
ng-value="ctrl.ApplicationDeploymentTypes.GLOBAL"
|
||||
ng-model="ctrl.formValues.DeploymentType"
|
||||
ng-click="ctrl.unselectAutoScaler()"
|
||||
/>
|
||||
<label for="deployment_global">
|
||||
<div class="boxselector_header">
|
||||
<i class="fa fa-cubes" aria-hidden="true" style="margin-right: 2px;"></i>
|
||||
|
@ -695,6 +701,116 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- auto scaling -->
|
||||
<div class="col-sm-12 form-section-title" ng-if="ctrl.formValues.DeploymentType !== ctrl.ApplicationDeploymentTypes.GLOBAL">
|
||||
Auto-scaling
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-if="ctrl.formValues.DeploymentType !== ctrl.ApplicationDeploymentTypes.GLOBAL && ctrl.state.useServerMetrics">
|
||||
<div class="col-sm-12">
|
||||
<label for="enable_auto_scaling" class="control-label text-left">
|
||||
Enable auto scaling for this application
|
||||
</label>
|
||||
<label class="switch" style="margin-left: 20px;">
|
||||
<input type="checkbox" class="form-control" name="enable_auto_scaling" ng-model="ctrl.formValues.AutoScaler.IsUsed" />
|
||||
<i></i>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-if="ctrl.formValues.DeploymentType !== ctrl.ApplicationDeploymentTypes.GLOBAL && !ctrl.state.useServerMetrics">
|
||||
<div class="col-sm-12 small text-muted">
|
||||
<p ng-if="!ctrl.isAdmin">
|
||||
This feature is currently disabled and must be enabled by an administrator user.
|
||||
</p>
|
||||
<p ng-if="ctrl.isAdmin">
|
||||
Server metrics features must be enabled in the
|
||||
<a ui-sref="portainer.endpoints.endpoint.kubernetesConfig({id: ctrl.endpoint.Id})" class="ctrl.isAdmin">endpoint configuration view</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-inline" ng-if="ctrl.formValues.AutoScaler.IsUsed">
|
||||
<table class="table" style="margin-bottom: 0px;">
|
||||
<tbody>
|
||||
<tr class="small">
|
||||
<td style="width: 33%; border: none; padding: 2px 0 2px 0;">Minimum instances</td>
|
||||
<td style="width: 33%; border: none; padding: 2px 0 2px 0;">Maximum instances</td>
|
||||
<td style="width: 33%; border: none; padding: 2px 0 2px 0;">
|
||||
Target CPU usage (<b>%</b>)
|
||||
<portainer-tooltip position="bottom" message="The autoscaler will ensure enough instances are running to maintain an average CPU usage across all instances.">
|
||||
</portainer-tooltip>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 8px 5px 5px 0; border: none;">
|
||||
<div class="input-group input-group-sm" style="width: 100%;">
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
name="auto_scaler_min"
|
||||
min="0"
|
||||
ng-max="ctrl.formValues.AutoScaler.MaxReplicas"
|
||||
ng-model="ctrl.formValues.AutoScaler.MinReplicas"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="input-group input-group-sm" ng-show="kubernetesApplicationCreationForm['auto_scaler_min'].$invalid">
|
||||
<div class="small text-warning" style="margin-top: 5px;">
|
||||
<ng-messages for="kubernetesApplicationCreationForm['auto_scaler_min'].$error">
|
||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Minimum instances is required.</p>
|
||||
<p ng-message="min"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Minimum instances must be greater than 0.</p>
|
||||
<p ng-message="max"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Minimum instances must be smaller than maximum instances.</p>
|
||||
</ng-messages>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="padding: 8px 5px 5px 0; border: none;">
|
||||
<div class="input-group input-group-sm" style="width: 100%;">
|
||||
<input
|
||||
type="number"
|
||||
class="form-control"
|
||||
name="auto_scaler_max"
|
||||
ng-min="ctrl.formValues.AutoScaler.MinReplicas"
|
||||
ng-model="ctrl.formValues.AutoScaler.MaxReplicas"
|
||||
/>
|
||||
</div>
|
||||
<div class="input-group input-group-sm" ng-show="kubernetesApplicationCreationForm['auto_scaler_max'].$invalid || ctrl.autoScalerOverflow()">
|
||||
<div class="small text-warning" style="margin-top: 5px;">
|
||||
<ng-messages for="kubernetesApplicationCreationForm['auto_scaler_max'].$error">
|
||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Maximum instances is required.</p>
|
||||
<p ng-message="min"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Maximum instances must be greater than minimum instances.</p>
|
||||
</ng-messages>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td style="padding: 8px 5px 5px 0; border: none;">
|
||||
<div class="input-group input-group-sm" style="width: 100%;">
|
||||
<input type="number" class="form-control" name="auto_scaler_cpu" ng-model="ctrl.formValues.AutoScaler.TargetCPUUtilization" min="1" max="100" required />
|
||||
</div>
|
||||
<div class="input-group input-group-sm" ng-show="kubernetesApplicationCreationForm['auto_scaler_cpu'].$invalid">
|
||||
<div class="small text-warning" style="margin-top: 5px;">
|
||||
<ng-messages for="kubernetesApplicationCreationForm['auto_scaler_cpu'].$error">
|
||||
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Target CPU usage is required.</p>
|
||||
<p ng-message="min"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Target CPU usage must be greater than 0.</p>
|
||||
<p ng-message="max"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Target CPU usage must be smaller than 100.</p>
|
||||
</ng-messages>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="form-group" ng-if="ctrl.autoScalerOverflow()" style="margin-bottom: 10px;">
|
||||
<div class="col-sm-12 small text-muted">
|
||||
<i class="fa fa-exclamation-circle orange-icon" aria-hidden="true" style="margin-right: 2px;"></i>
|
||||
This application would exceed available resources. Please review resource reservations or the maximum instance count of the auto-scaling policy.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- !auto scaling -->
|
||||
|
||||
<div class="col-sm-12 form-section-title">
|
||||
Publishing the application
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue