diff --git a/app/portainer/services/api/endpointService.js b/app/portainer/services/api/endpointService.js index 19b05260a..43f55201d 100644 --- a/app/portainer/services/api/endpointService.js +++ b/app/portainer/services/api/endpointService.js @@ -56,10 +56,10 @@ angular.module('portainer.app').factory('EndpointService', [ return Endpoints.remove({ id: endpointID }).$promise; }; - service.createLocalEndpoint = function () { + service.createLocalEndpoint = function (name = 'local') { var deferred = $q.defer(); - FileUploadService.createEndpoint('local', PortainerEndpointCreationTypes.LocalDockerEnvironment, '', '', 1, [], false) + FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalDockerEnvironment, '', '', 1, [], false) .then(function success(response) { deferred.resolve(response.data); }) @@ -117,10 +117,10 @@ angular.module('portainer.app').factory('EndpointService', [ return deferred.promise; }; - service.createLocalKubernetesEndpoint = function () { + service.createLocalKubernetesEndpoint = function (name = 'local') { var deferred = $q.defer(); - FileUploadService.createEndpoint('local', PortainerEndpointCreationTypes.LocalKubernetesEnvironment, '', '', 1, [], true, true, true) + FileUploadService.createEndpoint(name, PortainerEndpointCreationTypes.LocalKubernetesEnvironment, '', '', 1, [], true, true, true) .then(function success(response) { deferred.resolve(response.data); }) diff --git a/app/portainer/views/endpoints/create/createEndpointController.js b/app/portainer/views/endpoints/create/createEndpointController.js index b54fa8dc2..abb039440 100644 --- a/app/portainer/views/endpoints/create/createEndpointController.js +++ b/app/portainer/views/endpoints/create/createEndpointController.js @@ -89,40 +89,72 @@ angular $scope.availableTags = $scope.availableTags.concat(tag); $scope.formValues.TagIds = $scope.formValues.TagIds.concat(tag.Id); } catch (err) { - Notifications.error('Failue', err, 'Unable to create tag'); + Notifications.error('Failure', err, 'Unable to create tag'); } } $scope.addDockerEndpoint = function () { + if ($scope.formValues.ConnectSocket) { + var endpointName = $scope.formValues.Name; + $scope.state.actionInProgress = true; + EndpointService.createLocalEndpoint(endpointName) + .then(function success() { + Notifications.success('Endpoint created', endpointName); + $state.go('portainer.endpoints', {}, { reload: true }); + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to create endpoint'); + }) + .finally(function final() { + $scope.state.actionInProgress = false; + }); + } else { + var name = $scope.formValues.Name; + var URL = $filter('stripprotocol')($scope.formValues.URL); + var publicURL = $scope.formValues.PublicURL === '' ? URL.split(':')[0] : $scope.formValues.PublicURL; + var groupId = $scope.formValues.GroupId; + var tagIds = $scope.formValues.TagIds; + + var securityData = $scope.formValues.SecurityFormData; + var TLS = securityData.TLS; + var TLSMode = securityData.TLSMode; + var TLSSkipVerify = TLS && (TLSMode === 'tls_client_noca' || TLSMode === 'tls_only'); + var TLSSkipClientVerify = TLS && (TLSMode === 'tls_ca' || TLSMode === 'tls_only'); + var TLSCAFile = TLSSkipVerify ? null : securityData.TLSCACert; + var TLSCertFile = TLSSkipClientVerify ? null : securityData.TLSCert; + var TLSKeyFile = TLSSkipClientVerify ? null : securityData.TLSKey; + + addEndpoint( + name, + PortainerEndpointCreationTypes.LocalDockerEnvironment, + URL, + publicURL, + groupId, + tagIds, + TLS, + TLSSkipVerify, + TLSSkipClientVerify, + TLSCAFile, + TLSCertFile, + TLSKeyFile + ); + } + }; + + $scope.addKubernetesEndpoint = function () { var name = $scope.formValues.Name; - var URL = $filter('stripprotocol')($scope.formValues.URL); - var publicURL = $scope.formValues.PublicURL === '' ? URL.split(':')[0] : $scope.formValues.PublicURL; - var groupId = $scope.formValues.GroupId; - var tagIds = $scope.formValues.TagIds; - - var securityData = $scope.formValues.SecurityFormData; - var TLS = securityData.TLS; - var TLSMode = securityData.TLSMode; - var TLSSkipVerify = TLS && (TLSMode === 'tls_client_noca' || TLSMode === 'tls_only'); - var TLSSkipClientVerify = TLS && (TLSMode === 'tls_ca' || TLSMode === 'tls_only'); - var TLSCAFile = TLSSkipVerify ? null : securityData.TLSCACert; - var TLSCertFile = TLSSkipClientVerify ? null : securityData.TLSCert; - var TLSKeyFile = TLSSkipClientVerify ? null : securityData.TLSKey; - - addEndpoint( - name, - PortainerEndpointCreationTypes.LocalDockerEnvironment, - URL, - publicURL, - groupId, - tagIds, - TLS, - TLSSkipVerify, - TLSSkipClientVerify, - TLSCAFile, - TLSCertFile, - TLSKeyFile - ); + $scope.state.actionInProgress = true; + EndpointService.createLocalKubernetesEndpoint(name) + .then(function success(result) { + Notifications.success('Endpoint created', name); + $state.go('portainer.endpoints.endpoint.kubernetesConfig', { id: result.Id }); + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to create endpoint'); + }) + .finally(function final() { + $scope.state.actionInProgress = false; + }); }; $scope.addAgentEndpoint = function () { diff --git a/app/portainer/views/endpoints/create/createendpoint.html b/app/portainer/views/endpoints/create/createendpoint.html index 5d885a947..2f3f62814 100644 --- a/app/portainer/views/endpoints/create/createendpoint.html +++ b/app/portainer/views/endpoints/create/createendpoint.html @@ -44,6 +44,16 @@

Directly connect to the Docker API

+
+ + +
- - The Docker API must be exposed over TCP. You can find more information about how to expose the Docker API over TCP - in the Docker documentation. - +

+ You can connect Portainer to a Docker environment via socket or via TCP. You can find more information about how to expose the Docker API over TCP + in the Docker documentation. +

+ +

+ When using the socket, ensure that you have started the Portainer container with the following Docker flag + -v "/var/run/docker.sock:/var/run/docker.sock" + (on Linux) or + -v \.\pipe\docker_engine:\.\pipe\docker_engine + (on Windows). +

@@ -127,6 +145,21 @@
+
+
+ Important notice +
+
+

+ This will allow you to manage the Kubernetes environment where Portainer is running. +

+ +

+ + In order to manage a remote Kubernetes environment, please use the Agent or Edge agent options. +

+
+
Information @@ -176,8 +209,18 @@
+ +
+
+ + +
+
+ -
+
+ + +

+ + No environment available for management. Please head over the + endpoints view + to add an endpoint. +

+
+
+
Connect Connecting... +
diff --git a/app/portainer/views/init/endpoint/initEndpointController.js b/app/portainer/views/init/endpoint/initEndpointController.js index c5a39a737..235390a23 100644 --- a/app/portainer/views/init/endpoint/initEndpointController.js +++ b/app/portainer/views/init/endpoint/initEndpointController.js @@ -65,6 +65,10 @@ class InitEndpointController { } } + skipEndpointCreation() { + this.$state.go('portainer.home'); + } + /** * DOCKER_LOCAL (1) */