This repository was archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Detect IONOS managed Stackable clusters and skip installing releases #147
Open
sbernauer
wants to merge
1
commit into
main
Choose a base branch
from
detect-ionos
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::error::Error; | ||
|
||
use k8s_openapi::api::apps::v1::Deployment; | ||
use kube::{api::ListParams, Api, ResourceExt}; | ||
use lazy_static::lazy_static; | ||
use regex::Regex; | ||
|
||
/// We asked the IONOS guys and agreed an this way of identifying a managed stackable cluster | ||
/// One idea was to give the Namespace `stackable-operators` as special label | ||
/// | ||
/// The current solution lists the deployment in the `stackable-operators` namespace and searches for matching names | ||
/// This not the ideal solution and should be improved when there are better points of identifying a managed stackable cluster | ||
pub async fn detect_ionos_managed_stackable_operators() -> Result<Vec<String>, Box<dyn Error>> { | ||
lazy_static! { | ||
static ref OPERATOR_DEPLOYMENT_REGEX: Regex = | ||
Regex::new("dp-[0-9a-f]{20}-([a-z-]+)-operator-deployment").unwrap(); | ||
} | ||
|
||
let mut operators = Vec::new(); | ||
|
||
let client = crate::kube::get_client().await?; | ||
let deployments = Api::<Deployment>::namespaced(client, "stackable-operators") | ||
.list(&ListParams::default()) | ||
.await?; | ||
for deployment in deployments { | ||
let deployment_name = deployment.name_unchecked(); | ||
if let Some(operator_name) = OPERATOR_DEPLOYMENT_REGEX | ||
.captures(&deployment_name) | ||
.and_then(|cap| cap.get(1).map(|m| m.as_str())) | ||
{ | ||
operators.push(operator_name.to_string()); | ||
} | ||
} | ||
|
||
Ok(operators) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ mod arguments; | |
mod demo; | ||
mod helm; | ||
mod helpers; | ||
mod ionos; | ||
mod kind; | ||
mod kube; | ||
mod operator; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop sounds like something worth moving into its own method so it can be unit tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hope would be, that we get some more clear marker (e.g. a label on the stackable-operators Namespace) from the IONOS colleagues and replace this section