-
-
Notifications
You must be signed in to change notification settings - Fork 15
feat!: Add working conversion webhook with cert rotation #1066
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
Open
sbernauer
wants to merge
29
commits into
main
Choose a base branch
from
feat/conversion-webhook
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.
+722
−342
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0ef29ab
WIP
sbernauer ed58563
Actually rotate certs
sbernauer 3be083e
clippy
sbernauer fd4d94b
doctests
sbernauer b3c17b3
HashMap -> Vec
sbernauer bdbcee0
Set correct CA lifetime
sbernauer b4c22b0
Result type
sbernauer 31b128b
fix rustdocs
sbernauer b84cf05
Add some docs
sbernauer 0390680
Update rustdoc
sbernauer 2e1d085
Handle cert rottion loop falures
sbernauer 3f8e744
changelog
sbernauer 6f0040c
link to decision
sbernauer 941ee6b
fix rustdocs
sbernauer 0c52f5f
Merge remote-tracking branch 'origin/main' into feat/conversion-webhook
sbernauer 2ec9b73
Rework CLI structs and names
sbernauer a8a2381
test: Remove CLI parsing from env var test
sbernauer 9089385
Move subject_alterative_dns_names into Options
sbernauer 4671a41
changelog
sbernauer a3b3cc1
Remove mpsc in tests leftover
sbernauer f8683e4
docs: Use result of WebhookServer::new
sbernauer 457dbf3
fmt
sbernauer a39ee47
Update crates/stackable-webhook/src/tls/mod.rs
sbernauer 6210262
fix suggestion
sbernauer dcb22bd
capture in variable
sbernauer f1fee5d
Move route into variable
sbernauer caddffb
docs: Mention background cert rotation
sbernauer 7450d85
docs: Document TlsServer::new
sbernauer ac29c0e
docs: Hint on downward API env var
sbernauer 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -116,7 +116,7 @@ use product_config::ProductConfigManager; | |
use snafu::{ResultExt, Snafu}; | ||
use stackable_telemetry::tracing::TelemetryOptions; | ||
|
||
use crate::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOpts}; | ||
use crate::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOptions}; | ||
|
||
pub const AUTHOR: &str = "Stackable GmbH - [email protected]"; | ||
|
||
|
@@ -163,10 +163,10 @@ pub enum Command<Run: Args = ProductOperatorRun> { | |
/// Can be embedded into an extended argument set: | ||
/// | ||
/// ```rust | ||
/// # use stackable_operator::cli::{Command, ProductOperatorRun, ProductConfigPath}; | ||
/// # use stackable_operator::cli::{Command, OperatorEnvironmentOptions, ProductOperatorRun, ProductConfigPath}; | ||
/// # use stackable_operator::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOptions}; | ||
/// # use stackable_telemetry::tracing::TelemetryOptions; | ||
/// use clap::Parser; | ||
/// use stackable_operator::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOpts}; | ||
/// use stackable_telemetry::tracing::TelemetryOptions; | ||
/// | ||
/// #[derive(clap::Parser, Debug, PartialEq, Eq)] | ||
/// struct Run { | ||
|
@@ -176,17 +176,36 @@ pub enum Command<Run: Args = ProductOperatorRun> { | |
/// common: ProductOperatorRun, | ||
/// } | ||
/// | ||
/// let opts = Command::<Run>::parse_from(["foobar-operator", "run", "--name", "foo", "--product-config", "bar", "--watch-namespace", "foobar", "--kubernetes-node-name", "baz"]); | ||
/// let opts = Command::<Run>::parse_from([ | ||
/// "foobar-operator", | ||
/// "run", | ||
/// "--name", | ||
/// "foo", | ||
/// "--product-config", | ||
/// "bar", | ||
/// "--watch-namespace", | ||
/// "foobar", | ||
/// "--operator-namespace", | ||
/// "stackable-operators", | ||
/// "--operator-service-name", | ||
/// "foo-operator", | ||
/// "--kubernetes-node-name", | ||
/// "baz", | ||
/// ]); | ||
/// assert_eq!(opts, Command::Run(Run { | ||
/// name: "foo".to_string(), | ||
/// common: ProductOperatorRun { | ||
/// product_config: ProductConfigPath::from("bar".as_ref()), | ||
/// watch_namespace: WatchNamespace::One("foobar".to_string()), | ||
/// telemetry_arguments: TelemetryOptions::default(), | ||
/// cluster_info_opts: KubernetesClusterInfoOpts { | ||
/// telemetry: TelemetryOptions::default(), | ||
/// cluster_info: KubernetesClusterInfoOptions { | ||
/// kubernetes_cluster_domain: None, | ||
/// kubernetes_node_name: "baz".to_string(), | ||
/// }, | ||
/// operator_environment: OperatorEnvironmentOptions { | ||
/// operator_namespace: "stackable-operators".to_string(), | ||
/// operator_service_name: "foo-operator".to_string(), | ||
/// }, | ||
/// }, | ||
/// })); | ||
/// ``` | ||
|
@@ -220,10 +239,13 @@ pub struct ProductOperatorRun { | |
pub watch_namespace: WatchNamespace, | ||
|
||
#[command(flatten)] | ||
pub telemetry_arguments: TelemetryOptions, | ||
pub operator_environment: OperatorEnvironmentOptions, | ||
|
||
#[command(flatten)] | ||
pub telemetry: TelemetryOptions, | ||
|
||
#[command(flatten)] | ||
pub cluster_info_opts: KubernetesClusterInfoOpts, | ||
pub cluster_info: KubernetesClusterInfoOptions, | ||
} | ||
|
||
/// A path to a [`ProductConfigManager`] spec file | ||
|
@@ -281,9 +303,25 @@ impl ProductConfigPath { | |
} | ||
} | ||
|
||
#[derive(clap::Parser, Debug, PartialEq, Eq)] | ||
pub struct OperatorEnvironmentOptions { | ||
/// The namespace the operator is running in, usually `stackable-operators`. | ||
/// | ||
/// Note that when running the operator on Kubernetes we recommend to use the | ||
/// [downward API](https://kubernetes.io/docs/concepts/workloads/pods/downward-api/) | ||
/// to let Kubernetes mount the namespace as the `OPERATOR_NAMESPACE` env variable. | ||
#[arg(long, env)] | ||
pub operator_namespace: String, | ||
|
||
/// The name of the service the operator is reachable at, usually | ||
/// something like `<product>-operator`. | ||
#[arg(long, env)] | ||
pub operator_service_name: String, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::{env, fs::File}; | ||
use std::fs::File; | ||
|
||
use clap::Parser; | ||
use rstest::*; | ||
|
@@ -294,7 +332,6 @@ mod tests { | |
const USER_PROVIDED_PATH: &str = "user_provided_path_properties.yaml"; | ||
const DEPLOY_FILE_PATH: &str = "deploy_config_spec_properties.yaml"; | ||
const DEFAULT_FILE_PATH: &str = "default_file_path_properties.yaml"; | ||
const WATCH_NAMESPACE: &str = "WATCH_NAMESPACE"; | ||
|
||
#[test] | ||
fn verify_cli() { | ||
|
@@ -381,16 +418,17 @@ mod tests { | |
|
||
#[test] | ||
fn product_operator_run_watch_namespace() { | ||
// clean env var to not interfere if already set | ||
unsafe { env::remove_var(WATCH_NAMESPACE) }; | ||
|
||
// cli with namespace | ||
let opts = ProductOperatorRun::parse_from([ | ||
"run", | ||
"--product-config", | ||
"bar", | ||
"--watch-namespace", | ||
"foo", | ||
"--operator-namespace", | ||
"stackable-operators", | ||
"--operator-service-name", | ||
"foo-operator", | ||
"--kubernetes-node-name", | ||
"baz", | ||
]); | ||
|
@@ -399,11 +437,15 @@ mod tests { | |
ProductOperatorRun { | ||
product_config: ProductConfigPath::from("bar".as_ref()), | ||
watch_namespace: WatchNamespace::One("foo".to_string()), | ||
cluster_info_opts: KubernetesClusterInfoOpts { | ||
cluster_info: KubernetesClusterInfoOptions { | ||
kubernetes_cluster_domain: None, | ||
kubernetes_node_name: "baz".to_string() | ||
}, | ||
telemetry_arguments: Default::default(), | ||
telemetry: Default::default(), | ||
operator_environment: OperatorEnvironmentOptions { | ||
operator_namespace: "stackable-operators".to_string(), | ||
operator_service_name: "foo-operator".to_string(), | ||
} | ||
} | ||
); | ||
|
||
|
@@ -412,6 +454,10 @@ mod tests { | |
"run", | ||
"--product-config", | ||
"bar", | ||
"--operator-namespace", | ||
"stackable-operators", | ||
"--operator-service-name", | ||
"foo-operator", | ||
"--kubernetes-node-name", | ||
"baz", | ||
]); | ||
|
@@ -420,33 +466,15 @@ mod tests { | |
ProductOperatorRun { | ||
product_config: ProductConfigPath::from("bar".as_ref()), | ||
watch_namespace: WatchNamespace::All, | ||
cluster_info_opts: KubernetesClusterInfoOpts { | ||
kubernetes_cluster_domain: None, | ||
kubernetes_node_name: "baz".to_string() | ||
}, | ||
telemetry_arguments: Default::default(), | ||
} | ||
); | ||
|
||
// env with namespace | ||
unsafe { env::set_var(WATCH_NAMESPACE, "foo") }; | ||
let opts = ProductOperatorRun::parse_from([ | ||
"run", | ||
"--product-config", | ||
"bar", | ||
"--kubernetes-node-name", | ||
"baz", | ||
]); | ||
assert_eq!( | ||
opts, | ||
ProductOperatorRun { | ||
product_config: ProductConfigPath::from("bar".as_ref()), | ||
watch_namespace: WatchNamespace::One("foo".to_string()), | ||
cluster_info_opts: KubernetesClusterInfoOpts { | ||
cluster_info: KubernetesClusterInfoOptions { | ||
kubernetes_cluster_domain: None, | ||
kubernetes_node_name: "baz".to_string() | ||
}, | ||
telemetry_arguments: Default::default(), | ||
telemetry: Default::default(), | ||
operator_environment: OperatorEnvironmentOptions { | ||
operator_namespace: "stackable-operators".to_string(), | ||
operator_service_name: "foo-operator".to_string(), | ||
} | ||
} | ||
); | ||
} | ||
|
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
suggestion: We should mention that setting the operator namespace is preferred to be done via the env variable in combination with the downward API (which should link to the official docs).
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.
ac29c0e