pub struct CustomResourceDefinitionMaintainer<'a> { /* private fields */ }Expand description
Maintains various custom resource definitions.
When running this, the following operations are done:
- Apply the CRDs when starting up
- Reconcile the CRDs when the conversion webhook certificate is rotated
Implementations§
Source§impl<'a> CustomResourceDefinitionMaintainer<'a>
impl<'a> CustomResourceDefinitionMaintainer<'a>
Sourcepub fn new(
client: Client,
certificate_rx: Receiver<Certificate>,
definitions: impl IntoIterator<Item = CustomResourceDefinition>,
options: CustomResourceDefinitionMaintainerOptions<'a>,
) -> (Self, Receiver<()>)
pub fn new( client: Client, certificate_rx: Receiver<Certificate>, definitions: impl IntoIterator<Item = CustomResourceDefinition>, options: CustomResourceDefinitionMaintainerOptions<'a>, ) -> (Self, Receiver<()>)
Creates and returns a new CustomResourceDefinitionMaintainer which manages one or more
custom resource definitions.
§Parameters
This function expects four parameters:
client: A [Client] to interact with the Kubernetes API server. It continuously patches the CRDs when the TLS certificate is rotated.certificate_rx: A [mpsc::Receiver] to receive newly generated TLS certificates. The certificate data sent through the channel is used to set the caBundle in the conversion section of the CRD.definitions: An iterator of [CustomResourceDefinition]s which should be maintained by this maintainer. If the iterator is empty, the maintainer returns early without doing any work. As such, a polling mechanism which waits for all futures should be used to prevent premature termination of the operator.options: ProvidesCustomResourceDefinitionMaintainerOptionsto customize various parts of the maintainer. In the future, this will be converted to a builder, to enable a cleaner API interface.
§Return Values
This function returns a 2-tuple (pair) of values:
- The
CustomResourceDefinitionMaintaineritself. This is used to run the maintainer. SeeCustomResourceDefinitionMaintainer::runfor more details. - The [
oneshot::Receiver] which will be used to send out a message once the initial CRD reconciliation ran. This signal can be used to trigger the deployment of custom resources defined by the maintained CRDs.
§Example
use stackable_webhook::maintainer::{
CustomResourceDefinitionMaintainerOptions,
CustomResourceDefinitionMaintainer,
};
let options = CustomResourceDefinitionMaintainerOptions {
operator_service_name: "my-service-name",
operator_namespace: "my-namespace",
field_manager: "my-field-manager",
webhook_https_port: 8443,
disabled: true,
};
let client = Client::try_default().await.unwrap();
let definitions = vec![
S3Connection::merged_crd(S3ConnectionVersion::V1Alpha1).unwrap(),
S3Bucket::merged_crd(S3BucketVersion::V1Alpha1).unwrap(),
];
let (maintainer, initial_reconcile_rx) = CustomResourceDefinitionMaintainer::new(
client,
certificate_rx,
definitions,
options,
);Sourcepub async fn run(self) -> Result<(), Error>
pub async fn run(self) -> Result<(), Error>
Runs the CustomResourceDefinitionMaintainer asynchronously.
This needs to be polled in parallel with other parts of an operator, like controllers or
webhook servers. If it is disabled, the returned future immediately resolves to
std::task::Poll::Ready and thus doesn’t consume any resources.
Auto Trait Implementations§
impl<'a> Freeze for CustomResourceDefinitionMaintainer<'a>
impl<'a> !RefUnwindSafe for CustomResourceDefinitionMaintainer<'a>
impl<'a> Send for CustomResourceDefinitionMaintainer<'a>
impl<'a> Sync for CustomResourceDefinitionMaintainer<'a>
impl<'a> Unpin for CustomResourceDefinitionMaintainer<'a>
impl<'a> !UnwindSafe for CustomResourceDefinitionMaintainer<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].