Skip to content

feat: Add the product "opensearch" #400

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

Merged
merged 15 commits into from
Jul 16, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions deploy/helm/stackable-cockpit/templates/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rules:
- kafka.stackable.tech
- nifi.stackable.tech
- opa.stackable.tech
- opensearch.stackable.tech
- spark.stackable.tech
- superset.stackable.tech
- trino.stackable.tech
Expand Down
69 changes: 55 additions & 14 deletions rust/stackable-cockpit/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,61 @@ pub const HELM_OCI_REGISTRY: &str = "oci://oci.stackable.tech/sdp-charts";

pub const HELM_DEFAULT_CHART_VERSION: &str = "0.0.0-dev";

pub const PRODUCT_NAMES: &[&str] = &[
"airflow",
"druid",
"hbase",
"hdfs",
"hive",
"kafka",
"nifi",
"opa",
"spark-connect",
"spark-history",
"superset",
"trino",
"zookeeper",
/// Tuple of (product name, group, version, kind)
/// Group is usually "<product name>.stackable.tech".
/// The version is currently hard-coded to "v1alpha1".
/// Kind is usually "<product name with a capitalized first letter>Cluster".
/// But there are exceptions.
pub const PRODUCTS: &[(&str, &str, &str, &str)] = &[
(
"airflow",
"airflow.stackable.tech",
"v1alpha1",
"AirflowCluster",
),
("druid", "druid.stackable.tech", "v1alpha1", "DruidCluster"),
("hbase", "hbase.stackable.tech", "v1alpha1", "HbaseCluster"),
("hdfs", "hdfs.stackable.tech", "v1alpha1", "HdfsCluster"),
("hive", "hive.stackable.tech", "v1alpha1", "HiveCluster"),
("kafka", "kafka.stackable.tech", "v1alpha1", "KafkaCluster"),
("nifi", "nifi.stackable.tech", "v1alpha1", "NifiCluster"),
("opa", "opa.stackable.tech", "v1alpha1", "OpaCluster"),
// Kind is "OpenSearchCluster" instead of "OpensearchCluster".
(
"opensearch",
"opensearch.stackable.tech",
"v1alpha1",
"OpenSearchCluster",
),
// Group is "spark.stackable.tech" instead of "spark-connect.stackable.tech".
// Kind is "SparkConnectServer" instead of "Spark-connectCluster".
(
"spark-connect",
"spark.stackable.tech",
"v1alpha1",
"SparkConnectServer",
),
// Group is "spark.stackable.tech" instead of "spark-history.stackable.tech".
// Kind is "SparkHistoryServer" instead of "Spark-historyCluster".
(
"spark-history",
"spark.stackable.tech",
"v1alpha1",
"SparkHistoryServer",
),
(
"superset",
"superset.stackable.tech",
"v1alpha1",
"SupersetCluster",
),
("trino", "trino.stackable.tech", "v1alpha1", "TrinoCluster"),
(
"zookeeper",
"zookeeper.stackable.tech",
"v1alpha1",
"ZookeeperCluster",
),
];

pub const OCI_INDEX_PAGE_SIZE: usize = 20;
8 changes: 5 additions & 3 deletions rust/stackable-cockpit/src/platform/operator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub const VALID_OPERATORS: &[&str] = &[
"listener",
"nifi",
"opa",
"opensearch",
"secret",
"spark-k8s",
"superset",
Expand Down Expand Up @@ -92,9 +93,10 @@ impl FromStr for OperatorSpec {
ensure!(len <= 2, InvalidEqualSignCountSnafu);

// Check if the provided operator name is in the list of valid operators
ensure!(VALID_OPERATORS.contains(&parts[0]), InvalidNameSnafu {
name: parts[0]
});
ensure!(
VALID_OPERATORS.contains(&parts[0]),
InvalidNameSnafu { name: parts[0] }
);

// If there is only one part, the input didn't include
// the optional version identifier
Expand Down
71 changes: 24 additions & 47 deletions rust/stackable-cockpit/src/platform/stacklet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
use indexmap::IndexMap;
use kube::{ResourceExt, core::GroupVersionKind};
use serde::Serialize;
use snafu::{ResultExt, Snafu};
use snafu::{OptionExt, ResultExt, Snafu};
use stackable_operator::status::condition::ClusterCondition;
use tracing::info;
#[cfg(feature = "openapi")]
use utoipa::ToSchema;

use crate::{
constants::PRODUCT_NAMES,
constants::PRODUCTS,
platform::{credentials, service},
utils::{
k8s::{self, Client, ConditionsExt},
string::Casing,
},
utils::k8s::{self, Client, ConditionsExt},
};

mod grafana;
Expand Down Expand Up @@ -58,6 +55,9 @@ pub enum Error {

#[snafu(display("failed to receive service information"))]
ServiceFetch { source: service::Error },

#[snafu(display("product name {product_name:?} not found"))]
GetProduct { product_name: String },
}

/// Lists all installed stacklets. If `namespace` is [`None`], stacklets from ALL
Expand All @@ -83,7 +83,7 @@ pub async fn get_credentials_for_product(
object_name: &str,
product_name: &str,
) -> Result<Option<credentials::Credentials>, Error> {
let product_gvk = gvk_from_product_name(product_name);
let product_gvk = gvk_from_product_name(product_name)?;
let product_cluster = match client
.get_namespaced_object(namespace, object_name, &product_gvk)
.await
Expand Down Expand Up @@ -113,10 +113,14 @@ async fn list_stackable_stacklets(
client: &Client,
namespace: Option<&str>,
) -> Result<Vec<Stacklet>, Error> {
let product_list = build_products_gvk_list(PRODUCT_NAMES);
let mut stacklets = Vec::new();

for (product_name, product_gvk) in product_list {
for (product_name, group, version, kind) in PRODUCTS {
let product_gvk = GroupVersionKind {
group: group.to_string(),
version: version.to_string(),
kind: kind.to_string(),
};
let objects = match client
.list_objects(&product_gvk, namespace)
.await
Expand Down Expand Up @@ -164,42 +168,15 @@ async fn list_stackable_stacklets(
Ok(stacklets)
}

fn build_products_gvk_list<'a>(product_names: &[&'a str]) -> IndexMap<&'a str, GroupVersionKind> {
let mut map = IndexMap::new();

for product_name in product_names {
// Note(techassi): Why? Just why? Can we please make this consistent?
// Note(sbernauer): I think it's legit that SparkHistoryServer and SparkConnectServer are in
// the api group spark.stackable.tech. All of this will probably be rewritten any as soon as
// we have versions different than v1alpha1.
if *product_name == "spark-history" {
map.insert(*product_name, GroupVersionKind {
group: "spark.stackable.tech".into(),
version: "v1alpha1".into(),
kind: "SparkHistoryServer".into(),
});
} else if *product_name == "spark-connect" {
map.insert(*product_name, GroupVersionKind {
group: "spark.stackable.tech".into(),
version: "v1alpha1".into(),
kind: "SparkConnectServer".into(),
});
} else {
map.insert(*product_name, gvk_from_product_name(product_name));
}
}

map
}

// FIXME: Support SparkApplication and SparkConnectServer
fn gvk_from_product_name(product_name: &str) -> GroupVersionKind {
GroupVersionKind {
group: format!("{product_name}.stackable.tech"),
version: "v1alpha1".into(),
kind: format!(
"{product_name}Cluster",
product_name = product_name.capitalize()
),
}
fn gvk_from_product_name(product_name: &str) -> Result<GroupVersionKind, Error> {
let (_, group, version, kind) = PRODUCTS
.iter()
.find(|(other_product_name, _, _, _)| product_name == *other_product_name)
.context(GetProductSnafu { product_name })?;

Ok(GroupVersionKind {
group: group.to_string(),
version: version.to_string(),
kind: kind.to_string(),
})
}
1 change: 0 additions & 1 deletion rust/stackable-cockpit/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub mod check;
pub mod k8s;
pub mod params;
pub mod path;
pub mod string;
pub mod templating;

/// Returns the name of the operator used in the Helm repository.
Expand Down
16 changes: 0 additions & 16 deletions rust/stackable-cockpit/src/utils/string.rs

This file was deleted.

5 changes: 5 additions & 0 deletions rust/stackablectl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Add OpenSearch to the list of supported products ([#400]).

### Fixed

- nix: Update nixpkgs and upgrade nodejs-18 to nodejs_20 ([#384]).
Expand All @@ -15,6 +19,7 @@ All notable changes to this project will be documented in this file.
[#384]: https://github.com/stackabletech/stackable-cockpit/pull/384
[#386]: https://github.com/stackabletech/stackable-cockpit/pull/386
[#388]: https://github.com/stackabletech/stackable-cockpit/pull/388
[#400]: https://github.com/stackabletech/stackable-cockpit/pull/400

## [1.0.0] - 2025-06-02

Expand Down
Loading