From eadfe73b0a49d83bc029f6e55742a6496b81c9c2 Mon Sep 17 00:00:00 2001 From: LorenzoTettamanti Date: Fri, 4 Dec 2026 15:37:26 +0100 Subject: [PATCH] fix(cli): update install manifests and remove simple-example - Pull core manifests from 0.1.5/Examples/minikube instead of the removed core/src/testing paths. - Remove the obsolete install simple-example subcommand and related code. - Update CLI docs and quickstart output. --- Doc/docs/cfcli/overview.md | 7 +- Doc/docs/developer-guide/architecture.md | 2 +- Doc/docs/getting-started/installation.md | 2 +- Doc/docs/getting-started/quickstart.md | 80 +++++----- cli/src/install.rs | 190 ++++------------------- cli/src/main.rs | 5 +- 6 files changed, 74 insertions(+), 212 deletions(-) diff --git a/Doc/docs/cfcli/overview.md b/Doc/docs/cfcli/overview.md index 91c669fe..fa61ca65 100644 --- a/Doc/docs/cfcli/overview.md +++ b/Doc/docs/cfcli/overview.md @@ -10,10 +10,10 @@ This document describes the available commands and provides a quick reference ta ## Setup Commands - **`cfcli install cortexflow`** - Installs **all** CortexBrain core components. + Installs **all** CortexBrain core components from the manifests in [`Examples/minikube`](https://github.com/CortexFlow/CortexBrain/tree/0.1.5/Examples/minikube). -- **`cfcli install simple-example`** - Installs a demo example defined in [deploy-test-pod.yaml](https://github.com/CortexFlow/CortexBrain/blob/main/core/src/testing/deploy-test-pod.yaml). +!!! note + `cfcli install simple-example` was removed in 0.1.5 because `deploy-test-pod.yaml` is no longer part of the repository. Use the manifests under [`Examples/minikube`](https://github.com/CortexFlow/CortexBrain/tree/0.1.5/Examples/minikube) for demo deployments. - **`cfcli uninstall`** Uninstalls **all** CortexBrain components. @@ -61,7 +61,6 @@ This document describes the available commands and provides a quick reference ta | Command | Category | Description | |--------------------------------|----------------------|-----------------------------------------------------------------------------| | `cfcli install cortexflow` | Installation | Installs all CortexBrain core components | -| `cfcli install simple-example` | Installation | Installs a demo example from `deploy-test-pod.yaml` | | `cfcli uninstall` | Installation | Uninstalls all CortexBrain components | | `cfcli update` | CLI Management | Checks if the CLI version is up to date | | `cfcli info` | CLI Management | Displays version, authors, description, and environment metadata | diff --git a/Doc/docs/developer-guide/architecture.md b/Doc/docs/developer-guide/architecture.md index ad7029a4..5eabe4ee 100644 --- a/Doc/docs/developer-guide/architecture.md +++ b/Doc/docs/developer-guide/architecture.md @@ -54,7 +54,7 @@ All CortexBrain components run in the `cortexflow` namespace. The core deploymen | `cortexflow-identity` | initContainer `bpf-map-permissions` (mounts bpffs); `identity` -> `/usr/local/bin/cortexflow-identity-service`; sidecar `bpftool-control-manager` | `lorenzotettamanti/cortexflow-identity:latest` | None (no Service) | **Producer** - pins `events_map`, `veth_map`, `blocklist_map`, `tcp_packet_registry`; seeds `blocklist_map` from the `cortexbrain-client-config` ConfigMap | | `cortexflow-metrics` | `metrics` -> `/usr/local/bin/cortexflow-metrics`; sidecar `bpftool-control-manager` | `lorenzotettamanti/cortexflow-metrics:latest` | None (no Service) | **Producer** - pins `net_metrics`, `time_stamp_events` | -**Manifests**: `core/src/testing/agent.yaml`, `core/src/testing/identity.yaml`, `core/src/testing/metrics.yaml` +**Manifests**: `Examples/minikube/agent.yaml`, `Examples/minikube/identity.yaml`, `Examples/minikube/metrics.yaml` ## Where to go next - **[Agent API Overview](../developer-guide/agent-api.md)** - the gRPC RPCs and the BPF maps behind them, in detail. diff --git a/Doc/docs/getting-started/installation.md b/Doc/docs/getting-started/installation.md index 2f3a7cfe..45f19345 100644 --- a/Doc/docs/getting-started/installation.md +++ b/Doc/docs/getting-started/installation.md @@ -83,5 +83,5 @@ For RedHat/CentOS/Fedora based distributions you can copy and paste the followin ``` - Install the core components using cfcli: ```bash - cfcli install + cfcli install cortexflow ``` diff --git a/Doc/docs/getting-started/quickstart.md b/Doc/docs/getting-started/quickstart.md index c7e3499f..6cf1d242 100644 --- a/Doc/docs/getting-started/quickstart.md +++ b/Doc/docs/getting-started/quickstart.md @@ -163,52 +163,48 @@ chmod 700 /sys/fs/bpf ``` For this step, this is the expected output: ```bash - [SYSTEM] Founded config files - [SYSTEM] Readed configs for env variable: "Kubernetes" =====> Preparing cortexflow installation =====> Creating the config files - =====> Insert your cluster environment (e.g. Kubernetes) + =====> Creating cortexflow namespace ``` - Here you need to enter your cluster environment (e.g. Kubernetes, Docker Swarm, etc...) - After that, the installation will take place and will take no longer than 1 minute. + The installation will take place and will take no longer than 1 minute.
This is the expected output ```bash - [SYSTEM] Configuration files saved in path :"/home/cortexflow/.config/cfcli/config.yaml" - - [SYSTEM] Readed configs for env variable: "Kubernetes" + =====> Preparing cortexflow installation + =====> Creating the config files + =====> Creating cortexflow namespace =====> Copying installation files - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/configmap.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/configmap-role.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/rolebinding.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/cortexflow-rolebinding.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/identity.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/feature/ebpf-core/core/src/testing/agent.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/configmap-role.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/rolebinding.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/cortexflow-rolebinding.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/identity.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/metrics.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/agent.yaml - =====> Creating cortexflow namespace =====> Installing cortexflow components - =====> (1/ 6) Applying configmap.yaml - ✅ Applied configmap.yaml - =====> (2/ 6) Applying configmap-role.yaml + =====> (1/ 6) Applying configmap-role.yaml ✅ Applied configmap-role.yaml - =====> (3/ 6) Applying rolebinding.yaml + =====> (2/ 6) Applying rolebinding.yaml ✅ Applied rolebinding.yaml - =====> (4/ 6) Applying cortexflow-rolebinding.yaml + =====> (3/ 6) Applying cortexflow-rolebinding.yaml ✅ Applied cortexflow-rolebinding.yaml - =====> (5/ 6) Applying identity.yaml + =====> (4/ 6) Applying identity.yaml ✅ Applied identity.yaml + =====> (5/ 6) Applying metrics.yaml + ✅ Applied metrics.yaml =====> (6/ 6) Applying agent.yaml ✅ Applied agent.yaml =====> Removing temporary installation files - ✅ Removed file configmap.yaml ✅ Removed file configmap-role.yaml ✅ Removed file rolebinding.yaml ✅ Removed file cortexflow-rolebinding.yaml ✅ Removed file identity.yaml + ✅ Removed file metrics.yaml ✅ Removed file agent.yaml =====> installation completed @@ -284,52 +280,48 @@ chmod 700 /sys/fs/bpf ``` For this step, this is the expected output: ```bash - [SYSTEM] Founded config files - [SYSTEM] Readed configs for env variable: "Kubernetes" =====> Preparing cortexflow installation =====> Creating the config files - =====> Insert your cluster environment (e.g. Kubernetes) + =====> Creating cortexflow namespace ``` - Here you need to enter your cluster environment (e.g. Kubernetes, Docker Swarm, etc...) - After that, the installation will take place and will take no longer than 1 minute. + The installation will take place and will take no longer than 1 minute.
This is the expected output ```bash - [SYSTEM] Configuration files saved in path :"/home/cortexflow/.config/cfcli/config.yaml" - - [SYSTEM] Readed configs for env variable: "Kubernetes" + =====> Preparing cortexflow installation + =====> Creating the config files + =====> Creating cortexflow namespace =====> Copying installation files - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/configmap.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/configmap-role.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/rolebinding.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/cortexflow-rolebinding.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/identity.yaml - ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/feature/ebpf-core/core/src/testing/agent.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/configmap-role.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/rolebinding.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/cortexflow-rolebinding.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/identity.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/metrics.yaml + ✅ Copied file from https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/agent.yaml - =====> Creating cortexflow namespace =====> Installing cortexflow components - =====> (1/ 6) Applying configmap.yaml - ✅ Applied configmap.yaml - =====> (2/ 6) Applying configmap-role.yaml + =====> (1/ 6) Applying configmap-role.yaml ✅ Applied configmap-role.yaml - =====> (3/ 6) Applying rolebinding.yaml + =====> (2/ 6) Applying rolebinding.yaml ✅ Applied rolebinding.yaml - =====> (4/ 6) Applying cortexflow-rolebinding.yaml + =====> (3/ 6) Applying cortexflow-rolebinding.yaml ✅ Applied cortexflow-rolebinding.yaml - =====> (5/ 6) Applying identity.yaml + =====> (4/ 6) Applying identity.yaml ✅ Applied identity.yaml + =====> (5/ 6) Applying metrics.yaml + ✅ Applied metrics.yaml =====> (6/ 6) Applying agent.yaml ✅ Applied agent.yaml =====> Removing temporary installation files - ✅ Removed file configmap.yaml ✅ Removed file configmap-role.yaml ✅ Removed file rolebinding.yaml ✅ Removed file cortexflow-rolebinding.yaml ✅ Removed file identity.yaml + ✅ Removed file metrics.yaml ✅ Removed file agent.yaml =====> installation completed diff --git a/cli/src/install.rs b/cli/src/install.rs index 0834abcc..d4d9f9e1 100644 --- a/cli/src/install.rs +++ b/cli/src/install.rs @@ -4,27 +4,12 @@ use crate::essential::{BASE_COMMAND, connect_to_client, create_config_file, crea use clap::{Args, Subcommand}; use colored::Colorize; use k8s_openapi::api::core::v1::ConfigMap; -use kube::core::response::StatusSummary::Failure; use kube::core::Status; +use kube::core::response::StatusSummary::Failure; use kube::{Api, Client, Error}; use std::thread::sleep; use std::{process::Command, thread, time::Duration}; -// docs: -// -// Custom enum definition: -// InstallationType: -// - used to pass installation files. Can be used for: -// - Install components by passing a Vec containing the components urls -// - Install a simple-example by passing the component url (String) -// -// - -enum InstallationType { - Components(Vec), - SimpleExample(String), -} - // docs: // // main cortexflow installation function to install all the cortexflow components: @@ -37,11 +22,6 @@ pub enum InstallCommands { about = "Install all the CortexBrain core components" )] All, - #[command( - name = "simple-example", - about = "Deploys a simple example contained in deploy-test-pod.yaml" - )] - TestPods, #[command(name = "blocklist", about = "Install or Repair blocklist configmap")] Blocklist, } @@ -85,21 +65,6 @@ pub async fn install_cortexflow() -> Result<(), CliError> { Ok(()) } -// docs: -// -// main cortexflow installation function to install the examples: -// This function installs the demostration examples - -pub async fn install_simple_example() -> Result<(), CliError> { - println!( - "{} {}", - "=====>".blue().bold(), - "Installing simple example".white() - ); - install_simple_example_component().await?; - Ok(()) -} - //docs: // // This function manages the installation of the cortexflow cluster components @@ -119,81 +84,25 @@ async fn install_cluster_components() -> Result<(), CliError> { "=====>".blue().bold(), "Copying installation files".white() ); - download_installation_files( - InstallationType::Components( - vec![ - "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/configmap-role.yaml".to_string(), - "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/rolebinding.yaml".to_string(), - "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/cortexflow-rolebinding.yaml".to_string(), - "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/identity.yaml".to_string(), - "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/agent.yaml".to_string(), - "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/main/core/src/testing/metrics.yaml".to_string() - ] - ) - )?; + download_installation_files(vec![ + "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/configmap-role.yaml".to_string(), + "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/rolebinding.yaml".to_string(), + "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/cortexflow-rolebinding.yaml".to_string(), + "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/identity.yaml".to_string(), + "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/metrics.yaml".to_string(), + "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/0.1.5/Examples/minikube/agent.yaml".to_string() + ])?; thread::sleep(Duration::from_secs(1)); install_components("cortexbrain")?; println!("\n"); - rm_installation_files(InstallationType::Components(vec![ + rm_installation_files(vec![ "configmap-role.yaml".to_string(), "rolebinding.yaml".to_string(), "cortexflow-rolebinding.yaml".to_string(), "identity.yaml".to_string(), "metrics.yaml".to_string(), "agent.yaml".to_string(), - ]))?; - println!( - "{} {}", - "=====>".blue().bold(), - "installation completed".white() - ); - Ok(()) - } - Err(e) => { - return { - Err(CliError::ClientError(Error::Api(Box::new(Status { - status: Some(Failure), - message: "Failed to connect to kubernetes client".to_string(), - reason: e.to_string(), - code: 404, - metadata: None, - details: None, - })))) - }; - } - } -} - -//docs: -// -// This function manages the installation of the examples -// Steps: -// - Connects to kubernetes client -// - Copies examples files from the offcial github repository -// - Executes the install_example function -// - Executes the rm_example_installation_file to remove the temporary installation files -// -// Returns an CliError if something fails - -async fn install_simple_example_component() -> Result<(), CliError> { - match connect_to_client().await { - Ok(_) => { - println!( - "{} {}", - "=====>".blue().bold(), - "Copying installation files".white() - ); - download_installation_files( - InstallationType::SimpleExample( - "https://raw.githubusercontent.com/CortexFlow/CortexBrain/refs/heads/feature/ebpf-core/core/src/testing/deploy-test-pod.yaml".to_string() - ) - )?; - thread::sleep(Duration::from_secs(1)); - install_components("simple-example")?; - println!("\n"); - rm_installation_files(InstallationType::SimpleExample( - "deploy-test-pod.yaml".to_string(), - ))?; + ])?; println!( "{} {}", "=====>".blue().bold(), @@ -335,26 +244,6 @@ fn install_components_with( ); let mut i = 1; - for component in files_to_install { - println!( - "{} {}{}{}{}{} {} {}", - "=====>".blue().bold(), - "(", - i, - "/", - tot_files, - ")", - "Applying", - component.to_string().green().bold() - ); - apply_component_with(runner, component)?; - i = i + 1; - } - } else if components_type == "simple-example" { - let files_to_install = vec!["deploy-test-pod.yaml"]; - let tot_files = files_to_install.len(); - let mut i = 1; - for component in files_to_install { println!( "{} {}{}{}{}{} {} {}", @@ -414,21 +303,14 @@ fn apply_component_with(runner: &dyn CommandRunner, file: &str) -> Result<(), Cl // // This is an auxiliary function to download all the installation files // Steps: -// - Read the Vec containing the file names of the installation files from the InstallationType enum +// - Read the Vec containing the urls of the installation files // - Download the corresponding installation files from the github repository // // Returns an CliError if something fails -fn download_installation_files(installation_files: InstallationType) -> Result<(), CliError> { - match installation_files { - InstallationType::Components(files) => { - for src in files.iter() { - download_file(&src)?; - } - } - InstallationType::SimpleExample(file) => { - download_file(&file)?; - } +fn download_installation_files(files: Vec) -> Result<(), CliError> { + for src in files.iter() { + download_file(src)?; } println!("\n"); Ok(()) @@ -438,26 +320,19 @@ fn download_installation_files(installation_files: InstallationType) -> Result<( // // This is an auxiliary function to specifically remove the installation files after the installation // Steps: -// - Read the Vec containing the file names of the installation files from the InstallationType enum +// - Read the Vec containing the file names of the installation files // - Executes the rm_file function for each installation file // // Returns an CliError if something fails -fn rm_installation_files(file_to_remove: InstallationType) -> Result<(), CliError> { +fn rm_installation_files(files: Vec) -> Result<(), CliError> { println!( "{} {}", "=====>".blue().bold(), "Removing temporary installation files".white() ); - match file_to_remove { - InstallationType::Components(files) => { - for src in files.iter() { - rm_file(&src)?; - } - } - InstallationType::SimpleExample(file) => { - rm_file(&file)?; - } + for src in files.iter() { + rm_file(src)?; } Ok(()) @@ -552,7 +427,8 @@ mod tests { #[test] fn test_download_file_with_command_failure() { - let runner = crate::command_runner::test_support::StubCommandRunner::failure("404 Not Found"); + let runner = + crate::command_runner::test_support::StubCommandRunner::failure("404 Not Found"); assert!(download_file_with(&runner, "https://example.com/missing.yaml").is_err()); } @@ -637,7 +513,11 @@ mod tests { // When the configmap already exists no creation attempt is made, so this // is safe to exercise end-to-end against the fake client. let client = mock_client(http::StatusCode::OK, configmap_found_body()); - assert!(install_blocklist_configmap_with_client(client).await.is_ok()); + assert!( + install_blocklist_configmap_with_client(client) + .await + .is_ok() + ); } #[test] @@ -646,12 +526,6 @@ mod tests { assert!(install_components_with(&runner, "not-a-real-type").is_err()); } - #[test] - fn test_install_components_with_simple_example_success() { - let runner = crate::command_runner::test_support::StubCommandRunner::success(""); - assert!(install_components_with(&runner, "simple-example").is_ok()); - } - #[test] fn test_install_components_with_cortexbrain_success() { let runner = crate::command_runner::test_support::StubCommandRunner::success(""); @@ -660,8 +534,9 @@ mod tests { #[test] fn test_install_components_with_apply_failure() { - let runner = crate::command_runner::test_support::StubCommandRunner::failure("kubectl error"); - assert!(install_components_with(&runner, "simple-example").is_err()); + let runner = + crate::command_runner::test_support::StubCommandRunner::failure("kubectl error"); + assert!(install_components_with(&runner, "cortexbrain").is_err()); } #[derive(clap::Parser)] @@ -677,9 +552,8 @@ mod tests { } #[test] - fn test_install_commands_parses_simple_example() { - let parsed = InstallCommandsHarness::try_parse_from(["cfcli", "simple-example"]).unwrap(); - assert!(matches!(parsed.cmd, InstallCommands::TestPods)); + fn test_install_commands_rejects_simple_example() { + assert!(InstallCommandsHarness::try_parse_from(["cfcli", "simple-example"]).is_err()); } #[test] @@ -692,4 +566,4 @@ mod tests { fn test_install_commands_rejects_unknown_subcommand() { assert!(InstallCommandsHarness::try_parse_from(["cfcli", "not-a-command"]).is_err()); } -} \ No newline at end of file +} diff --git a/cli/src/main.rs b/cli/src/main.rs index 5b8516fe..b33f0cb8 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -15,7 +15,7 @@ use tracing::debug; use crate::errors::CliError; use crate::essential::{info, update_cli}; -use crate::install::{InstallArgs, InstallCommands, install_cortexflow, install_simple_example}; +use crate::install::{InstallArgs, InstallCommands, install_cortexflow}; use crate::logs::{LogsArgs, logs_command}; use crate::monitoring::{ MonitorArgs, MonitorCommands, list_features, live_otel_http_metrics, monitor_dropped_packets, @@ -78,9 +78,6 @@ async fn args_parser() -> Result<(), CliError> { InstallCommands::All => { install_cortexflow().await?; } - InstallCommands::TestPods => { - install_simple_example().await?; - } InstallCommands::Blocklist => { //install or repair blocklist configmap let _ = install::install_blocklist_configmap().await?;