Skip to content

Commit

Permalink
add the tkex statefulsetplus support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyzhou authored and rvql committed Oct 23, 2024
1 parent c35fbac commit 847b0f4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
41 changes: 41 additions & 0 deletions agent/src/platform/kubernetes/crd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,44 @@ pub mod opengauss {
}
}
}

pub mod tkex {
use super::*;

use k8s_openapi::{
api::core::v1::PodTemplateSpec, apimachinery::pkg::apis::meta::v1::LabelSelector,
};

#[derive(CustomResource, Clone, Debug, Serialize, Deserialize, JsonSchema)]
#[kube(
group = "platform.stke",
version = "v1alpha1",
kind = "StatefulSetPlus",
namespaced
)]
#[serde(rename_all = "camelCase")]
pub struct StatefulSetPlusSpec {
pub replicas: Option<i32>,
pub selector: LabelSelector,
pub template: PodTemplateSpec,
}

impl Trimmable for StatefulSetPlus {
fn trim(mut self) -> Self {
let name = if let Some(name) = self.metadata.name.as_ref() {
name
} else {
""
};
let mut ssp = Self::new(name, self.spec);
ssp.metadata = ObjectMeta {
uid: self.metadata.uid.take(),
name: self.metadata.name.take(),
namespace: self.metadata.namespace.take(),
labels: self.metadata.labels.take(),
..Default::default()
};
ssp
}
}
}
15 changes: 15 additions & 0 deletions agent/src/platform/kubernetes/resource_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use super::crd::{
kruise::{CloneSet, StatefulSet as KruiseStatefulSet},
opengauss::OpenGaussCluster,
pingan_cloud::ServiceRule,
tkex::StatefulSetPlus,
};
use crate::utils::stats::{self, Countable, Counter, CounterType, CounterValue, RefCountable};

Expand Down Expand Up @@ -101,6 +102,7 @@ pub enum GenericResourceWatcher {
KruiseStatefulSet(ResourceWatcher<KruiseStatefulSet>),
IpPool(ResourceWatcher<IpPool>),
OpenGaussCluster(ResourceWatcher<OpenGaussCluster>),
StatefulSetPlus(ResourceWatcher<StatefulSetPlus>),
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -344,6 +346,10 @@ pub fn supported_resources() -> Vec<Resource> {
group: "apps.kruise.io",
version: "v1beta1",
},
GroupVersion {
group: "platform.stke",
version: "v1alpha1",
},
],
selected_gv: None,
field_selector: String::new(),
Expand Down Expand Up @@ -1300,6 +1306,15 @@ impl ResourceWatcherFactory {
namespace,
config,
)),
GroupVersion {
group: "platform.stke",
version: "v1alpha1",
} => GenericResourceWatcher::StatefulSetPlus(self.new_watcher_inner(
resource,
stats_collector,
namespace,
config,
)),
GroupVersion {
group: "apps",
version: "v1",
Expand Down
1 change: 1 addition & 0 deletions server/controller/cloud/kubernetes_gather/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (k *KubernetesGather) getPods() (pods []model.Pod, err error) {
"InPlaceSet": false,
"ReplicaSet": false,
"StatefulSet": false,
"StatefulSetPlus": false,
"OpenGaussCluster": false,
"ReplicationController": false,
}
Expand Down

0 comments on commit 847b0f4

Please sign in to comment.