mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
[k8s.io/metrics] proto tags for metrics/v1alpha1
This commit adds proto tags to `k8s.io/metrics/pkg/apis/metrics/v1alpha1`. The tags are more-or-less what's suggested by `go-to-protobuf`, with the exception of the use of `castvalue`. `castvalue` is used to force gogo-proto to realize that the value of `ResourceList` (which is `map[ResourceName]Quantity`) is actually a type that it should consider when recording which packages are used. Otherwise, it ignores the type, using an unnamed import for the `k8s.io/apimachinery/pkg/api/resource`, which causes compilation errors.
This commit is contained in:
parent
85c3ca1013
commit
d72cbcb339
@ -29,15 +29,15 @@ import (
|
|||||||
// resource usage metrics of a node.
|
// resource usage metrics of a node.
|
||||||
type NodeMetrics struct {
|
type NodeMetrics struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// The following fields define time interval from which metrics were
|
// The following fields define time interval from which metrics were
|
||||||
// collected from the interval [Timestamp-Window, Timestamp].
|
// collected from the interval [Timestamp-Window, Timestamp].
|
||||||
Timestamp metav1.Time `json:"timestamp"`
|
Timestamp metav1.Time `json:"timestamp" protobuf:"bytes,2,opt,name=timestamp"`
|
||||||
Window metav1.Duration `json:"window"`
|
Window metav1.Duration `json:"window" protobuf:"bytes,3,opt,name=window"`
|
||||||
|
|
||||||
// The memory usage is the memory working set.
|
// The memory usage is the memory working set.
|
||||||
Usage v1.ResourceList `json:"usage"`
|
Usage v1.ResourceList `json:"usage" protobuf:"bytes,4,rep,name=usage,casttype=k8s.io/client-go/pkg/api/v1.ResourceList,castkey=k8s.io/client-go/pkg/api/v1.ResourceName,castvalue=k8s.io/apimachinery/pkg/api/resource.Quantity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeMetricsList is a list of NodeMetrics.
|
// NodeMetricsList is a list of NodeMetrics.
|
||||||
@ -45,10 +45,10 @@ type NodeMetricsList struct {
|
|||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
// Standard list metadata.
|
// Standard list metadata.
|
||||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
|
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
|
||||||
metav1.ListMeta `json:"metadata,omitempty"`
|
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// List of node metrics.
|
// List of node metrics.
|
||||||
Items []NodeMetrics `json:"items"`
|
Items []NodeMetrics `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// +genclient=true
|
// +genclient=true
|
||||||
@ -58,15 +58,15 @@ type NodeMetricsList struct {
|
|||||||
// resource usage metrics of a pod.
|
// resource usage metrics of a pod.
|
||||||
type PodMetrics struct {
|
type PodMetrics struct {
|
||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// The following fields define time interval from which metrics were
|
// The following fields define time interval from which metrics were
|
||||||
// collected from the interval [Timestamp-Window, Timestamp].
|
// collected from the interval [Timestamp-Window, Timestamp].
|
||||||
Timestamp metav1.Time `json:"timestamp"`
|
Timestamp metav1.Time `json:"timestamp" protobuf:"bytes,2,opt,name=timestamp"`
|
||||||
Window metav1.Duration `json:"window"`
|
Window metav1.Duration `json:"window" protobuf:"bytes,3,opt,name=window"`
|
||||||
|
|
||||||
// Metrics for all containers are collected within the same time window.
|
// Metrics for all containers are collected within the same time window.
|
||||||
Containers []ContainerMetrics `json:"containers"`
|
Containers []ContainerMetrics `json:"containers" protobuf:"bytes,4,rep,name=containers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodMetricsList is a list of PodMetrics.
|
// PodMetricsList is a list of PodMetrics.
|
||||||
@ -74,16 +74,16 @@ type PodMetricsList struct {
|
|||||||
metav1.TypeMeta `json:",inline"`
|
metav1.TypeMeta `json:",inline"`
|
||||||
// Standard list metadata.
|
// Standard list metadata.
|
||||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
|
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds
|
||||||
metav1.ListMeta `json:"metadata,omitempty"`
|
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
|
||||||
|
|
||||||
// List of pod metrics.
|
// List of pod metrics.
|
||||||
Items []PodMetrics `json:"items"`
|
Items []PodMetrics `json:"items" protobuf:"bytes,2,rep,name=items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// resource usage metrics of a container.
|
// resource usage metrics of a container.
|
||||||
type ContainerMetrics struct {
|
type ContainerMetrics struct {
|
||||||
// Container name corresponding to the one from pod.spec.containers.
|
// Container name corresponding to the one from pod.spec.containers.
|
||||||
Name string `json:"name"`
|
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
|
||||||
// The memory usage is the memory working set.
|
// The memory usage is the memory working set.
|
||||||
Usage v1.ResourceList `json:"usage"`
|
Usage v1.ResourceList `json:"usage" protobuf:"bytes,2,rep,name=usage,casttype=k8s.io/client-go/pkg/api/v1.ResourceList,castkey=k8s.io/client-go/pkg/api/v1.ResourceName,castvalue=k8s.io/apimachinery/pkg/api/resource.Quantity"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user