feat(endpoint-creation): update Edge agent deployment instructions
This commit is contained in:
@@ -43,7 +43,7 @@ func (payload *endpointCreatePayload) Validate(r *http.Request) error {
|
||||
|
||||
endpointType, err := request.RetrieveNumericMultiPartFormValue(r, "EndpointType", false)
|
||||
if err != nil || endpointType == 0 {
|
||||
return portainer.Error("Invalid endpoint type value. Value must be one of: 1 (Docker environment), 2 (Agent environment), 3 (Azure environment) or 4 (Agent Edge environment)")
|
||||
return portainer.Error("Invalid endpoint type value. Value must be one of: 1 (Docker environment), 2 (Agent environment), 3 (Azure environment) or 4 (Edge Agent environment)")
|
||||
}
|
||||
payload.EndpointType = endpointType
|
||||
|
||||
@@ -151,8 +151,8 @@ func (handler *Handler) endpointCreate(w http.ResponseWriter, r *http.Request) *
|
||||
func (handler *Handler) createEndpoint(payload *endpointCreatePayload) (*portainer.Endpoint, *httperror.HandlerError) {
|
||||
if portainer.EndpointType(payload.EndpointType) == portainer.AzureEnvironment {
|
||||
return handler.createAzureEndpoint(payload)
|
||||
} else if portainer.EndpointType(payload.EndpointType) == portainer.AgentEdgeEnvironment {
|
||||
return handler.createAgentEdgeEndpoint(payload)
|
||||
} else if portainer.EndpointType(payload.EndpointType) == portainer.EdgeAgentEnvironment {
|
||||
return handler.createEdgeAgentEndpoint(payload)
|
||||
}
|
||||
|
||||
if payload.TLS {
|
||||
@@ -199,8 +199,8 @@ func (handler *Handler) createAzureEndpoint(payload *endpointCreatePayload) (*po
|
||||
return endpoint, nil
|
||||
}
|
||||
|
||||
func (handler *Handler) createAgentEdgeEndpoint(payload *endpointCreatePayload) (*portainer.Endpoint, *httperror.HandlerError) {
|
||||
endpointType := portainer.AgentEdgeEnvironment
|
||||
func (handler *Handler) createEdgeAgentEndpoint(payload *endpointCreatePayload) (*portainer.Endpoint, *httperror.HandlerError) {
|
||||
endpointType := portainer.EdgeAgentEnvironment
|
||||
endpointID := handler.EndpointService.GetNextIdentifier()
|
||||
|
||||
edgeKey := base64.RawStdEncoding.EncodeToString([]byte(strings.TrimPrefix(payload.URL, "tcp://") + ":9999:7777:random_secret"))
|
||||
|
||||
@@ -68,7 +68,7 @@ func (handler *Handler) websocketExec(w http.ResponseWriter, r *http.Request) *h
|
||||
func (handler *Handler) handleExecRequest(w http.ResponseWriter, r *http.Request, params *webSocketRequestParams) error {
|
||||
r.Header.Del("Origin")
|
||||
|
||||
if params.nodeName != "" || (params.endpoint.Type == portainer.AgentOnDockerEnvironment || params.endpoint.Type == portainer.AgentEdgeEnvironment) {
|
||||
if params.nodeName != "" || (params.endpoint.Type == portainer.AgentOnDockerEnvironment || params.endpoint.Type == portainer.EdgeAgentEnvironment) {
|
||||
return handler.proxyWebsocketRequest(w, r, params)
|
||||
}
|
||||
|
||||
|
||||
@@ -894,8 +894,8 @@ const (
|
||||
AgentOnDockerEnvironment
|
||||
// AzureEnvironment represents an endpoint connected to an Azure environment
|
||||
AzureEnvironment
|
||||
// AgentEdgeEnvironment represents an endpoint connected to an Edge agent
|
||||
AgentEdgeEnvironment
|
||||
// EdgeAgentEnvironment represents an endpoint connected to an Edge agent
|
||||
EdgeAgentEnvironment
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -125,7 +125,7 @@ angular.module('portainer.app')
|
||||
} else if (type === 3) {
|
||||
return 'Azure ACI';
|
||||
} else if (type === 4) {
|
||||
return 'Agent Edge';
|
||||
return 'Edge Agent';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ function ($q, $scope, $state, $filter, clipboard, EndpointService, GroupService,
|
||||
addEndpoint(name, 2, URL, publicURL, groupId, tags, true, true, true, null, null, null);
|
||||
};
|
||||
|
||||
$scope.addAgentEdgeEndpoint = function() {
|
||||
$scope.addEdgeAgentEndpoint = function() {
|
||||
var name = $scope.formValues.Name;
|
||||
var groupId = $scope.formValues.GroupId;
|
||||
var tags = $scope.formValues.Tags;
|
||||
|
||||
@@ -37,13 +37,13 @@
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" id="agent_edge_endpoint" ng-model="state.EnvironmentType" value="agent_edge">
|
||||
<label for="agent_edge_endpoint">
|
||||
<input type="radio" id="edge_agent_endpoint" ng-model="state.EnvironmentType" value="edge_agent">
|
||||
<label for="edge_agent_endpoint">
|
||||
<div class="boxselector_header">
|
||||
<i class="fa fa-cloud" aria-hidden="true" style="margin-right: 2px;"></i>
|
||||
Agent Edge
|
||||
Edge Agent
|
||||
</div>
|
||||
<p>Portainer agent Edge</p>
|
||||
<p>Portainer Edge agent</p>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
@@ -248,7 +248,7 @@
|
||||
<span ng-hide="state.actionInProgress"><i class="fa fa-plus" aria-hidden="true"></i> Add endpoint</span>
|
||||
<span ng-show="state.actionInProgress">Creating endpoint...</span>
|
||||
</button>
|
||||
<button ng-if="state.EnvironmentType === 'agent_edge'" type="submit" class="btn btn-primary btn-sm" ng-disabled="state.actionInProgress || !endpointCreationForm.$valid" ng-click="addAgentEdgeEndpoint()" button-spinner="state.actionInProgress">
|
||||
<button ng-if="state.EnvironmentType === 'edge_agent'" type="submit" class="btn btn-primary btn-sm" ng-disabled="state.actionInProgress || !endpointCreationForm.$valid" ng-click="addEdgeAgentEndpoint()" button-spinner="state.actionInProgress">
|
||||
<span ng-hide="state.actionInProgress"><i class="fa fa-plus" aria-hidden="true"></i> Add endpoint</span>
|
||||
<span ng-show="state.actionInProgress">Creating endpoint...</span>
|
||||
</button>
|
||||
|
||||
@@ -13,20 +13,56 @@
|
||||
Deploy an agent on your remote Docker environment using the following command to enable this endpoint
|
||||
</p>
|
||||
<div style="margin-top: 10px;">
|
||||
<uib-tabset active="state.deploymentTab">
|
||||
<uib-tab index="0" heading="Standalone">
|
||||
<code style=display:block;white-space:pre-wrap>
|
||||
docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /var/lib/docker/volumes:/var/lib/docker/volumes \
|
||||
-v /:/host \
|
||||
--restart always \
|
||||
-e EDGE=1 \
|
||||
-e CAP_HOST_MANAGEMENT=1 \
|
||||
--name portainer_edge_agent \
|
||||
portainer/pagent:edge
|
||||
</code>
|
||||
</uib-tab>
|
||||
<uib-tab index="1" heading="Swarm">
|
||||
<code style=display:block;white-space:pre-wrap>
|
||||
docker service create \
|
||||
--name portainer_agent \
|
||||
--network portainer_agent_network \
|
||||
-e AGENT_CLUSTER_ADDR=tasks.portainer_agent \
|
||||
-e EDGE=1 \
|
||||
-e CAP_HOST_MANAGEMENT=1 \
|
||||
--mode global \
|
||||
--constraint 'node.platform.os == linux' \
|
||||
--mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock \
|
||||
--mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volumes \
|
||||
portainer/pagent:edge
|
||||
</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 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>
|
||||
Use the following join token to associate an agent with this endpoint
|
||||
</p>
|
||||
<div style="margin-top: 10px;">
|
||||
<code style=display:block;white-space:pre-wrap>
|
||||
docker run -d -v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /var/lib/docker/volumes:/var/lib/docker/volumes \
|
||||
-v /:/host \
|
||||
--restart always \
|
||||
-e TUNNELLING_MODE=1 \
|
||||
-e AGENT_SECRET={{ endpoint.EdgeKey }} \
|
||||
-e CAP_HOST_MANAGEMENT=1 \
|
||||
--name portainer_agent_edge \
|
||||
portainer/pagent:edge
|
||||
{{ endpoint.EdgeKey }}
|
||||
</code>
|
||||
<div style="margin-top: 10px;">
|
||||
<span class="btn btn-primary btn-sm" ng-click="copyAgentEdgeDeploymentCommand()"><i class="fa fa-copy space-right" aria-hidden="true"></i>Copy command</span>
|
||||
<span id="copyNotification" style="margin-left: 7px; display: none; color: #23ae89;">
|
||||
<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>
|
||||
|
||||
@@ -10,17 +10,28 @@ function ($q, $scope, $state, $transition$, $filter, clipboard, EndpointService,
|
||||
|
||||
$scope.state = {
|
||||
uploadInProgress: false,
|
||||
actionInProgress: false
|
||||
actionInProgress: false,
|
||||
deploymentTab: 0
|
||||
};
|
||||
|
||||
$scope.formValues = {
|
||||
SecurityFormData: new EndpointSecurityFormData()
|
||||
};
|
||||
|
||||
$scope.copyAgentEdgeDeploymentCommand = function() {
|
||||
clipboard.copyText('docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host --restart always -e TUNNELLING_MODE=1 -e AGENT_SECRET=' + $scope.endpoint.EdgeKey + ' -e CAP_HOST_MANAGEMENT=1 --name portainer_agent_iot portainer/pagent:intel');
|
||||
$('#copyNotification').show();
|
||||
$('#copyNotification').fadeOut(2500);
|
||||
$scope.copyEdgeAgentDeploymentCommand = function() {
|
||||
if ($scope.state.deploymentTab === 0) {
|
||||
clipboard.copyText('docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host --restart always -e EDGE=1 -e CAP_HOST_MANAGEMENT=1 --name portainer_agent_iot portainer/pagent:edge');
|
||||
} else {
|
||||
clipboard.copyText('docker service create --name portainer_agent --network portainer_agent_network -e AGENT_CLUSTER_ADDR=tasks.portainer_agent -e EDGE=1 -e CAP_HOST_MANAGEMENT=1 --mode global --constraint \'node.platform.os == linux\' --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock --mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volume portainer/pagent:edge');
|
||||
}
|
||||
$('#copyNotificationDeploymentCommand').show();
|
||||
$('#copyNotificationDeploymentCommand').fadeOut(2500);
|
||||
};
|
||||
|
||||
$scope.copyEdgeAgentKey = function() {
|
||||
clipboard.copyText($scope.endpoint.EdgeKey);
|
||||
$('#copyNotificationEdgeKey').show();
|
||||
$('#copyNotificationEdgeKey').fadeOut(2500);
|
||||
};
|
||||
|
||||
$scope.updateEndpoint = function() {
|
||||
|
||||
Reference in New Issue
Block a user