mirror of https://github.com/portainer/portainer
fix(wizard) EE-2053 Add Docker Standalone option to agent install instructions (#7589)
parent
4d123895ea
commit
47f2490059
|
@ -4,7 +4,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
margin-left: 10px;
|
margin-left: 50px;
|
||||||
}
|
}
|
||||||
.step-wrapper {
|
.step-wrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -12,7 +12,11 @@ interface Props {
|
||||||
createEdgeDevice?: boolean;
|
createEdgeDevice?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasEdge: EnvironmentSelectorValue[] = ['docker', 'kubernetes'];
|
const hasEdge: EnvironmentSelectorValue[] = [
|
||||||
|
'dockerStandalone',
|
||||||
|
'dockerSwarm',
|
||||||
|
'kubernetes',
|
||||||
|
];
|
||||||
|
|
||||||
export function EnvironmentSelector({
|
export function EnvironmentSelector({
|
||||||
value,
|
value,
|
||||||
|
|
|
@ -4,11 +4,17 @@ import KaaSIcon from './kaas-icon.svg?c';
|
||||||
|
|
||||||
export const environmentTypes = [
|
export const environmentTypes = [
|
||||||
{
|
{
|
||||||
id: 'docker',
|
id: 'dockerStandalone',
|
||||||
title: 'Docker',
|
title: 'Docker Standalone',
|
||||||
icon: 'fab fa-docker',
|
icon: 'fab fa-docker',
|
||||||
description:
|
description: 'Connect to Docker Standalone via URL/IP, API or Socket',
|
||||||
'Connect to Docker Standalone / Swarm via URL/IP, API or Socket',
|
featureId: undefined,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dockerSwarm',
|
||||||
|
title: 'Docker Swarm',
|
||||||
|
icon: 'fab fa-docker',
|
||||||
|
description: 'Connect to Docker Swarm via URL/IP, API or Socket',
|
||||||
featureId: undefined,
|
featureId: undefined,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,8 @@ export function EnvironmentCreationView() {
|
||||||
isLastStep,
|
isLastStep,
|
||||||
} = useStepper(steps, handleFinish);
|
} = useStepper(steps, handleFinish);
|
||||||
|
|
||||||
|
const isDockerStandalone = currentStep.id === 'dockerStandalone';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageHeader
|
<PageHeader
|
||||||
|
@ -75,7 +77,10 @@ export function EnvironmentCreationView() {
|
||||||
title={`Connect to your ${currentStep.title}
|
title={`Connect to your ${currentStep.title}
|
||||||
environment`}
|
environment`}
|
||||||
>
|
>
|
||||||
<Component onCreate={handleCreateEnvironment} />
|
<Component
|
||||||
|
onCreate={handleCreateEnvironment}
|
||||||
|
isDockerStandalone={isDockerStandalone}
|
||||||
|
/>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
@ -178,7 +183,8 @@ function useStepper(
|
||||||
|
|
||||||
function getComponent(id: EnvironmentSelectorValue) {
|
function getComponent(id: EnvironmentSelectorValue) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'docker':
|
case 'dockerStandalone':
|
||||||
|
case 'dockerSwarm':
|
||||||
return WizardDocker;
|
return WizardDocker;
|
||||||
case 'aci':
|
case 'aci':
|
||||||
return WizardAzure;
|
return WizardAzure;
|
||||||
|
|
|
@ -6,12 +6,13 @@ import { DeploymentScripts } from './DeploymentScripts';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onCreate(environment: Environment): void;
|
onCreate(environment: Environment): void;
|
||||||
|
isDockerStandalone?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AgentTab({ onCreate }: Props) {
|
export function AgentTab({ onCreate, isDockerStandalone }: Props) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<DeploymentScripts />
|
<DeploymentScripts isDockerStandalone={isDockerStandalone} />
|
||||||
|
|
||||||
<div className="mt-5">
|
<div className="mt-5">
|
||||||
<AgentForm onCreate={onCreate} />
|
<AgentForm onCreate={onCreate} />
|
||||||
|
|
|
@ -6,20 +6,40 @@ import { CopyButton } from '@@/buttons/CopyButton';
|
||||||
import { Code } from '@@/Code';
|
import { Code } from '@@/Code';
|
||||||
import { NavTabs } from '@@/NavTabs';
|
import { NavTabs } from '@@/NavTabs';
|
||||||
|
|
||||||
const deployments = [
|
const deploymentsStandalone = [
|
||||||
{
|
{
|
||||||
id: 'linux',
|
id: 'linux',
|
||||||
label: 'Linux',
|
label: 'Linux & Windows WSL',
|
||||||
command: linuxCommand,
|
command: linuxStandaloneCommand,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'win',
|
id: 'win',
|
||||||
label: 'Windows',
|
label: 'Windows WCS',
|
||||||
command: winCommand,
|
command: winStandaloneCommand,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function DeploymentScripts() {
|
const deploymentsSwarm = [
|
||||||
|
{
|
||||||
|
id: 'linux',
|
||||||
|
label: 'Linux & Windows WSL',
|
||||||
|
command: linuxSwarmCommand,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'win',
|
||||||
|
label: 'Windows WCS',
|
||||||
|
command: winSwarmCommand,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
isDockerStandalone?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DeploymentScripts({ isDockerStandalone }: Props) {
|
||||||
|
const deployments = isDockerStandalone
|
||||||
|
? deploymentsStandalone
|
||||||
|
: deploymentsSwarm;
|
||||||
const [deployType, setDeployType] = useState(deployments[0].id);
|
const [deployType, setDeployType] = useState(deployments[0].id);
|
||||||
|
|
||||||
const agentDetailsQuery = useAgentDetails();
|
const agentDetailsQuery = useAgentDetails();
|
||||||
|
@ -56,9 +76,6 @@ interface DeployCodeProps {
|
||||||
function DeployCode({ code }: DeployCodeProps) {
|
function DeployCode({ code }: DeployCodeProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span className="text-muted small">
|
|
||||||
CLI script for installing agent on your environment with Docker Swarm:
|
|
||||||
</span>
|
|
||||||
<div className="code-script">
|
<div className="code-script">
|
||||||
<Code>{code}</Code>
|
<Code>{code}</Code>
|
||||||
</div>
|
</div>
|
||||||
|
@ -67,7 +84,21 @@ function DeployCode({ code }: DeployCodeProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function linuxCommand(agentVersion: string, agentSecret: string) {
|
function linuxStandaloneCommand(agentVersion: string, agentSecret: string) {
|
||||||
|
const secret =
|
||||||
|
agentSecret === '' ? '' : `\\\n -e AGENT_SECRET=${agentSecret} `;
|
||||||
|
|
||||||
|
return `docker run -d \\
|
||||||
|
-p 9001:9001 ${secret}\\
|
||||||
|
--name portainer_agent \\
|
||||||
|
--restart=always \\
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \\
|
||||||
|
-v /var/lib/docker/volumes:/var/lib/docker/volumes \\
|
||||||
|
portainer/agent:${agentVersion}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function linuxSwarmCommand(agentVersion: string, agentSecret: string) {
|
||||||
const secret =
|
const secret =
|
||||||
agentSecret === '' ? '' : `\\\n -e AGENT_SECRET=${agentSecret} `;
|
agentSecret === '' ? '' : `\\\n -e AGENT_SECRET=${agentSecret} `;
|
||||||
|
|
||||||
|
@ -87,7 +118,22 @@ docker service create \\
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function winCommand(agentVersion: string, agentSecret: string) {
|
function winStandaloneCommand(agentVersion: string, agentSecret: string) {
|
||||||
|
const secret =
|
||||||
|
agentSecret === '' ? '' : `\\\n -e AGENT_SECRET=${agentSecret} `;
|
||||||
|
|
||||||
|
return `docker run -d \\
|
||||||
|
-p 9001:9001 ${secret}\\
|
||||||
|
--name portainer_agent \\
|
||||||
|
--restart=always \\
|
||||||
|
-v C:\\:C:\\host \\
|
||||||
|
-v C:\\ProgramData\\docker\\volumes:C:\\ProgramData\\docker\\volumes \\
|
||||||
|
-v \\\\.\\pipe\\docker_engine:\\\\.\\pipe\\docker_engine \\
|
||||||
|
portainer/agent:${agentVersion}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function winSwarmCommand(agentVersion: string, agentSecret: string) {
|
||||||
const secret =
|
const secret =
|
||||||
agentSecret === '' ? '' : `\\\n -e AGENT_SECRET=${agentSecret} `;
|
agentSecret === '' ? '' : `\\\n -e AGENT_SECRET=${agentSecret} `;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { SocketTab } from './SocketTab';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onCreate(environment: Environment, analytics: AnalyticsStateKey): void;
|
onCreate(environment: Environment, analytics: AnalyticsStateKey): void;
|
||||||
|
isDockerStandalone?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: BoxSelectorOption<
|
const defaultOptions: BoxSelectorOption<
|
||||||
|
@ -51,7 +52,7 @@ const defaultOptions: BoxSelectorOption<
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function WizardDocker({ onCreate }: Props) {
|
export function WizardDocker({ onCreate, isDockerStandalone }: Props) {
|
||||||
const options = useFilterEdgeOptionsIfNeeded(defaultOptions, 'edgeAgent');
|
const options = useFilterEdgeOptionsIfNeeded(defaultOptions, 'edgeAgent');
|
||||||
|
|
||||||
const [creationType, setCreationType] = useState(options[0].value);
|
const [creationType, setCreationType] = useState(options[0].value);
|
||||||
|
@ -77,6 +78,7 @@ export function WizardDocker({ onCreate }: Props) {
|
||||||
return (
|
return (
|
||||||
<AgentTab
|
<AgentTab
|
||||||
onCreate={(environment) => onCreate(environment, 'dockerAgent')}
|
onCreate={(environment) => onCreate(environment, 'dockerAgent')}
|
||||||
|
isDockerStandalone={isDockerStandalone}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case 'api':
|
case 'api':
|
||||||
|
|
Loading…
Reference in New Issue