Skip to content

Commit

Permalink
Adapt to new API authentication method (#191)
Browse files Browse the repository at this point in the history
* Adapt to new API authentication method

* Remove unused imports

* Remove METRICS_PASSWORD constant

* Reducing resources
  • Loading branch information
ausias-armesto authored Feb 2, 2024
1 parent 0e38fd2 commit 22efa6f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hoprd_operator"
version = "0.2.6"
version = "0.2.7"
authors = ["HOPR Association <[email protected]>"]
edition = "2021"

Expand Down
1 change: 0 additions & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub const IDENTITY_POOL_WALLET_DEPLOYER_PRIVATE_KEY_REF_KEY: &str = "DEPLOYER_PR
pub const IDENTITY_POOL_WALLET_PRIVATE_KEY_REF_KEY: &str = "PRIVATE_KEY";
pub const IDENTITY_POOL_IDENTITY_PASSWORD_REF_KEY: &str = "IDENTITY_PASSWORD";
pub const IDENTITY_POOL_API_TOKEN_REF_KEY: &str = "HOPRD_API_TOKEN";
pub const IDENTITY_POOL_METRICS_PASSWORD_REF_KEY: &str = "METRICS_PASSWORD";

// Annotations
pub const ANNOTATION_LAST_CONFIGURATION: &str = "kubectl.kubernetes.io/last-applied-configuration";
Expand Down
2 changes: 1 addition & 1 deletion src/hoprd/hoprd_deployment_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Default for HoprdDeploymentSpec {
let mut limits: BTreeMap<String, Quantity> = BTreeMap::new();
let mut requests: BTreeMap<String, Quantity> = BTreeMap::new();
limits.insert("cpu".to_owned(), Quantity("1500m".to_owned()));
limits.insert("memory".to_owned(), Quantity("3Gi".to_owned()));
limits.insert("memory".to_owned(), Quantity("2Gi".to_owned()));
requests.insert("cpu".to_owned(), Quantity("750m".to_owned()));
requests.insert("memory".to_owned(), Quantity("512Mi".to_owned()));
let resources_spec = serde_yaml::to_string(&ResourceRequirements {
Expand Down
3 changes: 1 addition & 2 deletions src/identity_pool/identity_pool_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ impl IdentityPool {
if let Some(wallet_data) = wallet.data {
if wallet_data.contains_key(constants::IDENTITY_POOL_WALLET_DEPLOYER_PRIVATE_KEY_REF_KEY) &&
wallet_data.contains_key(constants::IDENTITY_POOL_IDENTITY_PASSWORD_REF_KEY) &&
wallet_data.contains_key(constants::IDENTITY_POOL_API_TOKEN_REF_KEY) &&
wallet_data.contains_key(constants::IDENTITY_POOL_METRICS_PASSWORD_REF_KEY)
wallet_data.contains_key(constants::IDENTITY_POOL_API_TOKEN_REF_KEY)
{
Ok(true)
} else {
Expand Down
24 changes: 7 additions & 17 deletions src/identity_pool/identity_pool_service_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ use tracing::info;

use crate::context_data::ContextData;
use crate::servicemonitor::{
ServiceMonitorEndpoints, ServiceMonitorEndpointsBasicAuth,
ServiceMonitorEndpointsBasicAuthPassword, ServiceMonitorEndpointsBasicAuthUsername,
ServiceMonitorEndpointsRelabelings, ServiceMonitorEndpointsRelabelingsAction,
ServiceMonitorNamespaceSelector, ServiceMonitorSelector, ServiceMonitorSpec,
ServiceMonitorEndpoints, ServiceMonitorEndpointsBearerTokenSecret, ServiceMonitorEndpointsRelabelings, ServiceMonitorEndpointsRelabelingsAction, ServiceMonitorNamespaceSelector, ServiceMonitorSelector, ServiceMonitorSpec
};
use crate::{constants, servicemonitor::ServiceMonitor};

Expand All @@ -38,21 +35,14 @@ pub async fn create_service_monitor(context_data: Arc<ContextData>, name: &str,
interval: Some("15s".to_owned()),
path: Some("/api/v3/node/metrics".to_owned()),
port: Some("api".to_owned()),
basic_auth: Some(ServiceMonitorEndpointsBasicAuth {
username: Some(ServiceMonitorEndpointsBasicAuthUsername {
key: constants::IDENTITY_POOL_API_TOKEN_REF_KEY.to_owned(),
name: Some(secret_name.to_owned()),
optional: Some(false),
}),
password: Some(ServiceMonitorEndpointsBasicAuthPassword {
key: constants::IDENTITY_POOL_METRICS_PASSWORD_REF_KEY.to_owned(),
name: Some(secret_name.to_owned()),
optional: Some(false),
}),
}),
basic_auth: None,
authorization: None,
bearer_token_file: None,
bearer_token_secret: None,
bearer_token_secret: Some(ServiceMonitorEndpointsBearerTokenSecret{
key: constants::IDENTITY_POOL_API_TOKEN_REF_KEY.to_owned(),
name: Some(secret_name.to_owned()),
optional: Some(false),
}),
follow_redirects: None,
honor_labels: None,
honor_timestamps: None,
Expand Down

0 comments on commit 22efa6f

Please sign in to comment.