mirror of https://github.com/portainer/portainer
fix(endpoints): show edge script when unassociated [EE-2842] (#6730)
parent
287107e8da
commit
13faa75a2d
|
@ -16,7 +16,7 @@ angular.module('portainer.app').factory('Endpoints', [
|
|||
},
|
||||
get: { method: 'GET', params: { id: '@id' } },
|
||||
update: { method: 'PUT', params: { id: '@id' } },
|
||||
deassociate: { method: 'DELETE', params: { id: '@id', action: 'association' } },
|
||||
disassociate: { method: 'DELETE', params: { id: '@id', action: 'association' } },
|
||||
updateAccess: { method: 'PUT', params: { id: '@id', action: 'access' } },
|
||||
remove: { method: 'DELETE', params: { id: '@id' } },
|
||||
snapshots: { method: 'POST', params: { action: 'snapshot' } },
|
||||
|
|
|
@ -40,8 +40,8 @@ angular.module('portainer.app').factory('EndpointService', [
|
|||
return Endpoints.updateAccess({ id: id }, { UserAccessPolicies: userAccessPolicies, TeamAccessPolicies: teamAccessPolicies }).$promise;
|
||||
};
|
||||
|
||||
service.deassociateEndpoint = function (endpointID) {
|
||||
return Endpoints.deassociate({ id: endpointID }).$promise;
|
||||
service.disassociateEndpoint = function (endpointID) {
|
||||
return Endpoints.disassociate({ id: endpointID }).$promise;
|
||||
};
|
||||
|
||||
service.updateEndpoint = function (id, payload) {
|
||||
|
|
|
@ -115,17 +115,17 @@ export function confirmDetachment(message: string, callback: ConfirmCallback) {
|
|||
});
|
||||
}
|
||||
|
||||
export function confirmDeassociate(callback: ConfirmCallback) {
|
||||
export function confirmDisassociate(callback: ConfirmCallback) {
|
||||
const message =
|
||||
'<p>De-associating this Edge environment will mark it as non associated and will clear the registered Edge ID.</p>' +
|
||||
'<p>Disassociating this Edge environment will mark it as non associated and will clear the registered Edge ID.</p>' +
|
||||
'<p>Any agent started with the Edge key associated to this environment will be able to re-associate with this environment.</p>' +
|
||||
'<p>You can re-use the Edge ID and Edge key that you used to deploy the existing Edge agent to associate a new Edge device to this environment.</p>';
|
||||
confirm({
|
||||
title: 'About de-associating',
|
||||
title: 'About disassociating',
|
||||
message: sanitize(message),
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'De-associate',
|
||||
label: 'Disassociate',
|
||||
className: 'btn-primary',
|
||||
},
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@ import bootbox from 'bootbox';
|
|||
import {
|
||||
cancelRegistryRepositoryAction,
|
||||
confirmAsync,
|
||||
confirmDeassociate,
|
||||
confirmDisassociate,
|
||||
confirmDeletion,
|
||||
confirmDetachment,
|
||||
confirmDeletionAsync,
|
||||
|
@ -46,7 +46,7 @@ export function ModalServiceAngular() {
|
|||
cancelRegistryRepositoryAction,
|
||||
confirmDeletion,
|
||||
confirmDetachment,
|
||||
confirmDeassociate,
|
||||
confirmDisassociate,
|
||||
confirmUpdate,
|
||||
confirmRedeploy,
|
||||
confirmDeletionAsync,
|
||||
|
|
|
@ -10,113 +10,112 @@
|
|||
</rd-header>
|
||||
|
||||
<div class="row">
|
||||
<information-panel ng-if="state.edgeEndpoint && endpoint.EdgeID && endpoint.LastCheckInDate" title-text="Edge information">
|
||||
<span class="small text-muted">
|
||||
<p>
|
||||
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
This Edge environment is associated to an Edge environment {{ state.kubernetesEndpoint ? '(Kubernetes)' : '(Docker)' }}.
|
||||
</p>
|
||||
<p>
|
||||
Edge key: <code>{{ endpoint.EdgeKey }}</code>
|
||||
</p>
|
||||
<p>
|
||||
Edge identifier: <code>{{ endpoint.EdgeID }}</code>
|
||||
</p>
|
||||
<p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-sm"
|
||||
ng-disabled="state.actionInProgress"
|
||||
ng-click="onDeassociateEndpoint()"
|
||||
button-spinner="state.actionInProgress"
|
||||
analytics-on
|
||||
analytics-event="edge-endpoint-deassociate"
|
||||
analytics-category="edge"
|
||||
>
|
||||
<span ng-hide="state.actionInProgress">De-associate</span>
|
||||
</button>
|
||||
</p>
|
||||
</span>
|
||||
</information-panel>
|
||||
<information-panel ng-if="state.edgeEndpoint && !endpoint.LastCheckInDate" title-text="Deploy an agent">
|
||||
<span class="small text-muted">
|
||||
<p>
|
||||
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
Refer to the platform related command below to deploy the Edge agent in your remote cluster.
|
||||
</p>
|
||||
<p>
|
||||
The agent will communicate with Portainer via <u>{{ edgeKeyDetails.instanceURL }}</u> and <u>tcp://{{ edgeKeyDetails.tunnelServerAddr }}</u>
|
||||
</p>
|
||||
<div class="input-group input-group-sm" style="margin-top: 10px; margin-bottom: 10px">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<label class="btn btn-primary" ng-model="state.platformType" uib-btn-radio="'linux'"><i class="fab fa-linux" style="margin-right: 2px"></i> Linux</label>
|
||||
<label class="btn btn-primary" ng-model="state.platformType" uib-btn-radio="'windows'"><i class="fab fa-windows" style="margin-right: 2px"></i> Windows</label>
|
||||
<div ng-if="state.edgeEndpoint">
|
||||
<information-panel ng-if="state.edgeAssociated" title-text="Edge information">
|
||||
<span class="small text-muted">
|
||||
<p>
|
||||
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
This Edge environment is associated to an Edge environment {{ state.kubernetesEndpoint ? '(Kubernetes)' : '(Docker)' }}.
|
||||
</p>
|
||||
<p>
|
||||
Edge key: <code>{{ endpoint.EdgeKey }}</code>
|
||||
</p>
|
||||
<p>
|
||||
Edge identifier: <code>{{ endpoint.EdgeID }}</code>
|
||||
</p>
|
||||
<p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-primary btn-sm"
|
||||
ng-disabled="state.actionInProgress"
|
||||
ng-click="onDisassociateEndpoint()"
|
||||
button-spinner="state.actionInProgress"
|
||||
analytics-on
|
||||
analytics-event="edge-endpoint-disassociate"
|
||||
analytics-category="edge"
|
||||
>
|
||||
<span ng-hide="state.actionInProgress">Disassociate</span>
|
||||
</button>
|
||||
</p>
|
||||
</span>
|
||||
</information-panel>
|
||||
<information-panel ng-if="!state.edgeAssociated" title-text="Deploy an agent">
|
||||
<span class="small text-muted">
|
||||
<p>
|
||||
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
Refer to the platform related command below to deploy the Edge agent in your remote cluster.
|
||||
</p>
|
||||
<p>
|
||||
The agent will communicate with Portainer via <u>{{ edgeKeyDetails.instanceURL }}</u> and <u>tcp://{{ edgeKeyDetails.tunnelServerAddr }}</u>
|
||||
</p>
|
||||
<div class="input-group input-group-sm" style="margin-top: 10px; margin-bottom: 10px">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<label class="btn btn-primary" ng-model="state.platformType" uib-btn-radio="'linux'"><i class="fab fa-linux" style="margin-right: 2px"></i> Linux</label>
|
||||
<label class="btn btn-primary" ng-model="state.platformType" uib-btn-radio="'windows'"><i class="fab fa-windows" style="margin-right: 2px"></i> Windows</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<por-switch-field
|
||||
label="'Allow self-signed certs'"
|
||||
checked="state.allowSelfSignedCerts"
|
||||
tooltip="'When allowing self-signed certificates the edge agent will ignore the domain validation when connecting to Portainer via HTTPS'"
|
||||
on-change="(onToggleAllowSelfSignedCerts)"
|
||||
></por-switch-field>
|
||||
</div>
|
||||
|
||||
<div class="form-group clearfix" ng-if="!isKubernetesDeploymentTabSelected()">
|
||||
<label for="env_vars" class="col-sm-3 col-lg-2 control-label text-left" style="padding-left: 0; padding-top: 5px">
|
||||
Environment variables
|
||||
<portainer-tooltip
|
||||
position="bottom"
|
||||
message="Comma separated list of environment variables that will be sourced from the host where the agent is deployed."
|
||||
></portainer-tooltip>
|
||||
</label>
|
||||
<div class="col-sm-9 col-lg-10">
|
||||
<input type="text" class="form-control" id="env_vars" ng-model="formValues.EnvVarSource" placeholder="foo=bar,myvar" />
|
||||
<div class="form-group">
|
||||
<por-switch-field
|
||||
label="'Allow self-signed certs'"
|
||||
checked="state.allowSelfSignedCerts"
|
||||
tooltip="'When allowing self-signed certificates the edge agent will ignore the domain validation when connecting to Portainer via HTTPS'"
|
||||
on-change="(onToggleAllowSelfSignedCerts)"
|
||||
></por-switch-field>
|
||||
</div>
|
||||
<div class="form-group clearfix" ng-if="!isKubernetesDeploymentTabSelected()">
|
||||
<label for="env_vars" class="col-sm-3 col-lg-2 control-label text-left" style="padding-left: 0; padding-top: 5px">
|
||||
Environment variables
|
||||
<portainer-tooltip
|
||||
position="bottom"
|
||||
message="Comma separated list of environment variables that will be sourced from the host where the agent is deployed."
|
||||
></portainer-tooltip>
|
||||
</label>
|
||||
<div class="col-sm-9 col-lg-10">
|
||||
<input type="text" class="form-control" id="env_vars" ng-model="formValues.EnvVarSource" placeholder="foo=bar,myvar" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 10px">
|
||||
<uib-tabset active="state.deploymentTab">
|
||||
<uib-tab index="'kubernetes'" heading="Kubernetes" ng-if="state.platformType === 'linux'">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px">{{
|
||||
dockerCommands[state.deploymentTab][state.platformType](agentShortVersion, endpoint.EdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts)
|
||||
}}</code>
|
||||
</uib-tab>
|
||||
<uib-tab index="'swarm'" heading="Docker Swarm">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px">{{
|
||||
dockerCommands[state.deploymentTab][state.platformType](agentVersion, endpoint.EdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts)
|
||||
}}</code>
|
||||
</uib-tab>
|
||||
<uib-tab index="'standalone'" heading="Docker Standalone">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px">{{
|
||||
dockerCommands[state.deploymentTab][state.platformType](agentVersion, endpoint.EdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts)
|
||||
}}</code>
|
||||
</uib-tab>
|
||||
</uib-tabset>
|
||||
<div style="margin-top: 10px">
|
||||
<span class="btn btn-primary btn-sm" ng-click="copyEdgeAgentDeploymentCommand()"><i class="fa fa-copy space-right" aria-hidden="true"></i>Copy command</span>
|
||||
<span id="copyNotificationDeploymentCommand" style="margin-left: 7px; display: none; color: #23ae89"> <i class="fa fa-check" aria-hidden="true"></i> copied </span>
|
||||
<uib-tabset active="state.deploymentTab">
|
||||
<uib-tab index="'kubernetes'" heading="Kubernetes" ng-if="state.platformType === 'linux'">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px">{{
|
||||
dockerCommands[state.deploymentTab][state.platformType](agentShortVersion, endpoint.EdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts)
|
||||
}}</code>
|
||||
</uib-tab>
|
||||
<uib-tab index="'swarm'" heading="Docker Swarm">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px">{{
|
||||
dockerCommands[state.deploymentTab][state.platformType](agentVersion, endpoint.EdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts)
|
||||
}}</code>
|
||||
</uib-tab>
|
||||
<uib-tab index="'standalone'" heading="Docker Standalone">
|
||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px">{{
|
||||
dockerCommands[state.deploymentTab][state.platformType](agentVersion, endpoint.EdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts)
|
||||
}}</code>
|
||||
</uib-tab>
|
||||
</uib-tabset>
|
||||
<div style="margin-top: 10px">
|
||||
<span class="btn btn-primary btn-sm" ng-click="copyEdgeAgentDeploymentCommand()"><i class="fa fa-copy space-right" aria-hidden="true"></i>Copy command</span>
|
||||
<span id="copyNotificationDeploymentCommand" style="margin-left: 7px; display: none; color: #23ae89"> <i class="fa fa-check" aria-hidden="true"></i> copied </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 form-section-title" style="margin-top: 25px"> Join token </div>
|
||||
<p>
|
||||
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
For those prestaging the edge agent, use the following join token to associate the Edge agent with this environment.
|
||||
</p>
|
||||
<p> You can read more about pre-staging in the userguide available <a href="https://downloads.portainer.io/edge_agent_guide.pdf">here.</a> </p>
|
||||
<div style="margin-top: 10px; overflow-wrap: break-word">
|
||||
<code>
|
||||
{{ endpoint.EdgeKey }}
|
||||
</code>
|
||||
<div style="margin-top: 10px">
|
||||
<span class="btn btn-primary btn-sm" ng-click="copyEdgeAgentKey()"><i class="fa fa-copy space-right" aria-hidden="true"></i>Copy token</span>
|
||||
<span id="copyNotificationEdgeKey" style="margin-left: 7px; display: none; color: #23ae89"> <i class="fa fa-check" aria-hidden="true"></i> copied </span>
|
||||
<div class="col-sm-12 form-section-title" style="margin-top: 25px"> Join token </div>
|
||||
<p>
|
||||
<i class="fa fa-info-circle blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
For those prestaging the edge agent, use the following join token to associate the Edge agent with this environment.
|
||||
</p>
|
||||
<p> You can read more about pre-staging in the userguide available <a href="https://downloads.portainer.io/edge_agent_guide.pdf">here.</a> </p>
|
||||
<div style="margin-top: 10px; overflow-wrap: break-word">
|
||||
<code>
|
||||
{{ endpoint.EdgeKey }}
|
||||
</code>
|
||||
<div style="margin-top: 10px">
|
||||
<span class="btn btn-primary btn-sm" ng-click="copyEdgeAgentKey()"><i class="fa fa-copy space-right" aria-hidden="true"></i>Copy token</span>
|
||||
<span id="copyNotificationEdgeKey" style="margin-left: 7px; display: none; color: #23ae89"> <i class="fa fa-check" aria-hidden="true"></i> copied </span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
</information-panel>
|
||||
<information-panel ng-if="state.kubernetesEndpoint && (!state.edgeEndpoint || (state.edgeEndpoint && endpoint.EdgeID))" title-text="Kubernetes features configuration">
|
||||
</span>
|
||||
</information-panel>
|
||||
</div>
|
||||
<information-panel ng-if="state.kubernetesEndpoint && (!state.edgeEndpoint || state.edgeAssociated)" title-text="Kubernetes features configuration">
|
||||
<span class="small text-muted">
|
||||
<i class="fa fa-tools blue-icon" aria-hidden="true" style="margin-right: 2px"></i>
|
||||
You should configure the features available in this Kubernetes environment in the
|
||||
|
|
|
@ -47,6 +47,7 @@ function EndpointController(
|
|||
kubernetesEndpoint: false,
|
||||
agentEndpoint: false,
|
||||
edgeEndpoint: false,
|
||||
edgeAssociated: false,
|
||||
allowCreate: Authentication.isAdmin(),
|
||||
availableEdgeAgentCheckinOptions: [
|
||||
{ key: 'Use default interval', value: 0 },
|
||||
|
@ -139,24 +140,24 @@ function EndpointController(
|
|||
}
|
||||
}
|
||||
|
||||
$scope.onDeassociateEndpoint = async function () {
|
||||
ModalService.confirmDeassociate((confirmed) => {
|
||||
$scope.onDisassociateEndpoint = async function () {
|
||||
ModalService.confirmDisassociate((confirmed) => {
|
||||
if (confirmed) {
|
||||
deassociateEndpoint();
|
||||
disassociateEndpoint();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
async function deassociateEndpoint() {
|
||||
async function disassociateEndpoint() {
|
||||
var endpoint = $scope.endpoint;
|
||||
|
||||
try {
|
||||
$scope.state.actionInProgress = true;
|
||||
await EndpointService.deassociateEndpoint(endpoint.Id);
|
||||
Notifications.success('Environment de-associated', $scope.endpoint.Name);
|
||||
await EndpointService.disassociateEndpoint(endpoint.Id);
|
||||
Notifications.success('Environment disassociated', $scope.endpoint.Name);
|
||||
$state.reload();
|
||||
} catch (err) {
|
||||
Notifications.error('Failure', err, 'Unable to de-associate environment');
|
||||
Notifications.error('Failure', err, 'Unable to disassociate environment');
|
||||
} finally {
|
||||
$scope.state.actionInProgress = false;
|
||||
}
|
||||
|
@ -280,6 +281,8 @@ function EndpointController(
|
|||
|
||||
if (endpoint.Type === PortainerEndpointTypes.EdgeAgentOnDockerEnvironment || endpoint.Type === PortainerEndpointTypes.EdgeAgentOnKubernetesEnvironment) {
|
||||
$scope.edgeKeyDetails = decodeEdgeKey(endpoint.EdgeKey);
|
||||
|
||||
$scope.state.edgeAssociated = !!endpoint.EdgeID;
|
||||
endpoint.EdgeID = endpoint.EdgeID || uuidv4();
|
||||
|
||||
$scope.state.availableEdgeAgentCheckinOptions[0].key += ` (${settings.EdgeAgentCheckinInterval} seconds)`;
|
||||
|
@ -291,8 +294,7 @@ function EndpointController(
|
|||
|
||||
configureState();
|
||||
|
||||
const disconnectedEdge = $scope.state.edgeEndpoint && !endpoint.EdgeID;
|
||||
if (EndpointHelper.isDockerEndpoint(endpoint) && !disconnectedEdge) {
|
||||
if (EndpointHelper.isDockerEndpoint(endpoint) && $scope.state.edgeAssociated) {
|
||||
$scope.state.showAMTInfo = settings && settings.openAMTConfiguration && settings.openAMTConfiguration.enabled;
|
||||
}
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in New Issue