mirror of https://github.com/portainer/portainer
feat(frontend) auto generate agent version EE-1266 (#5794)
Co-authored-by: Simon Meng <simon.meng@portainer.io>pull/5553/head
parent
e4fd43e4fc
commit
0cb5656db6
|
@ -1,4 +1,5 @@
|
||||||
import { PortainerEndpointCreationTypes, PortainerEndpointTypes } from 'Portainer/models/endpoint/models';
|
import { PortainerEndpointCreationTypes, PortainerEndpointTypes } from 'Portainer/models/endpoint/models';
|
||||||
|
import { getAgentShortVersion } from 'Portainer/views/endpoints/helpers';
|
||||||
import { EndpointSecurityFormData } from '../../../components/endpointSecurity/porEndpointSecurityModel';
|
import { EndpointSecurityFormData } from '../../../components/endpointSecurity/porEndpointSecurityModel';
|
||||||
|
|
||||||
angular
|
angular
|
||||||
|
@ -16,7 +17,8 @@ angular
|
||||||
TagService,
|
TagService,
|
||||||
SettingsService,
|
SettingsService,
|
||||||
Notifications,
|
Notifications,
|
||||||
Authentication
|
Authentication,
|
||||||
|
StateManager
|
||||||
) {
|
) {
|
||||||
$scope.state = {
|
$scope.state = {
|
||||||
EnvironmentType: 'agent',
|
EnvironmentType: 'agent',
|
||||||
|
@ -44,11 +46,14 @@ angular
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const agentVersion = StateManager.getState().application.version;
|
||||||
|
const agentShortVersion = getAgentShortVersion(agentVersion);
|
||||||
|
|
||||||
const deployCommands = {
|
const deployCommands = {
|
||||||
kubeLoadBalancer: `curl -L https://downloads.portainer.io/portainer-agent-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml`,
|
kubeLoadBalancer: `curl -L https://downloads.portainer.io/portainer-agent-ce${agentShortVersion}-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml`,
|
||||||
kubeNodePort: `curl -L https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml`,
|
kubeNodePort: `curl -L https://downloads.portainer.io/portainer-agent-ce${agentShortVersion}-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml`,
|
||||||
agentLinux: `curl -L https://downloads.portainer.io/agent-stack.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent`,
|
agentLinux: `curl -L https://downloads.portainer.io/agent-stack-ce${agentShortVersion}.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent`,
|
||||||
agentWindows: `curl -L https://downloads.portainer.io/agent-stack-windows.yml -o agent-stack-windows.yml && docker stack deploy --compose-file=agent-stack-windows.yml portainer-agent`,
|
agentWindows: `curl -L https://downloads.portainer.io/agent-stack-ce${agentShortVersion}-windows.yml -o agent-stack-windows.yml && docker stack deploy --compose-file=agent-stack-windows.yml portainer-agent`,
|
||||||
};
|
};
|
||||||
$scope.deployCommands = deployCommands;
|
$scope.deployCommands = deployCommands;
|
||||||
|
|
||||||
|
|
|
@ -62,17 +62,17 @@
|
||||||
<uib-tabset active="state.deploymentTab">
|
<uib-tabset active="state.deploymentTab">
|
||||||
<uib-tab index="'kubernetes'" heading="Kubernetes" ng-if="state.platformType === 'linux'">
|
<uib-tab index="'kubernetes'" heading="Kubernetes" ng-if="state.platformType === 'linux'">
|
||||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px;">
|
<code style="display: block; white-space: pre-wrap; padding: 16px 45px;">
|
||||||
{{ dockerCommands[state.deploymentTab][state.platformType](randomEdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts) }}
|
{{ dockerCommands[state.deploymentTab][state.platformType](agentVersion, agentShortVersion, randomEdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts) }}
|
||||||
</code>
|
</code>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
<uib-tab index="'swarm'" heading="Docker Swarm">
|
<uib-tab index="'swarm'" heading="Docker Swarm">
|
||||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px;">
|
<code style="display: block; white-space: pre-wrap; padding: 16px 45px;">
|
||||||
{{ dockerCommands[state.deploymentTab][state.platformType](randomEdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts) }}
|
{{ dockerCommands[state.deploymentTab][state.platformType](agentVersion, agentShortVersion, randomEdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts) }}
|
||||||
</code>
|
</code>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
<uib-tab index="'standalone'" heading="Docker Standalone">
|
<uib-tab index="'standalone'" heading="Docker Standalone">
|
||||||
<code style="display: block; white-space: pre-wrap; padding: 16px 45px;">
|
<code style="display: block; white-space: pre-wrap; padding: 16px 45px;">
|
||||||
{{ dockerCommands[state.deploymentTab][state.platformType](randomEdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts) }}
|
{{ dockerCommands[state.deploymentTab][state.platformType](agentVersion, agentShortVersion, randomEdgeID, endpoint.EdgeKey, state.allowSelfSignedCerts) }}
|
||||||
</code>
|
</code>
|
||||||
</uib-tab>
|
</uib-tab>
|
||||||
</uib-tabset>
|
</uib-tabset>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import uuidv4 from 'uuid/v4';
|
||||||
|
|
||||||
import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
|
import { PortainerEndpointTypes } from '@/portainer/models/endpoint/models';
|
||||||
import { EndpointSecurityFormData } from '@/portainer/components/endpointSecurity/porEndpointSecurityModel';
|
import { EndpointSecurityFormData } from '@/portainer/components/endpointSecurity/porEndpointSecurityModel';
|
||||||
|
import { getAgentShortVersion } from 'Portainer/views/endpoints/helpers';
|
||||||
|
|
||||||
angular.module('portainer.app').controller('EndpointController', EndpointController);
|
angular.module('portainer.app').controller('EndpointController', EndpointController);
|
||||||
|
|
||||||
|
@ -22,7 +23,8 @@ function EndpointController(
|
||||||
Notifications,
|
Notifications,
|
||||||
Authentication,
|
Authentication,
|
||||||
SettingsService,
|
SettingsService,
|
||||||
ModalService
|
ModalService,
|
||||||
|
StateManager
|
||||||
) {
|
) {
|
||||||
const DEPLOYMENT_TABS = {
|
const DEPLOYMENT_TABS = {
|
||||||
SWARM: 'swarm',
|
SWARM: 'swarm',
|
||||||
|
@ -66,6 +68,9 @@ function EndpointController(
|
||||||
allowSelfSignedCerts: true,
|
allowSelfSignedCerts: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.agentVersion = StateManager.getState().application.version;
|
||||||
|
$scope.agentShortVersion = getAgentShortVersion($scope.agentVersion);
|
||||||
|
|
||||||
$scope.dockerCommands = {
|
$scope.dockerCommands = {
|
||||||
[DEPLOYMENT_TABS.STANDALONE]: {
|
[DEPLOYMENT_TABS.STANDALONE]: {
|
||||||
[PLATFORM_TYPES.LINUX]: buildLinuxStandaloneCommand,
|
[PLATFORM_TYPES.LINUX]: buildLinuxStandaloneCommand,
|
||||||
|
@ -87,7 +92,13 @@ function EndpointController(
|
||||||
|
|
||||||
$scope.copyEdgeAgentDeploymentCommand = copyEdgeAgentDeploymentCommand;
|
$scope.copyEdgeAgentDeploymentCommand = copyEdgeAgentDeploymentCommand;
|
||||||
function copyEdgeAgentDeploymentCommand() {
|
function copyEdgeAgentDeploymentCommand() {
|
||||||
const command = $scope.dockerCommands[$scope.state.deploymentTab][$scope.state.platformType]($scope.randomEdgeID, $scope.endpoint.EdgeKey, $scope.state.allowSelfSignedCerts);
|
const command = $scope.dockerCommands[$scope.state.deploymentTab][$scope.state.platformType](
|
||||||
|
$scope.agentVersion,
|
||||||
|
$scope.agentShortVersion,
|
||||||
|
$scope.randomEdgeID,
|
||||||
|
$scope.endpoint.EdgeKey,
|
||||||
|
$scope.state.allowSelfSignedCerts
|
||||||
|
);
|
||||||
clipboard.copyText(command.trim());
|
clipboard.copyText(command.trim());
|
||||||
$('#copyNotificationDeploymentCommand').show().fadeOut(2500);
|
$('#copyNotificationDeploymentCommand').show().fadeOut(2500);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +280,7 @@ function EndpointController(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildLinuxStandaloneCommand(edgeId, edgeKey, allowSelfSignedCerts) {
|
function buildLinuxStandaloneCommand(agentVersion, agentShortVersion, edgeId, edgeKey, allowSelfSignedCerts) {
|
||||||
return `
|
return `
|
||||||
docker run -d \\
|
docker run -d \\
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \\
|
-v /var/run/docker.sock:/var/run/docker.sock \\
|
||||||
|
@ -283,10 +294,10 @@ docker run -d \\
|
||||||
-e CAP_HOST_MANAGEMENT=1 \\
|
-e CAP_HOST_MANAGEMENT=1 \\
|
||||||
-e EDGE_INSECURE_POLL=${allowSelfSignedCerts ? 1 : 0} \\
|
-e EDGE_INSECURE_POLL=${allowSelfSignedCerts ? 1 : 0} \\
|
||||||
--name portainer_edge_agent \\
|
--name portainer_edge_agent \\
|
||||||
portainer/agent`;
|
portainer/agent:${agentVersion}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildWindowsStandaloneCommand(edgeId, edgeKey, allowSelfSignedCerts) {
|
function buildWindowsStandaloneCommand(agentVersion, agentShortVersion, edgeId, edgeKey, allowSelfSignedCerts) {
|
||||||
return `
|
return `
|
||||||
docker run -d \\
|
docker run -d \\
|
||||||
--mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine \\
|
--mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine \\
|
||||||
|
@ -299,10 +310,10 @@ docker run -d \\
|
||||||
-e CAP_HOST_MANAGEMENT=1 \\
|
-e CAP_HOST_MANAGEMENT=1 \\
|
||||||
-e EDGE_INSECURE_POLL=${allowSelfSignedCerts ? 1 : 0} \\
|
-e EDGE_INSECURE_POLL=${allowSelfSignedCerts ? 1 : 0} \\
|
||||||
--name portainer_edge_agent \\
|
--name portainer_edge_agent \\
|
||||||
portainer/agent`;
|
portainer/agent:${agentVersion}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildLinuxSwarmCommand(edgeId, edgeKey, allowSelfSignedCerts) {
|
function buildLinuxSwarmCommand(agentVersion, agentShortVersion, edgeId, edgeKey, allowSelfSignedCerts) {
|
||||||
return `
|
return `
|
||||||
docker network create \\
|
docker network create \\
|
||||||
--driver overlay \\
|
--driver overlay \\
|
||||||
|
@ -323,10 +334,10 @@ docker service create \\
|
||||||
--mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volumes \\
|
--mount type=bind,src=//var/lib/docker/volumes,dst=/var/lib/docker/volumes \\
|
||||||
--mount type=bind,src=//,dst=/host \\
|
--mount type=bind,src=//,dst=/host \\
|
||||||
--mount type=volume,src=portainer_agent_data,dst=/data \\
|
--mount type=volume,src=portainer_agent_data,dst=/data \\
|
||||||
portainer/agent`;
|
portainer/agent:${agentVersion}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildWindowsSwarmCommand(edgeId, edgeKey, allowSelfSignedCerts) {
|
function buildWindowsSwarmCommand(agentVersion, agentShortVersion, edgeId, edgeKey, allowSelfSignedCerts) {
|
||||||
return `
|
return `
|
||||||
docker network create \\
|
docker network create \\
|
||||||
--driver overlay \\
|
--driver overlay \\
|
||||||
|
@ -345,12 +356,12 @@ docker service create \\
|
||||||
--mount type=npipe,src=\\\\.\\pipe\\docker_engine,dst=\\\\.\\pipe\\docker_engine \\
|
--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=bind,src=C:\\ProgramData\\docker\\volumes,dst=C:\\ProgramData\\docker\\volumes \\
|
||||||
--mount type=volume,src=portainer_agent_data,dst=C:\\data \\
|
--mount type=volume,src=portainer_agent_data,dst=C:\\data \\
|
||||||
portainer/agent`;
|
portainer/agent:${agentVersion}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildKubernetesCommand(edgeId, edgeKey, allowSelfSignedCerts) {
|
function buildKubernetesCommand(agentVersion, agentShortVersion, edgeId, edgeKey, allowSelfSignedCerts) {
|
||||||
return `
|
return `
|
||||||
curl https://downloads.portainer.io/portainer-ce29-edge-agent-setup.sh | bash -s -- ${edgeId} ${edgeKey} ${allowSelfSignedCerts ? '1' : ''}
|
curl https://downloads.portainer.io/portainer-ce${agentShortVersion}-edge-agent-setup.sh | bash -s -- ${edgeId} ${edgeKey} ${allowSelfSignedCerts ? '1' : ''}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
export function getAgentShortVersion(agentVersion) {
|
||||||
|
const numbers = agentVersion.split('.');
|
||||||
|
return numbers[0] + numbers[1];
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
import { PortainerEndpointCreationTypes } from 'Portainer/models/endpoint/models';
|
import { PortainerEndpointCreationTypes } from 'Portainer/models/endpoint/models';
|
||||||
import { buildOption } from '@/portainer/components/box-selector';
|
import { buildOption } from '@/portainer/components/box-selector';
|
||||||
import { EndpointSecurityFormData } from 'Portainer/components/endpointSecurity/porEndpointSecurityModel';
|
import { EndpointSecurityFormData } from 'Portainer/components/endpointSecurity/porEndpointSecurityModel';
|
||||||
|
import { getAgentShortVersion } from 'Portainer/views/endpoints/helpers';
|
||||||
|
|
||||||
export default class WizardDockerController {
|
export default class WizardDockerController {
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
|
@ -200,9 +201,12 @@ export default class WizardDockerController {
|
||||||
securityFormData: new EndpointSecurityFormData(),
|
securityFormData: new EndpointSecurityFormData(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const agentVersion = this.StateManager.getState().application.version;
|
||||||
|
const agentShortVersion = getAgentShortVersion(agentVersion);
|
||||||
|
|
||||||
this.command = {
|
this.command = {
|
||||||
linuxCommand: `curl -L https://downloads.portainer.io/agent-stack.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent `,
|
linuxCommand: `curl -L https://downloads.portainer.io/agent-stack-ce${agentShortVersion}.yml -o agent-stack.yml && docker stack deploy --compose-file=agent-stack.yml portainer-agent `,
|
||||||
winCommand: `curl -L https://downloads.portainer.io/agent-stack-windows.yml -o agent-stack-windows.yml && docker stack deploy --compose-file=agent-stack-windows.yml portainer-agent `,
|
winCommand: `curl -L https://downloads.portainer.io/agent-stack-ce${agentShortVersion}-windows.yml -o agent-stack-windows.yml && docker stack deploy --compose-file=agent-stack-windows.yml portainer-agent `,
|
||||||
linuxSocket: `-v "/var/run/docker.sock:/var/run/docker.sock" `,
|
linuxSocket: `-v "/var/run/docker.sock:/var/run/docker.sock" `,
|
||||||
winSocket: `-v \.\pipe\docker_engine:\.\pipe\docker_engine `,
|
winSocket: `-v \.\pipe\docker_engine:\.\pipe\docker_engine `,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { PortainerEndpointCreationTypes } from 'Portainer/models/endpoint/models';
|
import { PortainerEndpointCreationTypes } from 'Portainer/models/endpoint/models';
|
||||||
//import { getAgentShortVersion } from 'Portainer/views/endpoints/helpers';
|
//import { getAgentShortVersion } from 'Portainer/views/endpoints/helpers';
|
||||||
import { buildOption } from '@/portainer/components/box-selector';
|
import { buildOption } from '@/portainer/components/box-selector';
|
||||||
|
import { getAgentShortVersion } from 'Portainer/views/endpoints/helpers';
|
||||||
|
|
||||||
export default class WizardKubernetesController {
|
export default class WizardKubernetesController {
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
|
@ -96,9 +97,12 @@ export default class WizardKubernetesController {
|
||||||
availableOptions: [buildOption('Agent', 'fa fa-bolt', 'Agent', '', 'agent')],
|
availableOptions: [buildOption('Agent', 'fa fa-bolt', 'Agent', '', 'agent')],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const agentVersion = this.StateManager.getState().application.version;
|
||||||
|
const agentShortVersion = getAgentShortVersion(agentVersion);
|
||||||
|
|
||||||
this.command = {
|
this.command = {
|
||||||
loadBalancer: `curl -L https://downloads.portainer.io/portainer-agent-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml `,
|
loadBalancer: `curl -L https://downloads.portainer.io/portainer-agent-ce${agentShortVersion}-k8s-lb.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml `,
|
||||||
nodePort: `curl -L https://downloads.portainer.io/portainer-agent-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml `,
|
nodePort: `curl -L https://downloads.portainer.io/portainer-agent-ce${agentShortVersion}-k8s-nodeport.yaml -o portainer-agent-k8s.yaml; kubectl apply -f portainer-agent-k8s.yaml `,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue