Skip to content

Commit

Permalink
fix: improve kubectl access errors (#3895)
Browse files Browse the repository at this point in the history
* fix: improve kubectl access errors

* fix: update comments

* fix: revise comment
  • Loading branch information
digikata committed Mar 14, 2024
1 parent 657b9bd commit 9369473
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
8 changes: 5 additions & 3 deletions crates/fluvio-cluster/src/cli/start/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ pub struct K8Install {
#[arg(long)]
pub chart_values: Vec<PathBuf>,

/// Uses port forwarding for connecting to SC during install
/// Uses port forwarding for connecting to SC (only during install)
///
/// For connecting to a cluster during and after install, --proxy-addr <IP or DNS> is recommended
#[arg(long)]
use_k8_port_forwarding: bool,

/// Uses port forwarding for connecting to SC during install
#[arg(long)]
/// Config option used in kubernetes deployments
#[arg(long, hide = true)]
use_cluster_ip: bool,

/// TLS: Client secret name while adding to Kubernetes
Expand Down
24 changes: 21 additions & 3 deletions crates/fluvio-cluster/src/start/k8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::io::Error as IoError;
use std::io::ErrorKind;
use std::collections::BTreeMap;
use std::io::Read;
use std::io::Write;
use std::path::PathBuf;
use std::borrow::Cow;
use std::process::Child;
Expand All @@ -14,7 +15,7 @@ use std::time::SystemTime;
use anyhow::{anyhow, Result};
use derive_builder::Builder;
use k8_client::meta_client::NameSpace;
use tracing::{info, warn, debug, instrument};
use tracing::{info, warn, error, debug, instrument};
use once_cell::sync::Lazy;
use tempfile::NamedTempFile;
use semver::Version;
Expand Down Expand Up @@ -580,8 +581,15 @@ impl ClusterInstaller {
/// # }
/// ```
pub fn from_config(config: ClusterConfig) -> Result<Self> {
let kube_client = load_and_share().map_err(|k8_err| {
let msg =
format!("unable to load kubectl context to access k8 cluster\nError: {k8_err:?}\n");
error!(target: "kubectl", msg);
anyhow!(msg)
})?;

Ok(Self {
kube_client: load_and_share()?,
kube_client,
pb_factory: ProgressBarFactory::new(config.hide_spinner),
config,
})
Expand Down Expand Up @@ -800,7 +808,17 @@ impl ClusterInstaller {

debug!(?helm_lb_config, "helm_lb_config");

serde_yaml::to_writer(&np_addr_fd, &helm_lb_config)?;
let helm_values: String = serde_yaml::to_string(&helm_lb_config).map_err(|e| {
debug!(
?helm_lb_config,
"couldn't serialize helm load balancer config"
);
anyhow!("couldn't serialize helm yaml {e:?}")
})?;
debug!(%helm_values, "helm_values");
write!(&np_addr_fd, "{helm_values}")
.map_err(|e| anyhow!("Error writing helm values file\n{e}"))?;

Some((np_addr_fd, np_conf_path))
} else {
None
Expand Down

0 comments on commit 9369473

Please sign in to comment.