Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the tkex statefulsetplus support. #8359

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading