mirror of https://github.com/portainer/portainer
feat(app/endpoint): edge deployment for windows (#4443)
* feat(app/endpoint): edge deployment for windows * feat(app/endpoint): hide instructions for kubernetes when windows is selected * feat(app/endpoint): fix typo * feat(endpoint): minor UI update Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>pull/4578/head
parent
8204d32538
commit
b360936454
|
@ -33,18 +33,26 @@
|
||||||
<p>
|
<p>
|
||||||
The agent will communicate with Portainer via <u>{{ edgeKeyDetails.instanceURL }}</u> and <u>tcp://{{ edgeKeyDetails.tunnelServerAddr }}</u>
|
The agent will communicate with Portainer via <u>{{ edgeKeyDetails.instanceURL }}</u> and <u>tcp://{{ edgeKeyDetails.tunnelServerAddr }}</u>
|
||||||
</p>
|
</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 style="margin-top: 10px;">
|
<div style="margin-top: 10px;">
|
||||||
<uib-tabset active="state.deploymentTab">
|
<uib-tabset active="state.deploymentTab">
|
||||||
<uib-tab index="0" heading="Kubernetes">
|
<uib-tab index="0" ng-if="state.platformType === 'linux'" heading="Kubernetes">
|
||||||
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;"
|
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;"
|
||||||
>curl https://downloads.portainer.io/portainer-edge-agent-setup.sh | sudo bash -s -- {{ randomEdgeID }} {{ endpoint.EdgeKey }}</code
|
>curl https://downloads.portainer.io/portainer-edge-agent-setup.sh | sudo bash -s -- {{ randomEdgeID }} {{ endpoint.EdgeKey }}</code
|
||||||
>
|
>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
<uib-tab index="1" heading="Docker Swarm">
|
<uib-tab index="1" heading="Docker Swarm">
|
||||||
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.swarm }}</code>
|
<code ng-if="state.platformType === 'linux'" style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.linuxSwarm }}</code>
|
||||||
|
<code ng-if="state.platformType === 'windows'" style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.windowsSwarm }}</code>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
<uib-tab index="2" heading="Docker Standalone">
|
<uib-tab index="2" heading="Docker Standalone">
|
||||||
<code style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.standalone }}</code>
|
<code ng-if="state.platformType === 'linux'" style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.linuxStandalone }}</code>
|
||||||
|
<code ng-if="state.platformType === 'windows'" style="display: block; white-space: pre-wrap; padding: 16px 90px;">{{ dockerCommands.windowsStandalone }}</code>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
</uib-tabset>
|
</uib-tabset>
|
||||||
<div style="margin-top: 10px;">
|
<div style="margin-top: 10px;">
|
||||||
|
|
|
@ -29,6 +29,7 @@ angular
|
||||||
kubernetesEndpoint: false,
|
kubernetesEndpoint: false,
|
||||||
agentEndpoint: false,
|
agentEndpoint: false,
|
||||||
edgeEndpoint: false,
|
edgeEndpoint: false,
|
||||||
|
platformType: 'linux',
|
||||||
allowCreate: Authentication.isAdmin(),
|
allowCreate: Authentication.isAdmin(),
|
||||||
availableEdgeAgentCheckinOptions: [
|
availableEdgeAgentCheckinOptions: [
|
||||||
{ key: 'Use default interval', value: 0 },
|
{ key: 'Use default interval', value: 0 },
|
||||||
|
@ -55,15 +56,23 @@ angular
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.copyEdgeAgentDeploymentCommand = function () {
|
$scope.copyEdgeAgentDeploymentCommand = function () {
|
||||||
if ($scope.state.deploymentTab === 2) {
|
if ($scope.state.deploymentTab === 2 && $scope.state.platformType === 'linux') {
|
||||||
clipboard.copyText(
|
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 EDGE_ID=' +
|
'docker run -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes -v /:/host -v portainer_agent_data:/data --restart always -e EDGE=1 -e EDGE_ID=' +
|
||||||
$scope.randomEdgeID +
|
$scope.randomEdgeID +
|
||||||
' -e EDGE_KEY=' +
|
' -e EDGE_KEY=' +
|
||||||
$scope.endpoint.EdgeKey +
|
$scope.endpoint.EdgeKey +
|
||||||
' -e CAP_HOST_MANAGEMENT=1 -v portainer_agent_data:/data --name portainer_edge_agent portainer/agent'
|
' -e CAP_HOST_MANAGEMENT=1 --name portainer_edge_agent portainer/agent'
|
||||||
);
|
);
|
||||||
} else if ($scope.state.deploymentTab === 1) {
|
} else if ($scope.state.deploymentTab === 2 && $scope.state.platformType === 'windows') {
|
||||||
|
clipboard.copyText(
|
||||||
|
'docker run -d --mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine --mount type=bind,src=C:\\ProgramData\\docker\\volumes,dst=C:\\ProgramData\\docker\\volumes --mount type=volume,src=portainer_agent_data,dst=C:\\data -e EDGE=1 -e EDGE_ID=' +
|
||||||
|
$scope.randomEdgeID +
|
||||||
|
' -e EDGE_KEY=' +
|
||||||
|
$scope.endpoint.EdgeKey +
|
||||||
|
' -e CAP_HOST_MANAGEMENT=1 --name portainer_edge_agent portainer/agent'
|
||||||
|
);
|
||||||
|
} else if ($scope.state.deploymentTab === 1 && $scope.state.platformType === 'linux') {
|
||||||
clipboard.copyText(
|
clipboard.copyText(
|
||||||
'docker network create --driver overlay portainer_agent_network; docker service create --name portainer_edge_agent --network portainer_agent_network -e AGENT_CLUSTER_ADDR=tasks.portainer_edge_agent -e EDGE=1 -e EDGE_ID=' +
|
'docker network create --driver overlay portainer_agent_network; docker service create --name portainer_edge_agent --network portainer_agent_network -e AGENT_CLUSTER_ADDR=tasks.portainer_edge_agent -e EDGE=1 -e EDGE_ID=' +
|
||||||
$scope.randomEdgeID +
|
$scope.randomEdgeID +
|
||||||
|
@ -71,6 +80,14 @@ angular
|
||||||
$scope.endpoint.EdgeKey +
|
$scope.endpoint.EdgeKey +
|
||||||
" -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 --mount type=bind,src=//,dst=/host --mount type=volume,src=portainer_agent_data,dst=/data portainer/agent"
|
" -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 --mount type=bind,src=//,dst=/host --mount type=volume,src=portainer_agent_data,dst=/data portainer/agent"
|
||||||
);
|
);
|
||||||
|
} else if ($scope.state.deploymentTab === 1 && $scope.state.platformType === 'windows') {
|
||||||
|
clipboard.copyText(
|
||||||
|
'docker network create --driver overlay portainer_edge_agent_network && docker service create --name portainer_edge_agent --network portainer_edge_agent_network -e AGENT_CLUSTER_ADDR=tasks.portainer_edge_agent -e EDGE=1 -e EDGE_ID=' +
|
||||||
|
$scope.randomEdgeID +
|
||||||
|
' -e EDGE_KEY=' +
|
||||||
|
$scope.endpoint.EdgeKey +
|
||||||
|
' -e CAP_HOST_MANAGEMENT=1 --mode global --constraint node.platform.os==windows --mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine --mount type=bind,src=C:\\ProgramData\\docker\\volumes,dst=C:\\ProgramData\\docker\\volumes --mount type=volume,src=portainer_agent_data,dst=C:\\data portainer/agent'
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
clipboard.copyText('curl https://downloads.portainer.io/portainer-edge-agent-setup.sh | bash -s -- ' + $scope.randomEdgeID + ' ' + $scope.endpoint.EdgeKey);
|
clipboard.copyText('curl https://downloads.portainer.io/portainer-edge-agent-setup.sh | bash -s -- ' + $scope.randomEdgeID + ' ' + $scope.endpoint.EdgeKey);
|
||||||
}
|
}
|
||||||
|
@ -206,8 +223,10 @@ angular
|
||||||
$scope.edgeKeyDetails = decodeEdgeKey(endpoint.EdgeKey);
|
$scope.edgeKeyDetails = decodeEdgeKey(endpoint.EdgeKey);
|
||||||
$scope.randomEdgeID = uuidv4();
|
$scope.randomEdgeID = uuidv4();
|
||||||
$scope.dockerCommands = {
|
$scope.dockerCommands = {
|
||||||
standalone: buildStandaloneCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
linuxStandalone: buildLinuxStandaloneCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
||||||
swarm: buildSwarmCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
windowsStandalone: buildWindowsStandaloneCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
||||||
|
linuxSwarm: buildLinuxSwarmCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
||||||
|
windowsSwarm: buildWindowsSwarmCommand($scope.randomEdgeID, endpoint.EdgeKey),
|
||||||
};
|
};
|
||||||
|
|
||||||
const settings = data.settings;
|
const settings = data.settings;
|
||||||
|
@ -223,21 +242,36 @@ angular
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildStandaloneCommand(edgeId, edgeKey) {
|
function buildLinuxStandaloneCommand(edgeId, edgeKey) {
|
||||||
return `docker run -d -v /var/run/docker.sock:/var/run/docker.sock \\
|
return `docker run -d \\
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \\
|
||||||
-v /var/lib/docker/volumes:/var/lib/docker/volumes \\
|
-v /var/lib/docker/volumes:/var/lib/docker/volumes \\
|
||||||
-v /:/host \\
|
-v /:/host \\
|
||||||
|
-v portainer_agent_data:/data \\
|
||||||
|
--restart always \\
|
||||||
|
-e EDGE=1 \\
|
||||||
|
-e EDGE_ID=${edgeId} \\
|
||||||
|
-e EDGE_KEY=${edgeKey} \\
|
||||||
|
-e CAP_HOST_MANAGEMENT=1 \\
|
||||||
|
--name portainer_edge_agent \\localhost
|
||||||
|
portainer/agent`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildWindowsStandaloneCommand(edgeId, edgeKey) {
|
||||||
|
return `docker run -d \\
|
||||||
|
--mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine \\
|
||||||
|
--mount type=bind,src=C:\\ProgramData\\docker\\volumes,dst=C:\\ProgramData\\docker\\volumes \\
|
||||||
|
--mount type=volume,src=portainer_agent_data,dst=C:\\data \\
|
||||||
--restart always \\
|
--restart always \\
|
||||||
-e EDGE=1 \\
|
-e EDGE=1 \\
|
||||||
-e EDGE_ID=${edgeId} \\
|
-e EDGE_ID=${edgeId} \\
|
||||||
-e EDGE_KEY=${edgeKey} \\
|
-e EDGE_KEY=${edgeKey} \\
|
||||||
-e CAP_HOST_MANAGEMENT=1 \\
|
-e CAP_HOST_MANAGEMENT=1 \\
|
||||||
-v portainer_agent_data:/data \\
|
|
||||||
--name portainer_edge_agent \\
|
--name portainer_edge_agent \\
|
||||||
portainer/agent`;
|
portainer/agent`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildSwarmCommand(edgeId, edgeKey) {
|
function buildLinuxSwarmCommand(edgeId, edgeKey) {
|
||||||
return `docker network create \\
|
return `docker network create \\
|
||||||
--driver overlay \\
|
--driver overlay \\
|
||||||
portainer_agent_network;
|
portainer_agent_network;
|
||||||
|
@ -259,5 +293,25 @@ docker service create \\
|
||||||
portainer/agent`;
|
portainer/agent`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildWindowsSwarmCommand(edgeId, edgeKey) {
|
||||||
|
return `docker network create \\
|
||||||
|
--driver overlay \\
|
||||||
|
portainer_edge_agent_network && \\
|
||||||
|
docker service create \\
|
||||||
|
--name portainer_edge_agent \\
|
||||||
|
--network portainer_edge_agent_network \\
|
||||||
|
-e AGENT_CLUSTER_ADDR=tasks.portainer_edge_agent \\
|
||||||
|
-e EDGE=1 \\
|
||||||
|
-e EDGE_ID=${edgeId} \\
|
||||||
|
-e EDGE_KEY=${edgeKey} \\
|
||||||
|
-e CAP_HOST_MANAGEMENT=1 \\
|
||||||
|
--mode global \\
|
||||||
|
--constraint node.platform.os==windows \\
|
||||||
|
--mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine \\
|
||||||
|
--mount type=bind,src=C:\\ProgramData\\docker\\volumes,dst=C:\\ProgramData\\docker\\volumes \\
|
||||||
|
--mount type=volume,src=portainer_agent_data,dst=C:\\data \\
|
||||||
|
portainer/agent`;
|
||||||
|
}
|
||||||
|
|
||||||
initView();
|
initView();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue