-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Leong <alex@buoyant.io>
- Loading branch information
Showing
3 changed files
with
101 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use k8s_gateway_api::v1alpha2::{ | ||
BackendRef, HttpBackendRef, HttpHeaderMatch, HttpRoute, HttpRouteMatch, HttpRouteRule, | ||
HttpRouteSpec, | ||
}; | ||
use kube::{api::PostParams, core::ObjectMeta}; | ||
|
||
#[tokio::test(flavor = "current_thread")] | ||
async fn round_trip() { | ||
tracing::trace!("Initializing client"); | ||
let client = kube::Client::try_default() | ||
.await | ||
.expect("failed to initialize k8s client"); | ||
let api = kube::Api::<HttpRoute>::default_namespaced(client); | ||
|
||
let route = HttpRoute { | ||
metadata: ObjectMeta { | ||
name: Some("bar-route".to_string()), | ||
namespace: None, | ||
labels: Some([("gateway".to_string(), "external-https-prod".to_string())].into()), | ||
..Default::default() | ||
}, | ||
spec: HttpRouteSpec { | ||
hostnames: Some(vec!["bar.example.com".to_string()]), | ||
rules: Some(vec![ | ||
HttpRouteRule { | ||
backend_refs: Some(vec![ | ||
HttpBackendRef { | ||
backend_ref: Some(BackendRef { | ||
name: "bar-v1".to_string(), | ||
port: 8080, | ||
weight: Some(90), | ||
}), | ||
filters: None, | ||
}, | ||
HttpBackendRef { | ||
backend_ref: Some(BackendRef { | ||
name: "bar-v2".to_string(), | ||
port: 8080, | ||
weight: Some(10), | ||
}), | ||
filters: None, | ||
}, | ||
]), | ||
filters: None, | ||
matches: None, | ||
}, | ||
HttpRouteRule { | ||
matches: Some(vec![HttpRouteMatch { | ||
headers: Some(vec![HttpHeaderMatch::Exact { | ||
name: "env".to_string(), | ||
value: "canary".to_string(), | ||
}]), | ||
..HttpRouteMatch::default() | ||
}]), | ||
backend_refs: Some(vec![HttpBackendRef { | ||
backend_ref: Some(BackendRef { | ||
name: "bar-v2".to_string(), | ||
port: 8080, | ||
weight: None, | ||
}), | ||
filters: None, | ||
}]), | ||
filters: None, | ||
}, | ||
]), | ||
..HttpRouteSpec::default() | ||
}, | ||
status: None, | ||
}; | ||
let post_params = PostParams { | ||
field_manager: Some("gateway-api-test".to_string()), | ||
..Default::default() | ||
}; | ||
api.create(&post_params, &route) | ||
.await | ||
.expect("failed to create resource"); | ||
|
||
api.get("bar-route").await.expect("failed to get resource"); | ||
|
||
api.delete("bar-route", &Default::default()) | ||
.await | ||
.expect("failed to delete resource"); | ||
} |
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