Skip to content
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
1,518 changes: 444 additions & 1,074 deletions gen/api/v1/common.pb.go

Large diffs are not rendered by default.

1,429 changes: 684 additions & 745 deletions gen/api/v1/metrics_collector.pb.go

Large diffs are not rendered by default.

104 changes: 53 additions & 51 deletions internal/collector/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const (
CronJob
PersistentVolumeClaim
PersistentVolume
PersistentVolumeClaimMetrics
StorageClass
Service
Ingress
Expand Down Expand Up @@ -147,57 +148,56 @@ const (
// String returns the string representation of the ResourceType
func (r ResourceType) String() string {
names := map[ResourceType]string{
Unknown: "unknown",
Cluster: "cluster",
Node: "node",
Pod: "pod",
Namespace: "namespace",
Event: "event",
Endpoints: "endpoints",
ServiceAccount: "service_account",
LimitRange: "limit_range",
ResourceQuota: "resource_quota",
Deployment: "deployment",
StatefulSet: "stateful_set",
DaemonSet: "daemon_set",
ReplicaSet: "replica_set",
ReplicationController: "replication_controller",
Job: "job",
CronJob: "cron_job",
PersistentVolumeClaim: "persistent_volume_claim",
PersistentVolume: "persistent_volume",
StorageClass: "storage_class",
Service: "service",
Ingress: "ingress",
IngressClass: "ingress_class",
NetworkPolicy: "network_policy",
Role: "role",
RoleBinding: "role_binding",
ClusterRole: "cluster_role",
ClusterRoleBinding: "cluster_role_binding",
HorizontalPodAutoscaler: "horizontal_pod_autoscaler",
VerticalPodAutoscaler: "vertical_pod_autoscaler",
PodDisruptionBudget: "pod_disruption_budget",
PodSecurityPolicy: "pod_security_policy",
CustomResourceDefinition: "custom_resource_definition",
NodeResource: "node_resource",
Container: "container",
ContainerResource: "container_resource",
CSINode: "csi_node",
Karpenter: "karpenter",
Datadog: "datadog",
ArgoRollouts: "argo_rollouts",
Keda: "keda",
KedaScaledJob: "keda_scaled_job",
KedaScaledObject: "keda_scaled_object",
ClusterSnapshot: "cluster_snapshot",
CSIDriver: "csi_driver",
CSIStorageCapacity: "csi_storage_capacity",
VolumeAttachment: "volume_attachment",
KubeflowNotebook: "kubeflow_notebook",
VolcanoJob: "volcano_job",
SparkApplication: "spark_application",
ScheduledSparkApplication: "scheduled_spark_application",
Unknown: "unknown",
Cluster: "cluster",
Node: "node",
Pod: "pod",
Namespace: "namespace",
Event: "event",
Endpoints: "endpoints",
ServiceAccount: "service_account",
LimitRange: "limit_range",
ResourceQuota: "resource_quota",
Deployment: "deployment",
StatefulSet: "stateful_set",
DaemonSet: "daemon_set",
ReplicaSet: "replica_set",
ReplicationController: "replication_controller",
Job: "job",
CronJob: "cron_job",
PersistentVolumeClaim: "persistent_volume_claim",
PersistentVolume: "persistent_volume",
PersistentVolumeClaimMetrics: "pvc_metrics",
StorageClass: "storage_class",
Service: "service",
Ingress: "ingress",
IngressClass: "ingress_class",
NetworkPolicy: "network_policy",
Role: "role",
RoleBinding: "role_binding",
ClusterRole: "cluster_role",
ClusterRoleBinding: "cluster_role_binding",
HorizontalPodAutoscaler: "horizontal_pod_autoscaler",
VerticalPodAutoscaler: "vertical_pod_autoscaler",
PodDisruptionBudget: "pod_disruption_budget",
PodSecurityPolicy: "pod_security_policy",
CustomResourceDefinition: "custom_resource_definition",
NodeResource: "node_resource",
Container: "container",
ContainerResource: "container_resource",
CSINode: "csi_node",
Karpenter: "karpenter",
Datadog: "datadog",
ArgoRollouts: "argo_rollouts",
Keda: "keda",
KedaScaledJob: "keda_scaled_job",
KedaScaledObject: "keda_scaled_object",
ClusterSnapshot: "cluster_snapshot",
CSIDriver: "csi_driver",
CSIStorageCapacity: "csi_storage_capacity",
VolumeAttachment: "volume_attachment",
KubeflowNotebook: "kubeflow_notebook",
VolcanoJob: "volcano_job",
}

if name, ok := names[r]; ok {
Expand Down Expand Up @@ -245,6 +245,8 @@ func (r ResourceType) ProtoType() gen.ResourceType {
return gen.ResourceType_RESOURCE_TYPE_PERSISTENT_VOLUME_CLAIM
case PersistentVolume:
return gen.ResourceType_RESOURCE_TYPE_PERSISTENT_VOLUME
case PersistentVolumeClaimMetrics:
return gen.ResourceType_RESOURCE_TYPE_PVC_METRICS
case StorageClass:
return gen.ResourceType_RESOURCE_TYPE_STORAGE_CLASS
case Service:
Expand Down
3 changes: 2 additions & 1 deletion internal/collector/pvc_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func NewPersistentVolumeClaimCollector(
excludedPVCs: excludedPVCsMap,
logger: newLogger,
telemetryLogger: telemetryLogger,
cDHelper: ChangeDetectionHelper{logger: newLogger}}
cDHelper: ChangeDetectionHelper{logger: newLogger},
}
}

// Start begins the PVC collection process
Expand Down
29 changes: 29 additions & 0 deletions internal/collector/pvc_metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package collector

// PersistentVolumeClaimMetricsSnapshot represents a strongly-typed snapshot of PVC storage usage metrics
type PersistentVolumeClaimMetricsSnapshot struct {
// PVC identification
PvcName string `json:"pvcName"`
Namespace string `json:"namespace"`
PvcUID string `json:"pvcUID"`

// Volume binding information
PvName string `json:"pvName,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
VolumeMode string `json:"volumeMode,omitempty"` // "Filesystem" or "Block"

// Additional metadata for UI and cost attribution
AccessModes []string `json:"accessModes,omitempty"` // e.g., ["ReadWriteOnce"]
RequestedBytes int64 `json:"requestedBytes,omitempty"` // From PVC spec resources.requests.storage

// Storage usage metrics
UsedBytes int64 `json:"usedBytes"`
CapacityBytes int64 `json:"capacityBytes"`
AvailableBytes int64 `json:"availableBytes"`
UtilizationPct float64 `json:"utilizationPct"`

// Quality and source information
StatsAvailable bool `json:"statsAvailable"`
StatsSource string `json:"statsSource"` // "csi", "kubelet", "unknown"
UnavailableReason string `json:"unavailableReason,omitempty"`
}
Loading