[Fleet] updated agent standalone instructions (#119629)

* updated agent standalone instructions

* updated for kubernetes

* updated public api md

* fix import

* fixed doc link

* removed unused translations

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Julia Bardi 2021-11-25 14:27:56 +01:00 committed by GitHub
parent 5e93d91fae
commit a66551e81b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 151 additions and 119 deletions

View file

@ -252,6 +252,7 @@ readonly links: {
datastreams: string;
datastreamsNamingScheme: string;
installElasticAgent: string;
installElasticAgentStandalone: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;

File diff suppressed because one or more lines are too long

View file

@ -498,6 +498,7 @@ export class DocLinksService {
datastreams: `${FLEET_DOCS}data-streams.html`,
datastreamsNamingScheme: `${FLEET_DOCS}data-streams.html#data-streams-naming-scheme`,
installElasticAgent: `${FLEET_DOCS}install-fleet-managed-elastic-agent.html`,
installElasticAgentStandalone: `${FLEET_DOCS}install-standalone-elastic-agent.html`,
upgradeElasticAgent: `${FLEET_DOCS}upgrade-elastic-agent.html`,
upgradeElasticAgent712lower: `${FLEET_DOCS}upgrade-elastic-agent.html#upgrade-7.12-lower`,
learnMoreBlog: `${ELASTIC_WEBSITE_URL}blog/elastic-agent-and-fleet-make-it-easier-to-integrate-your-systems-with-elastic`,
@ -777,6 +778,7 @@ export interface DocLinksStart {
datastreams: string;
datastreamsNamingScheme: string;
installElasticAgent: string;
installElasticAgentStandalone: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;

View file

@ -734,6 +734,7 @@ export interface DocLinksStart {
datastreams: string;
datastreamsNamingScheme: string;
installElasticAgent: string;
installElasticAgentStandalone: string;
upgradeElasticAgent: string;
upgradeElasticAgent712lower: string;
learnMoreBlog: string;

View file

@ -18,7 +18,8 @@ export const FLEET_SYNTHETICS_PACKAGE = 'synthetics';
export const FLEET_KUBERNETES_PACKAGE = 'kubernetes';
export const KUBERNETES_RUN_INSTRUCTIONS =
'kubectl apply -f elastic-agent-standalone-kubernetes.yaml';
export const STANDALONE_RUN_INSTRUCTIONS = './elastic-agent install';
export const STANDALONE_RUN_INSTRUCTIONS_LINUXMAC = 'sudo ./elastic-agent install';
export const STANDALONE_RUN_INSTRUCTIONS_WINDOWS = '.\\elastic-agent.exe install';
/*
Package rules:

View file

@ -36,9 +36,12 @@ import type { PackagePolicy } from '../../../common';
import {
FLEET_KUBERNETES_PACKAGE,
KUBERNETES_RUN_INSTRUCTIONS,
STANDALONE_RUN_INSTRUCTIONS,
STANDALONE_RUN_INSTRUCTIONS_LINUXMAC,
STANDALONE_RUN_INSTRUCTIONS_WINDOWS,
} from '../../../common';
import { PlatformSelector } from '../enrollment_instructions/manual/platform_selector';
import { DownloadStep, AgentPolicySelectionStep } from './steps';
import type { BaseProps } from './types';
@ -55,8 +58,11 @@ export const StandaloneInstructions = React.memo<Props>(({ agentPolicy, agentPol
'IS_LOADING'
);
const [yaml, setYaml] = useState<string | string>('');
const runInstructions =
isK8s === 'IS_KUBERNETES' ? KUBERNETES_RUN_INSTRUCTIONS : STANDALONE_RUN_INSTRUCTIONS;
const linuxMacCommand =
isK8s === 'IS_KUBERNETES' ? KUBERNETES_RUN_INSTRUCTIONS : STANDALONE_RUN_INSTRUCTIONS_LINUXMAC;
const windowsCommand =
isK8s === 'IS_KUBERNETES' ? KUBERNETES_RUN_INSTRUCTIONS : STANDALONE_RUN_INSTRUCTIONS_WINDOWS;
const { docLinks } = useStartServices();
useEffect(() => {
async function checkifK8s() {
@ -172,19 +178,6 @@ export const StandaloneInstructions = React.memo<Props>(({ agentPolicy, agentPol
/>
);
const applyMsg =
isK8s === 'IS_KUBERNETES' ? (
<FormattedMessage
id="xpack.fleet.agentEnrollment.stepRunAgentDescriptionk8s"
defaultMessage="From the directory where the Kubernetes manifest is downloaded, run the apply command."
/>
) : (
<FormattedMessage
id="xpack.fleet.agentEnrollment.stepRunAgentDescription"
defaultMessage="From the agent directory, run this command to install, enroll and start an Elastic Agent. You can reuse this command to set up agents on more than one host. Requires administrator privileges."
/>
);
const steps = [
!agentPolicy
? AgentPolicySelectionStep({ agentPolicies, setSelectedPolicyId, excludeFleetServer: true })
@ -231,24 +224,13 @@ export const StandaloneInstructions = React.memo<Props>(({ agentPolicy, agentPol
defaultMessage: 'Start the agent',
}),
children: (
<>
<EuiText>
<>{applyMsg}</>
<EuiSpacer size="m" />
<EuiCodeBlock fontSize="m">{runInstructions}</EuiCodeBlock>
<EuiSpacer size="m" />
<EuiCopy textToCopy={runInstructions}>
{(copy) => (
<EuiButton onClick={copy} iconType="copyClipboard">
<FormattedMessage
id="xpack.fleet.agentEnrollment.copyRunInstructionsButton"
defaultMessage="Copy to clipboard"
/>
</EuiButton>
)}
</EuiCopy>
</EuiText>
</>
<PlatformSelector
linuxMacCommand={linuxMacCommand}
windowsCommand={windowsCommand}
installAgentLink={docLinks.links.fleet.installElasticAgentStandalone}
troubleshootLink={docLinks.links.fleet.troubleshooting}
isK8s={isK8s === 'IS_KUBERNETES'}
/>
),
},
{

View file

@ -6,25 +6,15 @@
*/
import React from 'react';
import styled from 'styled-components';
import { EuiText, EuiSpacer, EuiLink, EuiCodeBlock, EuiButtonGroup } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import { useStartServices } from '../../../hooks';
import type { EnrollmentAPIKey } from '../../../types';
import { PLATFORM_OPTIONS, usePlatform, useStartServices } from '../../../hooks';
import type { PLATFORM_TYPE } from '../../../hooks';
import { PlatformSelector } from './platform_selector';
interface Props {
fleetServerHosts: string[];
apiKey: EnrollmentAPIKey;
}
// Otherwise the copy button is over the text
const CommandCode = styled.pre({
overflow: 'scroll',
});
function getfleetServerHostsEnrollArgs(apiKey: EnrollmentAPIKey, fleetServerHosts: string[]) {
return `--url=${fleetServerHosts[0]} --enrollment-token=${apiKey.api_key}`;
}
@ -33,9 +23,7 @@ export const ManualInstructions: React.FunctionComponent<Props> = ({
apiKey,
fleetServerHosts,
}) => {
const { platform, setPlatform } = usePlatform();
const { docLinks } = useStartServices();
const enrollArgs = getfleetServerHostsEnrollArgs(apiKey, fleetServerHosts);
const linuxMacCommand = `sudo ./elastic-agent install ${enrollArgs}`;
@ -43,70 +31,12 @@ export const ManualInstructions: React.FunctionComponent<Props> = ({
const windowsCommand = `.\\elastic-agent.exe install ${enrollArgs}`;
return (
<>
<EuiText>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.descriptionText"
defaultMessage="From the agent directory, run the appropriate command to install, enroll, and start an Elastic Agent. You can reuse these commands to set up agents on more than one host. Requires administrator privileges."
/>
</EuiText>
<EuiSpacer size="l" />
<EuiButtonGroup
options={PLATFORM_OPTIONS}
idSelected={platform}
onChange={(id) => setPlatform(id as PLATFORM_TYPE)}
legend={i18n.translate('xpack.fleet.enrollmentInstructions.platformSelectAriaLabel', {
defaultMessage: 'Platform',
})}
/>
<EuiSpacer size="s" />
{platform === 'linux-mac' && (
<EuiCodeBlock fontSize="m" isCopyable={true} paddingSize="m">
<CommandCode>{linuxMacCommand}</CommandCode>
</EuiCodeBlock>
)}
{platform === 'windows' && (
<EuiCodeBlock fontSize="m" isCopyable={true} paddingSize="m">
<CommandCode>{windowsCommand}</CommandCode>
</EuiCodeBlock>
)}
{platform === 'rpm-deb' && (
<EuiText>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.moreInstructionsText"
defaultMessage="See the {link} for RPM / DEB deploy instructions."
values={{
link: (
<EuiLink target="_blank" external href={docLinks.links.fleet.installElasticAgent}>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.moreInstructionsLink"
defaultMessage="Elastic Agent docs"
/>
</EuiLink>
),
}}
/>
</EuiText>
)}
<EuiSpacer size="l" />
<EuiText>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.troubleshootingText"
defaultMessage="If you are having trouble connecting, see our {link}."
values={{
link: (
<EuiLink target="_blank" external href={docLinks.links.fleet.troubleshooting}>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.troubleshootingLink"
defaultMessage="troubleshooting guide"
/>
</EuiLink>
),
}}
/>
</EuiText>
</>
<PlatformSelector
linuxMacCommand={linuxMacCommand}
windowsCommand={windowsCommand}
installAgentLink={docLinks.links.fleet.installElasticAgent}
troubleshootLink={docLinks.links.fleet.troubleshooting}
isK8s={false}
/>
);
};

View file

@ -0,0 +1,119 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';
import styled from 'styled-components';
import { EuiText, EuiSpacer, EuiLink, EuiCodeBlock, EuiButtonGroup } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { i18n } from '@kbn/i18n';
import type { PLATFORM_TYPE } from '../../../hooks';
import { PLATFORM_OPTIONS, usePlatform } from '../../../hooks';
interface Props {
linuxMacCommand: string;
windowsCommand: string;
installAgentLink: string;
troubleshootLink: string;
isK8s: boolean;
}
// Otherwise the copy button is over the text
const CommandCode = styled.pre({
overflow: 'auto',
});
export const PlatformSelector: React.FunctionComponent<Props> = ({
linuxMacCommand,
windowsCommand,
installAgentLink,
troubleshootLink,
isK8s,
}) => {
const { platform, setPlatform } = usePlatform();
return (
<>
<EuiText>
{isK8s ? (
<FormattedMessage
id="xpack.fleet.agentEnrollment.stepRunAgentDescriptionk8s"
defaultMessage="From the directory where the Kubernetes manifest is downloaded, run the apply command."
/>
) : (
<FormattedMessage
id="xpack.fleet.agentEnrollment.stepRunAgentDescription"
defaultMessage="From the agent directory, run this command to install, enroll and start an Elastic Agent. You can reuse this command to set up agents on more than one host. Requires administrator privileges."
/>
)}
</EuiText>
<EuiSpacer size="l" />
{isK8s ? (
<EuiCodeBlock fontSize="m" isCopyable={true} paddingSize="m">
<CommandCode>{linuxMacCommand}</CommandCode>
</EuiCodeBlock>
) : (
<>
<EuiButtonGroup
options={PLATFORM_OPTIONS}
idSelected={platform}
onChange={(id) => setPlatform(id as PLATFORM_TYPE)}
legend={i18n.translate('xpack.fleet.enrollmentInstructions.platformSelectAriaLabel', {
defaultMessage: 'Platform',
})}
/>
<EuiSpacer size="s" />
{platform === 'linux-mac' && (
<EuiCodeBlock fontSize="m" isCopyable={true} paddingSize="m">
<CommandCode>{linuxMacCommand}</CommandCode>
</EuiCodeBlock>
)}
{platform === 'windows' && (
<EuiCodeBlock fontSize="m" isCopyable={true} paddingSize="m">
<CommandCode>{windowsCommand}</CommandCode>
</EuiCodeBlock>
)}
{platform === 'rpm-deb' && (
<EuiText>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.moreInstructionsText"
defaultMessage="See the {link} for RPM / DEB deploy instructions."
values={{
link: (
<EuiLink target="_blank" external href={installAgentLink}>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.moreInstructionsLink"
defaultMessage="Elastic Agent docs"
/>
</EuiLink>
),
}}
/>
</EuiText>
)}
</>
)}
<EuiSpacer size="l" />
<EuiText>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.troubleshootingText"
defaultMessage="If you are having trouble connecting, see our {link}."
values={{
link: (
<EuiLink target="_blank" external href={troubleshootLink}>
<FormattedMessage
id="xpack.fleet.enrollmentInstructions.troubleshootingLink"
defaultMessage="troubleshooting guide"
/>
</EuiLink>
),
}}
/>
</EuiText>
</>
);
};

View file

@ -10087,7 +10087,6 @@
"xpack.fleet.agentEnrollment.agentsNotInitializedText": "エージェントを登録する前に、{link}。",
"xpack.fleet.agentEnrollment.closeFlyoutButtonLabel": "閉じる",
"xpack.fleet.agentEnrollment.copyPolicyButton": "クリップボードにコピー",
"xpack.fleet.agentEnrollment.copyRunInstructionsButton": "クリップボードにコピー",
"xpack.fleet.agentEnrollment.downloadDescription": "FleetサーバーはElasticエージェントで実行されます。Elasticエージェントダウンロードページでは、Elasticエージェントバイナリと検証署名をダウンロードできます。",
"xpack.fleet.agentEnrollment.downloadLink": "ダウンロードページに移動",
"xpack.fleet.agentEnrollment.downloadPolicyButton": "ポリシーのダウンロード",
@ -10375,7 +10374,6 @@
"xpack.fleet.editPackagePolicy.upgradePageTitleWithPackageName": "{packageName}統合をアップグレード",
"xpack.fleet.enrollemntAPIKeyList.emptyMessage": "登録トークンが見つかりません。",
"xpack.fleet.enrollemntAPIKeyList.loadingTokensMessage": "登録トークンを読み込んでいます...",
"xpack.fleet.enrollmentInstructions.descriptionText": "エージェントのディレクトリから、該当するコマンドを実行し、Elasticエージェントをインストール、登録、起動します。これらのコマンドを再利用すると、複数のホストでエージェントを設定できます。管理者権限が必要です。",
"xpack.fleet.enrollmentInstructions.moreInstructionsLink": "Elastic エージェントドキュメント",
"xpack.fleet.enrollmentInstructions.moreInstructionsText": "RPM/DEB デプロイの手順については、{link}を参照してください。",
"xpack.fleet.enrollmentInstructions.platformButtons.linux": "Linux / macOS",

View file

@ -10178,7 +10178,6 @@
"xpack.fleet.agentEnrollment.agentsNotInitializedText": "注册代理前,请{link}。",
"xpack.fleet.agentEnrollment.closeFlyoutButtonLabel": "关闭",
"xpack.fleet.agentEnrollment.copyPolicyButton": "复制到剪贴板",
"xpack.fleet.agentEnrollment.copyRunInstructionsButton": "复制到剪贴板",
"xpack.fleet.agentEnrollment.downloadDescription": "Fleet 服务器运行在 Elastic 代理上。可从 Elastic 的下载页面下载 Elastic 代理二进制文件及验证签名。",
"xpack.fleet.agentEnrollment.downloadLink": "前往下载页面",
"xpack.fleet.agentEnrollment.downloadPolicyButton": "下载策略",
@ -10476,7 +10475,6 @@
"xpack.fleet.editPackagePolicy.upgradePageTitleWithPackageName": "升级 {packageName} 集成",
"xpack.fleet.enrollemntAPIKeyList.emptyMessage": "未找到任何注册令牌。",
"xpack.fleet.enrollemntAPIKeyList.loadingTokensMessage": "正在加载注册令牌......",
"xpack.fleet.enrollmentInstructions.descriptionText": "从代理目录运行相应命令,以安装、注册并启动 Elastic 代理。您可以重复使用这些命令在多个主机上设置代理。需要管理员权限。",
"xpack.fleet.enrollmentInstructions.moreInstructionsLink": "Elastic 代理文档",
"xpack.fleet.enrollmentInstructions.moreInstructionsText": "有关 RPM/DEB 部署说明,请参见 {link}。",
"xpack.fleet.enrollmentInstructions.platformButtons.linux": "Linux/macOS",