Implement base operator #1
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -864,6 +864,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
"futures",
|
||||||
"k8s-openapi",
|
"k8s-openapi",
|
||||||
"kube",
|
"kube",
|
||||||
"log",
|
"log",
|
||||||
|
@ -15,3 +15,4 @@ schemars = "0.8.12"
|
|||||||
tokio = { version = "1.28.0", features = ["full"] }
|
tokio = { version = "1.28.0", features = ["full"] }
|
||||||
kube = { version = "0.82.2", features = ["runtime", "derive"] }
|
kube = { version = "0.82.2", features = ["runtime", "derive"] }
|
||||||
k8s-openapi = { version = "0.18.0", features = ["v1_26"] } # TODO : switch to v1_27
|
k8s-openapi = { version = "0.18.0", features = ["v1_26"] } # TODO : switch to v1_27
|
||||||
|
futures = "0.3.28"
|
||||||
|
25
src/main.rs
25
src/main.rs
@ -1,4 +1,7 @@
|
|||||||
use kube::Client;
|
use futures::TryStreamExt;
|
||||||
|
use kube::{Api, Client};
|
||||||
|
use kube::runtime::{watcher, WatchStreamExt};
|
||||||
|
use minio_operator::crd::MinioBucket;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
@ -6,5 +9,25 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let client = Client::try_default().await?;
|
let client = Client::try_default().await?;
|
||||||
|
|
||||||
|
let buckets: Api<MinioBucket> = Api::default_namespaced(client.clone());
|
||||||
|
|
||||||
|
// Listen for events / buckets creation or update (deletion is not supported)
|
||||||
|
let wc = watcher::Config::default();
|
||||||
|
let bw = watcher(buckets, wc).applied_objects();
|
||||||
|
futures::pin_mut!(bw);
|
||||||
|
|
||||||
|
while let Some(b) = bw.try_next().await? {
|
||||||
|
if let Err(e) = apply_bucket(&b, &client).await {
|
||||||
|
log::error!("Failed to apply desired configuration for applied bucket {} : {}", b.spec.name, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// Make sure a bucket is compliant with a desired configuration
|
||||||
|
async fn apply_bucket(b: &MinioBucket, _client: &Client) -> anyhow::Result<()> {
|
||||||
|
log::info!("Apply configuration for bucket {}", b.spec.name);
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -22,4 +22,4 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
instance: my-minio-instance
|
instance: my-minio-instance
|
||||||
name: first-bucket
|
name: first-bucket
|
||||||
secret: bucket-secret
|
secret: first-bucket-secret
|
9
test/second-bucket.yaml
Normal file
9
test/second-bucket.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
apiVersion: "communiquons.org/v1"
|
||||||
|
kind: MinioBucket
|
||||||
|
metadata:
|
||||||
|
name: second-bucket
|
||||||
|
spec:
|
||||||
|
instance: my-minio-instance
|
||||||
|
name: second-bucket
|
||||||
|
secret: second-bucket-secret
|
Loading…
Reference in New Issue
Block a user