diff --git a/api/http/handler/endpoints/endpoint_create.go b/api/http/handler/endpoints/endpoint_create.go index 4aac20039..5362d596b 100644 --- a/api/http/handler/endpoints/endpoint_create.go +++ b/api/http/handler/endpoints/endpoint_create.go @@ -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")) diff --git a/api/http/handler/websocket/exec.go b/api/http/handler/websocket/exec.go index 09eb235b6..8916d57a7 100644 --- a/api/http/handler/websocket/exec.go +++ b/api/http/handler/websocket/exec.go @@ -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) } diff --git a/api/portainer.go b/api/portainer.go index 6f780a92e..347aaa612 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -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 ( diff --git a/app/portainer/filters/filters.js b/app/portainer/filters/filters.js index db35252c7..cfe6f5e1a 100644 --- a/app/portainer/filters/filters.js +++ b/app/portainer/filters/filters.js @@ -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 ''; }; diff --git a/app/portainer/views/endpoints/create/createEndpointController.js b/app/portainer/views/endpoints/create/createEndpointController.js index b465022dd..9803ea3f5 100644 --- a/app/portainer/views/endpoints/create/createEndpointController.js +++ b/app/portainer/views/endpoints/create/createEndpointController.js @@ -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; diff --git a/app/portainer/views/endpoints/create/createendpoint.html b/app/portainer/views/endpoints/create/createendpoint.html index e82370b9f..d9a5340bd 100644 --- a/app/portainer/views/endpoints/create/createendpoint.html +++ b/app/portainer/views/endpoints/create/createendpoint.html @@ -37,13 +37,13 @@
- -
@@ -248,7 +248,7 @@ Add endpoint Creating endpoint... - diff --git a/app/portainer/views/endpoints/edit/endpoint.html b/app/portainer/views/endpoints/edit/endpoint.html index 0dddc963e..00cf4afa9 100644 --- a/app/portainer/views/endpoints/edit/endpoint.html +++ b/app/portainer/views/endpoints/edit/endpoint.html @@ -13,20 +13,56 @@ Deploy an agent on your remote Docker environment using the following command to enable this endpoint

+ + + + 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 + + + + + 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 + + + +
+ Copy command + +
+
+
+ Join token +
+

+ + Use the following join token to associate an agent with this endpoint +

+
- 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 }}
- Copy command -
diff --git a/app/portainer/views/endpoints/edit/endpointController.js b/app/portainer/views/endpoints/edit/endpointController.js index 3299547da..2200d1b27 100644 --- a/app/portainer/views/endpoints/edit/endpointController.js +++ b/app/portainer/views/endpoints/edit/endpointController.js @@ -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() {