Skip to content

Commit

Permalink
[Fleet] add support for fleet server urls (#94364) (#95574)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Chaulet <[email protected]>
  • Loading branch information
kibanamachine and nchaulet authored Mar 26, 2021
1 parent dcc8d30 commit cb38b0b
Show file tree
Hide file tree
Showing 17 changed files with 702 additions and 289 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/fleet/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export interface FleetConfigType {
host?: string;
ca_sha256?: string;
};
fleet_server?: {
hosts?: string[];
};
agentPolicyRolloutRateLimitIntervalMs: number;
agentPolicyRolloutRateLimitRequestPerInterval: number;
};
Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/fleet/common/types/models/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ export interface FullAgentPolicy {
[key: string]: any;
};
};
fleet?: {
kibana: FullAgentPolicyKibanaConfig;
};
fleet?:
| {
hosts: string[];
}
| {
kibana: FullAgentPolicyKibanaConfig;
};
inputs: FullAgentPolicyInput[];
revision?: number;
agent?: {
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/common/types/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import type { SavedObjectAttributes } from 'src/core/public';

export interface BaseSettings {
has_seen_add_data_notice?: boolean;
fleet_server_hosts: string[];
// TODO remove as part of https://github.com/elastic/kibana/issues/94303
kibana_urls: string[];
kibana_ca_sha256?: string;
has_seen_add_data_notice?: boolean;
}

export interface Settings extends BaseSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import type { EnrollmentAPIKey } from '../../../types';

interface Props {
fleetServerHosts: string[];
kibanaUrl: string;
apiKey: EnrollmentAPIKey;
kibanaCASha256?: string;
Expand All @@ -23,14 +24,32 @@ const CommandCode = styled.pre({
overflow: 'scroll',
});

function getfleetServerHostsEnrollArgs(apiKey: EnrollmentAPIKey, fleetServerHosts: string[]) {
return `--url=${fleetServerHosts[0]} --enrollment-token=${apiKey.api_key}`;
}

function getKibanaUrlEnrollArgs(
apiKey: EnrollmentAPIKey,
kibanaUrl: string,
kibanaCASha256?: string
) {
return `--kibana-url=${kibanaUrl} --enrollment-token=${apiKey.api_key}${
kibanaCASha256 ? ` --ca_sha256=${kibanaCASha256}` : ''
}`;
}

export const ManualInstructions: React.FunctionComponent<Props> = ({
kibanaUrl,
apiKey,
kibanaCASha256,
fleetServerHosts,
}) => {
const enrollArgs = `--kibana-url=${kibanaUrl} --enrollment-token=${apiKey.api_key}${
kibanaCASha256 ? ` --ca_sha256=${kibanaCASha256}` : ''
}`;
const fleetServerHostsNotEmpty = fleetServerHosts.length > 0;

const enrollArgs = fleetServerHostsNotEmpty
? getfleetServerHostsEnrollArgs(apiKey, fleetServerHosts)
: // TODO remove as part of https://github.com/elastic/kibana/issues/94303
getKibanaUrlEnrollArgs(apiKey, kibanaUrl, kibanaCASha256);

const linuxMacCommand = `./elastic-agent install -f ${enrollArgs}`;

Expand Down

This file was deleted.

Loading

0 comments on commit cb38b0b

Please sign in to comment.