forked from NationTech/harmony
fix: K8s ingress module was completely broken, fixed resource definition structure and types
This commit is contained in:
parent
6cf61ae67c
commit
8d8120bbfd
@ -26,7 +26,11 @@ impl K8sClient {
|
|||||||
<K as Resource>::Scope: ApplyStrategy<K>,
|
<K as Resource>::Scope: ApplyStrategy<K>,
|
||||||
<K as kube::Resource>::DynamicType: Default,
|
<K as kube::Resource>::DynamicType: Default,
|
||||||
{
|
{
|
||||||
debug!("Applying resource {:?} with ns {:?}", resource.meta().name, ns);
|
debug!(
|
||||||
|
"Applying resource {:?} with ns {:?}",
|
||||||
|
resource.meta().name,
|
||||||
|
ns
|
||||||
|
);
|
||||||
trace!("{:#?}", serde_json::to_string(resource));
|
trace!("{:#?}", serde_json::to_string(resource));
|
||||||
|
|
||||||
let api: Api<K> = <<K as Resource>::Scope as ApplyStrategy<K>>::get_api(&self.client, ns);
|
let api: Api<K> = <<K as Resource>::Scope as ApplyStrategy<K>>::get_api(&self.client, ns);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
use harmony_macros::ingress_path;
|
use harmony_macros::ingress_path;
|
||||||
use k8s_openapi::api::networking::v1::Ingress;
|
use k8s_openapi::api::networking::v1::Ingress;
|
||||||
|
use log::{debug, trace};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
@ -56,22 +57,24 @@ impl<T: Topology + K8sclient> Score<T> for K8sIngressScore {
|
|||||||
let ingress = json!(
|
let ingress = json!(
|
||||||
{
|
{
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"name": self.name
|
"name": self.name.to_string(),
|
||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"rules": [
|
"rules": [
|
||||||
{ "host": self.host,
|
{ "host": self.host.to_string(),
|
||||||
"http": {
|
"http": {
|
||||||
"paths": [
|
"paths": [
|
||||||
{
|
{
|
||||||
"path": path,
|
"path": path,
|
||||||
"pathType": path_type.as_str(),
|
"pathType": path_type.as_str(),
|
||||||
"backend": [
|
"backend": {
|
||||||
{
|
"service": {
|
||||||
"service": self.backend_service,
|
"name": self.backend_service.to_string(),
|
||||||
"port": self.port
|
"port": {
|
||||||
|
"number": self.port,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -81,13 +84,16 @@ impl<T: Topology + K8sclient> Score<T> for K8sIngressScore {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
trace!("Building ingresss object from Value {ingress:#}");
|
||||||
let ingress: Ingress = serde_json::from_value(ingress).unwrap();
|
let ingress: Ingress = serde_json::from_value(ingress).unwrap();
|
||||||
|
debug!(
|
||||||
|
"Successfully built Ingress for host {:?}",
|
||||||
|
ingress.metadata.name
|
||||||
|
);
|
||||||
Box::new(K8sResourceInterpret {
|
Box::new(K8sResourceInterpret {
|
||||||
score: K8sResourceScore::single(
|
score: K8sResourceScore::single(
|
||||||
ingress.clone(),
|
ingress.clone(),
|
||||||
self.namespace
|
self.namespace.clone().map(|f| f.to_string()),
|
||||||
.clone()
|
|
||||||
.map(|f| f.as_c_str().to_str().unwrap().to_string()),
|
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user