Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: agent install instructions #2292

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/Agents/Add/AddAgentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function AgentForm({
name: agent?.name ?? "",
properties: agent?.properties ?? {},
kubernetes: {
interval: "30m",
schedule: "30m",
enabled: false
},
pushTelemetry: {
Expand Down Expand Up @@ -173,7 +173,7 @@ export default function AgentForm({
{ label: "12h", value: "12h" },
{ label: "24h", value: "24h" }
]}
name="kubernetes.interval"
name="kubernetes.schedule"
label="Scrape Interval"
hintPosition="top"
hint="How often to perform a full reconciliation of changes (in addition to real-time changes from Kubernetes events), set higher for larger clusters."
Expand Down
81 changes: 0 additions & 81 deletions src/components/Agents/InstalAgentInstruction/CLIInstallAgent.tsx

This file was deleted.

118 changes: 0 additions & 118 deletions src/components/Agents/InstalAgentInstruction/FluxInstallAgent.tsx

This file was deleted.

123 changes: 81 additions & 42 deletions src/components/Agents/InstalAgentInstruction/InstallAgentModal.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
import { useState } from "react";
import HelmInstallationSnippets, {
ChartData
} from "@flanksource-ui/ui/HelmSnippet/HelmInstallationSnippets";
import { useMemo } from "react";
import { GeneratedAgent } from "../../../api/services/agents";
import { Button } from "../../../ui/Buttons/Button";
import { Modal } from "../../../ui/Modal";
import { Tab, Tabs } from "../../../ui/Tabs/Tabs";
import { AgentFormValues } from "../Add/AddAgentForm";
import CLIInstallAgent from "./CLIInstallAgent";
import FluxInstallAgent from "./FluxInstallAgent";

export function WarningBox() {
return (
<div
className="relative rounded border border-yellow-200 bg-yellow-100 px-4 py-3 text-yellow-700"
role="alert"
>
<span className="block sm:inline">
Access token will be shown only once. Please copy it and store it
securely.
</span>
</div>
);
}
import { useAgentsBaseURL } from "./useAgentsBaseURL";

export function MoreInfoBox() {
return (
Expand Down Expand Up @@ -96,7 +83,81 @@ export default function InstallAgentModal({
generatedAgent,
agentFormValues
}: Props) {
const [activeTab, setActiveTab] = useState<"cli" | "flux">("cli");
const baseUrl = useAgentsBaseURL();

const data = useMemo(() => {
const kubeOptions = agentFormValues?.kubernetes;
const pushTelemetry = agentFormValues?.pushTelemetry ?? undefined;

return [
{
chart: "mission-control-agent",
namespace: "mission-control-agent",
repoName: "flanksource",
createNamespace: true,
createRepo: true,
updateHelmRepo: true,
releaseName: "mc-agent",
chartUrl: "https://flanksource.github.io/charts",
// You can add more values here to be passed to the template for the
// values section of the HelmRelease
values: [
{
key: "upstream.createSecret",
value: "true"
},
{
key: "upstream.host",
value: baseUrl
},
{
key: "upstream.username",
value: "token"
},
{
key: "upstream.password",
value: generatedAgent?.access_token
},
{
key: "upstream.agentName",
value: agentFormValues?.name
},
...(pushTelemetry?.enabled
? [
{
key: "pushTelemetry.enabled",
value: "true"
},
{
key: "pushTelemetry.topologyName",
value: `${pushTelemetry.topologyName}`
}
]
: [])
]
},
...(kubeOptions?.enabled
? [
{
chart: "mission-control-kubernetes",
namespace: "mission-control-agent",
repoName: "flanksource",
releaseName: "mc-agent-kubernetes",
values: [
{
key: "clusterName",
value: agentFormValues?.name
},
{
key: "scraper.schedule",
value: kubeOptions.schedule
}
]
}
]
: [])
] satisfies ChartData[];
}, [agentFormValues, baseUrl, generatedAgent]);

return (
<Modal
Expand All @@ -111,29 +172,7 @@ export default function InstallAgentModal({
Install the Mission Control agent using instructions below
</h3>
<div className="flex flex-col">
<Tabs
activeTab={activeTab}
onSelectTab={(v) => setActiveTab(v as any)}
>
<Tab className="flex flex-col gap-4 p-4" label="Flux" value="flux">
<FluxInstallAgent
generatedAgent={generatedAgent}
agentFormValues={agentFormValues}
/>
<WarningBox />
</Tab>
<Tab
className="flex flex-col gap-4 p-4"
label="Helm CLI"
value="cli"
>
<CLIInstallAgent
generatedAgent={generatedAgent}
agentFormValues={agentFormValues}
/>
<WarningBox />
</Tab>
</Tabs>
<HelmInstallationSnippets charts={data} isWarningDisplayed />
</div>
<MoreInfoBox />
</div>
Expand Down
Loading
Loading