Skip to content

Commit

Permalink
chore: Version CRD and KafkaClusterConfig (#826)
Browse files Browse the repository at this point in the history
* chore: Remove separate CRD crate

* chore: Version KafkaCluster

* chore: Move KafkaCluster impl blocks

* chore: Version KafkaClusterConfig

* chore: make regenerate-nix

* Apply suggestions from code review

* chore: make regenerate-charts

---------

Co-authored-by: Nick Larsen <[email protected]>
Co-authored-by: Nick <[email protected]>
  • Loading branch information
3 people authored Feb 12, 2025
1 parent 0191244 commit e9d3d48
Show file tree
Hide file tree
Showing 23 changed files with 1,649 additions and 465 deletions.
325 changes: 278 additions & 47 deletions Cargo.lock

Large diffs are not rendered by default.

1,358 changes: 1,148 additions & 210 deletions Cargo.nix

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["rust/crd", "rust/operator-binary"]
members = ["rust/operator-binary"]
resolver = "2"

[workspace.package]
Expand All @@ -10,20 +10,22 @@ edition = "2021"
repository = "https://github.com/stackabletech/kafka-operator"

[workspace.dependencies]
stackable-versioned = { git = "https://github.com/stackabletech/operator-rs.git", features = ["k8s"], tag = "stackable-versioned-0.5.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }

anyhow = "1.0"
built = { version = "0.7", features = ["chrono", "git2"] }
clap = "4.5"
const_format = "0.2"
futures = { version = "0.3" }
futures = "0.3"
indoc = "2.0"
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
rstest = "0.24"
semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
snafu = "0.8"
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.85.0" }
strum = { version = "0.26", features = ["derive"] }
tokio = { version = "1.40", features = ["full"] }
tracing = "0.1"
Expand Down
3 changes: 3 additions & 0 deletions crate-hashes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion deploy/helm/kafka-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,10 @@ spec:
- roleGroups
type: object
clusterConfig:
description: Kafka settings that affect all roles and role groups. The settings in the `clusterConfig` are cluster wide settings that do not need to be configurable at role or role group level.
description: |-
Kafka settings that affect all roles and role groups.
The settings in the `clusterConfig` are cluster wide settings that do not need to be configurable at role or role group level.
properties:
authentication:
default: []
Expand Down
23 changes: 0 additions & 23 deletions rust/crd/Cargo.toml

This file was deleted.

9 changes: 6 additions & 3 deletions rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,25 @@ repository.workspace = true
publish = false

[dependencies]
stackable-kafka-crd = { path = "../crd" }
stackable-versioned.workspace = true
stackable-operator.workspace = true
product-config.workspace = true

indoc.workspace = true
anyhow.workspace = true
clap.workspace = true
const_format.workspace = true
futures.workspace = true
product-config.workspace = true
serde_json.workspace = true
serde.workspace = true
snafu.workspace = true
stackable-operator.workspace = true
strum.workspace = true
tokio.workspace = true
tracing.workspace = true

[dev-dependencies]
serde_yaml.workspace = true
rstest.workspace = true

[build-dependencies]
built.workspace = true
Expand Down
15 changes: 8 additions & 7 deletions rust/operator-binary/src/config/jvm.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use snafu::{OptionExt, ResultExt, Snafu};
use stackable_kafka_crd::{
KafkaConfig, KafkaConfigFragment, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
STACKABLE_CONFIG_DIR,
};
use stackable_operator::{
memory::{BinaryMultiple, MemoryQuantity},
role_utils::{self, GenericRoleConfig, JavaCommonConfig, JvmArgumentOverrides, Role},
};

use crate::crd::{
KafkaConfig, KafkaConfigFragment, JVM_SECURITY_PROPERTIES_FILE, METRICS_PORT,
STACKABLE_CONFIG_DIR,
};

const JAVA_HEAP_FACTOR: f32 = 0.8;

#[derive(Snafu, Debug)]
Expand Down Expand Up @@ -97,9 +98,8 @@ fn is_heap_jvm_argument(jvm_argument: &str) -> bool {

#[cfg(test)]
mod tests {
use stackable_kafka_crd::{KafkaCluster, KafkaRole};

use super::*;
use crate::crd::{v1alpha1, KafkaRole};

#[test]
fn test_construct_jvm_arguments_defaults() {
Expand Down Expand Up @@ -188,7 +188,8 @@ mod tests {
Role<KafkaConfigFragment, GenericRoleConfig, JavaCommonConfig>,
String,
) {
let kafka: KafkaCluster = serde_yaml::from_str(kafka_cluster).expect("illegal test input");
let kafka: v1alpha1::KafkaCluster =
serde_yaml::from_str(kafka_cluster).expect("illegal test input");

let kafka_role = KafkaRole::Broker;
let rolegroup_ref = kafka.broker_rolegroup_ref("default");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use stackable_operator::{
k8s_openapi::api::core::v1::PodAntiAffinity,
};

use crate::{KafkaRole, APP_NAME};
use crate::crd::{KafkaRole, APP_NAME};

pub fn get_affinity(cluster_name: &str, role: &KafkaRole) -> StackableAffinityFragment {
StackableAffinityFragment {
Expand Down Expand Up @@ -33,7 +33,7 @@ mod tests {
};

use super::*;
use crate::KafkaCluster;
use crate::crd::v1alpha1;

#[rstest]
#[case(KafkaRole::Broker)]
Expand All @@ -54,7 +54,8 @@ mod tests {
replicas: 1
"#;

let kafka: KafkaCluster = serde_yaml::from_str(input).expect("illegal test input");
let kafka: v1alpha1::KafkaCluster =
serde_yaml::from_str(input).expect("illegal test input");
let merged_config = kafka
.merged_config(&role, &role.rolegroup_ref(&kafka, "default"))
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use stackable_operator::{
schemars::{self, JsonSchema},
};

use crate::ObjectRef;
use crate::crd::ObjectRef;

pub const SUPPORTED_AUTHENTICATION_CLASS_PROVIDERS: [&str; 2] = ["TLS", "Kerberos"];

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use snafu::{OptionExt, Snafu};
use stackable_operator::{kube::ResourceExt, utils::cluster_info::KubernetesClusterInfo};
use strum::{EnumDiscriminants, EnumString};

use crate::{security::KafkaTlsSecurity, KafkaCluster, STACKABLE_LISTENER_BROKER_DIR};
use crate::crd::{security::KafkaTlsSecurity, v1alpha1, STACKABLE_LISTENER_BROKER_DIR};

const LISTENER_LOCAL_ADDRESS: &str = "0.0.0.0";

Expand Down Expand Up @@ -96,7 +96,7 @@ impl Display for KafkaListener {
}

pub fn get_kafka_listener_config(
kafka: &KafkaCluster,
kafka: &v1alpha1::KafkaCluster,
kafka_security: &KafkaTlsSecurity,
object_name: &str,
cluster_info: &KubernetesClusterInfo,
Expand Down Expand Up @@ -246,7 +246,7 @@ fn node_port_cmd(directory: &str, port_name: &str) -> String {
}

pub fn pod_fqdn(
kafka: &KafkaCluster,
kafka: &v1alpha1::KafkaCluster,
object_name: &str,
cluster_info: &KubernetesClusterInfo,
) -> Result<String, KafkaListenerError> {
Expand All @@ -273,7 +273,7 @@ mod tests {
};

use super::*;
use crate::authentication::ResolvedAuthenticationClasses;
use crate::crd::authentication::ResolvedAuthenticationClasses;

fn default_cluster_info() -> KubernetesClusterInfo {
KubernetesClusterInfo {
Expand Down Expand Up @@ -303,7 +303,8 @@ mod tests {
serverSecretClass: tls
zookeeperConfigMapName: xyz
"#;
let kafka: KafkaCluster = serde_yaml::from_str(kafka_cluster).expect("illegal test input");
let kafka: v1alpha1::KafkaCluster =
serde_yaml::from_str(kafka_cluster).expect("illegal test input");
let kafka_security = KafkaTlsSecurity::new(
ResolvedAuthenticationClasses::new(vec![AuthenticationClass {
metadata: ObjectMetaBuilder::new().name("auth-class").build(),
Expand Down Expand Up @@ -479,7 +480,8 @@ mod tests {
serverSecretClass: tls
zookeeperConfigMapName: xyz
"#;
let kafka: KafkaCluster = serde_yaml::from_str(kafka_cluster).expect("illegal test input");
let kafka: v1alpha1::KafkaCluster =
serde_yaml::from_str(kafka_cluster).expect("illegal test input");
let kafka_security = KafkaTlsSecurity::new(
ResolvedAuthenticationClasses::new(vec![AuthenticationClass {
metadata: ObjectMetaBuilder::new().name("auth-class").build(),
Expand Down
Loading

0 comments on commit e9d3d48

Please sign in to comment.