1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 05:15:25 +02:00

feature(kubernetes): stack name made optional & add toggle to disable stack in kubernetes [EE-6170] (#10436)

This commit is contained in:
Prabhat Khera 2023-10-16 14:08:06 +13:00 committed by GitHub
parent 44d66cc633
commit 7840e0bfe1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 305 additions and 47 deletions

View file

@ -99,6 +99,54 @@
</div>
<!-- #endregion -->
<!-- #region STACK -->
<div class="form-group" ng-if="!ctrl.deploymentOptions.hideStacksFunctionality && ctrl.state.appType !== ctrl.KubernetesDeploymentTypes.APPLICATION_FORM">
<div class="col-sm-12 small text-muted vertical-center">
<pr-icon icon="'info'" mode="'primary'"></pr-icon>
Portainer can automatically bundle multiple applications inside a stack. Enter a name of a new stack or select an existing stack in the list. Leave empty to use
the application name.
</div>
</div>
<div class="form-group" ng-if="!ctrl.deploymentOptions.hideStacksFunctionality && ctrl.state.appType !== ctrl.KubernetesDeploymentTypes.APPLICATION_FORM">
<label for="stack_name" class="col-sm-3 col-lg-2 control-label text-left">
Stack
<portainer-tooltip
ng-if="!ctrl.isAdmin"
message="'The stack field below was previously labelled \'Name\' but, in
fact, it\'s always been the stack name (hence the relabelling).'"
class-name="'[&>span]:!text-left'"
set-html-message="true"
>
</portainer-tooltip>
<portainer-tooltip
ng-if="ctrl.isAdmin"
message="'The stack field below was previously labelled \'Name\' but, in
fact, it\'s always been the stack name (hence the relabelling).<br/>
Kubernetes Stacks functionality can be turned off entirely via
<a href=\'/#!/settings\' target=\'_blank\'>
Kubernetes Settings
</a>.'"
class-name="'[&>span]:!text-left'"
set-html-message="true"
>
</portainer-tooltip>
</label>
<div class="col-sm-8">
<input
type="text"
class="form-control"
placeholder="myStack"
ng-model="ctrl.formValues.StackName"
name="stack_name"
uib-typeahead="stack for stack in ctrl.stacks | filter:$viewValue | limitTo:7"
typeahead-min-length="0"
data-cy="k8sAppCreate-stackName"
/>
</div>
</div>
<!-- #endregion -->
<!-- #region Git repository -->
<kubernetes-redeploy-app-git-form
ng-if="ctrl.state.appType === ctrl.KubernetesDeploymentTypes.GIT"
@ -218,7 +266,7 @@
<div ng-if="ctrl.formValues.ResourcePool">
<!-- #region STACK -->
<div class="form-group">
<div class="form-group" ng-if="!ctrl.deploymentOptions.hideStacksFunctionality">
<div class="col-sm-12 small text-muted vertical-center">
<pr-icon icon="'info'" mode="'primary'"></pr-icon>
Portainer can automatically bundle multiple applications inside a stack. Enter a name of a new stack or select an existing stack in the list. Leave empty to
@ -226,7 +274,7 @@
</div>
</div>
<div class="form-group">
<div class="form-group" ng-if="!ctrl.deploymentOptions.hideStacksFunctionality">
<label for="stack_name" class="col-sm-3 col-lg-2 control-label text-left">Stack</label>
<div class="col-sm-8">
<input
@ -1401,7 +1449,7 @@
class="btn btn-sm btn-primary"
ng-click="ctrl.updateApplicationViaWebEditor()"
ng-if="ctrl.state.appType === ctrl.KubernetesDeploymentTypes.CONTENT || ctrl.state.updateWebEditorInProgress"
ng-disabled="!kubernetesApplicationCreationForm.$valid || !ctrl.state.isEditorDirty || ctrl.state.updateWebEditorInProgress"
ng-disabled="kubernetesApplicationCreationForm.$valid && !ctrl.state.isEditorDirty && ctrl.savedFormValues.StackName === ctrl.formValues.StackName || ctrl.state.updateWebEditorInProgress"
style="margin-top: 7px; margin-left: 0"
button-spinner="ctrl.state.updateWebEditorInProgress"
>

View file

@ -5,6 +5,7 @@ import * as JsonPatch from 'fast-json-patch';
import { RegistryTypes } from '@/portainer/models/registryTypes';
import { getServices } from '@/react/kubernetes/networks/services/service';
import { KubernetesConfigurationKinds } from 'Kubernetes/models/configuration/models';
import { getGlobalDeploymentOptions } from '@/react/portainer/settings/settings.service';
import {
KubernetesApplicationDataAccessPolicies,
@ -196,7 +197,10 @@ class KubernetesCreateApplicationController {
}
this.state.updateWebEditorInProgress = true;
await this.StackService.updateKubeStack({ EndpointId: this.endpoint.Id, Id: this.application.StackId }, { stackFile: this.stackFileContent });
await this.StackService.updateKubeStack(
{ EndpointId: this.endpoint.Id, Id: this.application.StackId },
{ stackFile: this.stackFileContent, stackName: this.formValues.StackName }
);
this.state.isEditorDirty = false;
await this.$state.reload(this.$state.current);
} catch (err) {
@ -932,7 +936,7 @@ class KubernetesCreateApplicationController {
this.formValues.ApplicationOwner = this.Authentication.getUserDetails().username;
// combine the secrets and configmap form values when submitting the form
_.remove(this.formValues.Configurations, (item) => item.SelectedConfiguration === undefined);
await this.KubernetesApplicationService.create(this.formValues, this.originalServicePorts);
await this.KubernetesApplicationService.create(this.formValues, this.originalServicePorts, this.deploymentOptions.hideStacksFunctionality);
this.Notifications.success('Request to deploy application successfully submitted', this.formValues.Name);
this.$state.go('kubernetes.applications');
} catch (err) {
@ -1092,6 +1096,8 @@ class KubernetesCreateApplicationController {
this.state.useLoadBalancer = this.endpoint.Kubernetes.Configuration.UseLoadBalancer;
this.state.useServerMetrics = this.endpoint.Kubernetes.Configuration.UseServerMetrics;
this.deploymentOptions = await getGlobalDeploymentOptions();
const [resourcePools, nodes, nodesLimits] = await Promise.all([
this.KubernetesResourcePoolService.get(),
this.KubernetesNodeService.get(),
@ -1140,6 +1146,8 @@ class KubernetesCreateApplicationController {
this.nodesLabels,
this.ingresses
);
this.formValues.Services = this.formValues.Services || [];
this.originalServicePorts = structuredClone(this.formValues.Services.flatMap((service) => service.Ports));
this.originalIngressPaths = structuredClone(this.originalServicePorts.flatMap((port) => port.ingressPaths).filter((ingressPath) => ingressPath.Host));