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: improve kubectl access errors #3895

Merged
merged 3 commits into from
Mar 14, 2024
Merged
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
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
Loading