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

osrdyne: add k8s/keda authentication ref support #10909

Merged
merged 1 commit into from
Feb 24, 2025
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
16 changes: 14 additions & 2 deletions osrdyne/src/drivers/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ pub struct KedaOptions {
/// Max Replicas for the HPA of the ScaledObject
pub max_replicas: i32,

/// Amqp Host
/// Amqp Host, without authentication ref
pub amqp_host: String,

/// Amqp Host, with authentication ref
pub authentication_ref: Option<String>,

/// Mode
pub mode: String,

Expand Down Expand Up @@ -298,9 +301,18 @@ impl KubernetesDriver {
type_: "rabbitmq".to_string(),
use_cached_metrics: Some(keda.use_cached_metrics),
metric_type: keda.metric_type.clone(),
authentication_ref: keda
.authentication_ref
.clone()
.map(|auth_ref| keda::AuthenticationRef { name: auth_ref }),
metadata: {
let mut metadata = HashMap::new();
metadata.insert("host".to_string(), keda.amqp_host.clone());

// If there is no authentication reference, we use the amqp host from the KEDA configuration.
if keda.authentication_ref.is_none() {
metadata.insert("host".to_string(), keda.amqp_host.clone());
}

metadata.insert("protocol".to_string(), "auto".to_string());
metadata.insert("mode".to_string(), keda.mode.clone());
metadata.insert("value".to_string(), keda.value.clone());
Expand Down
7 changes: 7 additions & 0 deletions osrdyne/src/drivers/kubernetes/keda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ pub enum MetricType {
pub struct Trigger {
pub type_: String,
pub metadata: HashMap<String, String>,
pub authentication_ref: Option<AuthenticationRef>,
pub use_cached_metrics: Option<bool>,
pub metric_type: MetricType,
}

#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct AuthenticationRef {
pub name: String,
}
Loading