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

Update Cluster Install with proxy option and detail process #1378

Closed
wants to merge 14 commits into from
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ GIT_COMMIT=$(shell git rev-parse HEAD)
DOCKER_TAG=$(VERSION)-$(GIT_COMMIT)
DOCKER_REGISTRY=infinyon
K8_CLUSTER?=$(shell ./k8-util/cluster/cluster-type.sh)
DOCKER_IMAGE=$(DOCKER_REGISTRY)/fluvio
TARGET_MUSL=x86_64-unknown-linux-musl
TARGET?=
IMAGE_VERSION?= # If set, this indicates that the image is pre-built and should not be built
BUILD_PROFILE=$(if $(RELEASE),release,debug)
CARGO_BUILDER=$(if $(findstring arm,$(TARGET)),cross,cargo) # If TARGET contains the substring "arm"
FLUVIO_BIN=$(if $(TARGET),./target/$(TARGET)/$(BUILD_PROFILE)/fluvio,./target/$(BUILD_PROFILE)/fluvio)
Expand All @@ -33,7 +33,7 @@ TEST_ENV_FLV_SPU_DELAY=
TEST_ARG_SPU=--spu ${DEFAULT_SPU}
TEST_ARG_LOG=--client-log ${CLIENT_LOG} --server-log ${SERVER_LOG}
TEST_ARG_REPLICATION=-r ${REPL}
TEST_ARG_DEVELOP=--develop
TEST_ARG_DEVELOP=$(if $(IMAGE_VERSION),--image-version ${IMAGE_VERSION}, --develop)
TEST_ARG_SKIP_CHECKS=
TEST_ARG_EXTRA=
TEST_ARG_CONSUMER_WAIT=
Expand All @@ -54,6 +54,7 @@ helm_pkg:
build-cli: install_rustup_target
$(CARGO_BUILDER) build --bin fluvio $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG)


build-cli-minimal: install_rustup_target
# https://github.com/infinyon/fluvio/issues/1255
cargo build --bin fluvio $(RELEASE_FLAG) $(TARGET_FLAG) $(VERBOSE_FLAG) --no-default-features --features consumer --manifest-path ./src/cli/Cargo.toml
Expand Down Expand Up @@ -125,7 +126,7 @@ k8-setup:
# Kubernetes Tests

smoke-test-k8: TEST_ARG_EXTRA=$(EXTRA_ARG)
smoke-test-k8: build_k8_image smoke-test
smoke-test-k8: smoke-test build_k8_image

smoke-test-k8-tls: TEST_ARG_EXTRA=--tls $(EXTRA_ARG)
smoke-test-k8-tls: build_k8_image smoke-test
Expand Down Expand Up @@ -230,6 +231,8 @@ run-client-doc-test: install_rustup_target
# In CI mode, do not build k8 image
ifeq (${CI},true)
build_k8_image:
else ifeq (${IMAGE_VERSION},true)
build_k8_image:
else
# When not in CI (i.e. development), build image before testing
build_k8_image: fluvio_image
Expand Down
4 changes: 2 additions & 2 deletions k8-util/cluster/reset-minikube.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
# delete and re-install minikube ready for fluvio
# this defaults to docker and assume you have have sudo access
# it uses docker as default driver
set -e
ARG1=${1:-docker}
K8_VERSION=${2:-1.21.2}
minikube delete
minikube start --driver $ARG1 --kubernetes-version=$K8_VERSION
minikube start --driver $ARG1 --kubernetes-version=$K8_VERSION --extra-config=apiserver.service-node-port-range=32700-32800 --ports=127.0.0.1:32700-32800:32700-32800
# minikube start --extra-config=apiserver.v=10
1 change: 1 addition & 0 deletions src/client/src/fluvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl Fluvio {
debug!("connected to cluster at: {}", inner_client.config().addr());

let (socket, config, versions) = inner_client.split();
debug!(version = ?versions.platform_version(),"checking platform version");
check_platform_compatible(versions.platform_version())?;
let socket = MultiplexerSocket::shared(socket);
let metadata = MetadataStores::start(socket.clone()).await?;
Expand Down
39 changes: 36 additions & 3 deletions src/cluster/src/charts/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use std::path::{PathBuf};

use tracing::{info, debug, instrument};
use derive_builder::Builder;
use semver::{Version,Error as VersionError};

use semver::Version;

use fluvio_helm::{HelmClient, InstallArg};
use fluvio_helm::{HelmClient, InstallArg,InstalledChart};

use crate::DEFAULT_NAMESPACE;

Expand Down Expand Up @@ -147,6 +146,14 @@ impl ChartInstaller {
Ok(!installed_charts.is_empty())
}

/// find chart installations
pub fn retrieve_installations(&self) -> Result<Vec<InstalledChart>, ChartInstallError> {
self
.helm_client
.get_installed_chart_by_name(&self.config.name, None)
.map_err(|err| err.into())
}

/// install or upgrade
#[instrument(skip(self))]
pub fn process(&self, upgrade: bool) -> Result<(), ChartInstallError> {
Expand Down Expand Up @@ -177,6 +184,32 @@ impl ChartInstaller {
}
}


/// Installation information
#[derive(Debug)]
pub struct ChartInstallation {
chart: InstalledChart,
app_version: Version
}


impl ChartInstallation {

pub fn from(chart: InstalledChart) -> Result<Self,VersionError> {
let app_version = Version::parse(&chart.app_version)?;
Ok(Self {
chart,
app_version
})
}

pub fn app_version(&self) -> &Version {
&self.app_version
}
}



#[cfg(test)]
mod test {

Expand Down
11 changes: 7 additions & 4 deletions src/cluster/src/cli/start/k8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::convert::TryInto;
use fluvio::config::TlsPolicy;
use semver::Version;

use crate::{ClusterInstaller, ClusterError, K8InstallError, StartStatus, ClusterConfig};
use crate::{ClusterInstaller, K8InstallError, StartStatus, ClusterConfig, ClusterError};
use crate::cli::ClusterCliError;
use crate::cli::start::StartOpt;
use crate::check::render::{
Expand Down Expand Up @@ -33,6 +33,7 @@ pub async fn process_k8(
.chart_values(opt.k8_config.chart_values)
.render_checks(true)
.upgrade(upgrade)
.proxy_addr(opt.proxy_addr)
.with_if(skip_sys, |b| b.install_sys(false))
.with_if(opt.skip_checks, |b| b.skip_checks(true));

Expand Down Expand Up @@ -61,13 +62,15 @@ pub async fn process_k8(
if opt.setup {
setup_k8(&installer).await?;
} else {
start_k8(&installer).await?;
let k8_install: Result<_, ClusterError> =
start_k8(&installer).await.map_err(|err| err.into());
k8_install?
}

Ok(())
}

pub async fn start_k8(installer: &ClusterInstaller) -> Result<(), ClusterCliError> {
pub async fn start_k8(installer: &ClusterInstaller) -> Result<(), K8InstallError> {
match installer.install_fluvio().await {
// Successfully performed startup without pre-checks
Ok(StartStatus { checks: None, .. }) => {
Expand All @@ -82,7 +85,7 @@ pub async fn start_k8(installer: &ClusterInstaller) -> Result<(), ClusterCliErro
println!("Successfully installed Fluvio!");
}
// Aborted startup because pre-checks failed
Err(ClusterError::InstallK8(K8InstallError::FailedPrecheck(check_statuses))) => {
Err(K8InstallError::FailedPrecheck(check_statuses)) => {
render_statuses_next_steps(&check_statuses);
}
// Another type of error occurred during checking or startup
Expand Down
6 changes: 5 additions & 1 deletion src/cluster/src/cli/start/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ pub struct StartOpt {
/// Tries to setup necessary environment for cluster startup
#[structopt(long)]
pub setup: bool,

/// Proxy address
#[structopt(long)]
pub proxy_addr: Option<String>,
}

impl StartOpt {
Expand All @@ -137,7 +141,7 @@ impl StartOpt {
use crate::cli::start::k8::process_k8;

if self.sys {
process_sys(self, upgrade)?;
process_sys(self, platform_version)?;
} else if self.local {
process_local(self, platform_version).await?;
} else {
Expand Down
23 changes: 16 additions & 7 deletions src/cluster/src/cli/start/sys.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
use semver::Version;

use crate::cli::start::StartOpt;
use crate::cli::ClusterCliError;
use crate::charts::{ChartConfig, ChartInstallError, ChartInstaller};
use crate::ClusterError;
use crate::sys::{SysConfig,SysInstallError};

pub fn process_sys(opt: StartOpt, upgrade: bool) -> Result<(), ClusterCliError> {
install_sys_impl(opt, upgrade).map_err(ClusterError::InstallSys)?;
Ok(())
}

fn install_sys_impl(opt: StartOpt, upgrade: bool) -> Result<(), ChartInstallError> {
println!("installing sys chart");
pub fn process_sys(opt: StartOpt,platform_version: Version) -> Result<(), SysInstallError> {

let config = SysConfig::builder(platform_version)
.namespace(&opt.k8_config.namespace)
.build()?;

/*
if upgrade {
println!("upgrading sys chart");
} else {
println!("installing sys chart");
}

let config = ChartConfig::sys_builder()
.namespace(&opt.k8_config.namespace)
Expand All @@ -22,6 +30,7 @@ fn install_sys_impl(opt: StartOpt, upgrade: bool) -> Result<(), ChartInstallErro
.build()?;
let installer = ChartInstaller::from_config(config)?;
installer.process(upgrade)?;
*/

Ok(())
}
5 changes: 3 additions & 2 deletions src/cluster/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

/// charts
pub mod charts;
pub mod sys;
mod check;
mod start;
mod delete;
Expand All @@ -38,8 +39,8 @@ pub mod cli;

use fluvio_helm as helm;

pub use start::k8::{ClusterInstaller, ClusterConfig, ClusterConfigBuilder};
pub use start::local::{LocalInstaller, LocalConfig, LocalConfigBuilder};
pub use start::k8::{ClusterInstaller, ClusterConfig};
pub use start::local::{LocalInstaller, LocalConfig};
pub use error::{ClusterError, K8InstallError, LocalInstallError, UninstallError};
pub use helm::HelmError;
pub use check::{ClusterChecker, CheckStatus, CheckStatuses, CheckResult, CheckResults};
Expand Down
Loading