mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
move metrics functions away from workload api classes
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
a1babe7b2a
commit
5471db80e4
@ -27,6 +27,26 @@ export class ClusterApi extends KubeApi<Cluster> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMetricsForNodeNames(nodeNames: string[], params?: IMetricsReqParams): Promise<IClusterMetrics> {
|
||||||
|
const nodes = nodeNames.join("|");
|
||||||
|
const opts = { category: "cluster", nodes };
|
||||||
|
|
||||||
|
return metricsApi.getMetrics({
|
||||||
|
memoryUsage: opts,
|
||||||
|
memoryRequests: opts,
|
||||||
|
memoryLimits: opts,
|
||||||
|
memoryCapacity: opts,
|
||||||
|
cpuUsage: opts,
|
||||||
|
cpuRequests: opts,
|
||||||
|
cpuLimits: opts,
|
||||||
|
cpuCapacity: opts,
|
||||||
|
podUsage: opts,
|
||||||
|
podCapacity: opts,
|
||||||
|
fsSize: opts,
|
||||||
|
fsUsage: opts
|
||||||
|
}, params);
|
||||||
|
}
|
||||||
|
|
||||||
export enum ClusterStatus {
|
export enum ClusterStatus {
|
||||||
ACTIVE = "Active",
|
ACTIVE = "Active",
|
||||||
CREATING = "Creating",
|
CREATING = "Creating",
|
||||||
|
|||||||
@ -74,7 +74,9 @@ export class DaemonSet extends WorkloadKubeObject {
|
|||||||
|
|
||||||
|
|
||||||
export class DaemonSetApi extends KubeApi<DaemonSet> {
|
export class DaemonSetApi extends KubeApi<DaemonSet> {
|
||||||
getMetrics(daemonsets: DaemonSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
}
|
||||||
|
|
||||||
|
export function getMetricsForDaemonSets(daemonsets: DaemonSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||||
const podSelector = daemonsets.map(daemonset => `${daemonset.getName()}-[[:alnum:]]{5}`).join("|");
|
const podSelector = daemonsets.map(daemonset => `${daemonset.getName()}-[[:alnum:]]{5}`).join("|");
|
||||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||||
|
|
||||||
@ -88,7 +90,6 @@ export class DaemonSetApi extends KubeApi<DaemonSet> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export const daemonSetApi = new DaemonSetApi({
|
export const daemonSetApi = new DaemonSetApi({
|
||||||
objectConstructor: DaemonSet,
|
objectConstructor: DaemonSet,
|
||||||
|
|||||||
@ -46,8 +46,9 @@ export class DeploymentApi extends KubeApi<Deployment> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getMetrics(deployments: Deployment[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
export function getMetricsForDeployments(deployments: Deployment[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||||
const podSelector = deployments.map(deployment => `${deployment.getName()}-[[:alnum:]]{9,}-[[:alnum:]]{5}`).join("|");
|
const podSelector = deployments.map(deployment => `${deployment.getName()}-[[:alnum:]]{9,}-[[:alnum:]]{5}`).join("|");
|
||||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||||
|
|
||||||
@ -61,7 +62,6 @@ export class DeploymentApi extends KubeApi<Deployment> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
interface IContainerProbe {
|
interface IContainerProbe {
|
||||||
httpGet?: {
|
httpGet?: {
|
||||||
|
|||||||
@ -4,7 +4,9 @@ import { IMetrics, metricsApi } from "./metrics.api";
|
|||||||
import { KubeApi } from "../kube-api";
|
import { KubeApi } from "../kube-api";
|
||||||
|
|
||||||
export class IngressApi extends KubeApi<Ingress> {
|
export class IngressApi extends KubeApi<Ingress> {
|
||||||
getMetrics(ingress: string, namespace: string): Promise<IIngressMetrics> {
|
}
|
||||||
|
|
||||||
|
export function getMetricsForIngress(ingress: string, namespace: string): Promise<IIngressMetrics> {
|
||||||
const opts = { category: "ingress", ingress };
|
const opts = { category: "ingress", ingress };
|
||||||
|
|
||||||
return metricsApi.getMetrics({
|
return metricsApi.getMetrics({
|
||||||
@ -16,7 +18,6 @@ export class IngressApi extends KubeApi<Ingress> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export interface IIngressMetrics<T = IMetrics> {
|
export interface IIngressMetrics<T = IMetrics> {
|
||||||
[metric: string]: T;
|
[metric: string]: T;
|
||||||
|
|||||||
@ -110,7 +110,9 @@ export class Job extends WorkloadKubeObject {
|
|||||||
|
|
||||||
|
|
||||||
export class JobApi extends KubeApi<Job> {
|
export class JobApi extends KubeApi<Job> {
|
||||||
getMetrics(jobs: Job[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
}
|
||||||
|
|
||||||
|
export function getMetricsForJobs(jobs: Job[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||||
const podSelector = jobs.map(job => `${job.getName()}-[[:alnum:]]{5}`).join("|");
|
const podSelector = jobs.map(job => `${job.getName()}-[[:alnum:]]{5}`).join("|");
|
||||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||||
|
|
||||||
@ -124,7 +126,6 @@ export class JobApi extends KubeApi<Job> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export const jobApi = new JobApi({
|
export const jobApi = new JobApi({
|
||||||
objectConstructor: Job,
|
objectConstructor: Job,
|
||||||
|
|||||||
@ -25,7 +25,9 @@ export class Namespace extends KubeObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NamespaceApi extends KubeApi<Namespace> {
|
export class NamespaceApi extends KubeApi<Namespace> {
|
||||||
getMetrics(namespace: string, selector = ""): Promise<IPodMetrics> {
|
}
|
||||||
|
|
||||||
|
export function getMetricsForNamespace(namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||||
const opts = { category: "pods", pods: ".*", namespace, selector };
|
const opts = { category: "pods", pods: ".*", namespace, selector };
|
||||||
|
|
||||||
return metricsApi.getMetrics({
|
return metricsApi.getMetrics({
|
||||||
@ -38,7 +40,6 @@ export class NamespaceApi extends KubeApi<Namespace> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export const namespacesApi = new NamespaceApi({
|
export const namespacesApi = new NamespaceApi({
|
||||||
objectConstructor: Namespace,
|
objectConstructor: Namespace,
|
||||||
|
|||||||
@ -4,7 +4,9 @@ import { IMetrics, metricsApi } from "./metrics.api";
|
|||||||
import { KubeApi } from "../kube-api";
|
import { KubeApi } from "../kube-api";
|
||||||
|
|
||||||
export class NodesApi extends KubeApi<Node> {
|
export class NodesApi extends KubeApi<Node> {
|
||||||
getMetrics(): Promise<INodeMetrics> {
|
}
|
||||||
|
|
||||||
|
export function getMetricsForAllNodes(): Promise<INodeMetrics> {
|
||||||
const opts = { category: "nodes"};
|
const opts = { category: "nodes"};
|
||||||
|
|
||||||
return metricsApi.getMetrics({
|
return metricsApi.getMetrics({
|
||||||
@ -16,7 +18,6 @@ export class NodesApi extends KubeApi<Node> {
|
|||||||
fsUsage: opts
|
fsUsage: opts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export interface INodeMetrics<T = IMetrics> {
|
export interface INodeMetrics<T = IMetrics> {
|
||||||
[metric: string]: T;
|
[metric: string]: T;
|
||||||
|
|||||||
@ -5,14 +5,15 @@ import { Pod } from "./pods.api";
|
|||||||
import { KubeApi } from "../kube-api";
|
import { KubeApi } from "../kube-api";
|
||||||
|
|
||||||
export class PersistentVolumeClaimsApi extends KubeApi<PersistentVolumeClaim> {
|
export class PersistentVolumeClaimsApi extends KubeApi<PersistentVolumeClaim> {
|
||||||
getMetrics(pvcName: string, namespace: string): Promise<IPvcMetrics> {
|
|
||||||
return metricsApi.getMetrics({
|
|
||||||
diskUsage: { category: "pvc", pvc: pvcName },
|
|
||||||
diskCapacity: { category: "pvc", pvc: pvcName }
|
|
||||||
}, {
|
|
||||||
namespace
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMetricsForPvc(pvc: PersistentVolumeClaim): Promise<IPvcMetrics> {
|
||||||
|
return metricsApi.getMetrics({
|
||||||
|
diskUsage: { category: "pvc", pvc: pvc.getName() },
|
||||||
|
diskCapacity: { category: "pvc", pvc: pvc.getName() }
|
||||||
|
}, {
|
||||||
|
namespace: pvc.getNs()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPvcMetrics<T = IMetrics> {
|
export interface IPvcMetrics<T = IMetrics> {
|
||||||
|
|||||||
@ -9,8 +9,9 @@ export class PodsApi extends KubeApi<Pod> {
|
|||||||
|
|
||||||
return this.request.get(path, { query });
|
return this.request.get(path, { query });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getMetrics(pods: Pod[], namespace: string, selector = "pod, namespace"): Promise<IPodMetrics> {
|
export function getMetricsForPods(pods: Pod[], namespace: string, selector = "pod, namespace"): Promise<IPodMetrics> {
|
||||||
const podSelector = pods.map(pod => pod.getName()).join("|");
|
const podSelector = pods.map(pod => pod.getName()).join("|");
|
||||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||||
|
|
||||||
@ -28,7 +29,6 @@ export class PodsApi extends KubeApi<Pod> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export interface IPodMetrics<T = IMetrics> {
|
export interface IPodMetrics<T = IMetrics> {
|
||||||
[metric: string]: T;
|
[metric: string]: T;
|
||||||
|
|||||||
@ -26,8 +26,9 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getMetrics(replicasets: ReplicaSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
export function getMetricsForReplicaSets(replicasets: ReplicaSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||||
const podSelector = replicasets.map(replicaset => `${replicaset.getName()}-[[:alnum:]]{5}`).join("|");
|
const podSelector = replicasets.map(replicaset => `${replicaset.getName()}-[[:alnum:]]{5}`).join("|");
|
||||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||||
|
|
||||||
@ -41,7 +42,6 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class ReplicaSet extends WorkloadKubeObject {
|
export class ReplicaSet extends WorkloadKubeObject {
|
||||||
|
|||||||
@ -26,8 +26,9 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getMetrics(statefulSets: StatefulSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
export function getMetricsForStatefulSets(statefulSets: StatefulSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||||
const podSelector = statefulSets.map(statefulset => `${statefulset.getName()}-[[:digit:]]+`).join("|");
|
const podSelector = statefulSets.map(statefulset => `${statefulset.getName()}-[[:digit:]]+`).join("|");
|
||||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||||
|
|
||||||
@ -41,7 +42,6 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
|
|||||||
namespace,
|
namespace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
export class StatefulSet extends WorkloadKubeObject {
|
export class StatefulSet extends WorkloadKubeObject {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { action, observable, reaction, when } from "mobx";
|
import { action, observable, reaction, when } from "mobx";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { Cluster, clusterApi, IClusterMetrics } from "../../api/endpoints";
|
import { Cluster, clusterApi, getMetricsForNodeNames, IClusterMetrics } from "../../api/endpoints";
|
||||||
import { autobind, createStorage } from "../../utils";
|
import { autobind, createStorage } from "../../utils";
|
||||||
import { IMetricsReqParams, normalizeMetrics } from "../../api/endpoints/metrics.api";
|
import { IMetricsReqParams, normalizeMetrics } from "../../api/endpoints/metrics.api";
|
||||||
import { nodesStore } from "../+nodes/nodes.store";
|
import { nodesStore } from "../+nodes/nodes.store";
|
||||||
@ -78,7 +78,7 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster> implements Cl
|
|||||||
const { masterNodes, workerNodes } = nodesStore;
|
const { masterNodes, workerNodes } = nodesStore;
|
||||||
const nodes = this.metricNodeRole === MetricNodeRole.MASTER && masterNodes.length ? masterNodes : workerNodes;
|
const nodes = this.metricNodeRole === MetricNodeRole.MASTER && masterNodes.length ? masterNodes : workerNodes;
|
||||||
|
|
||||||
this.metrics = await clusterApi.getMetrics(nodes.map(node => node.getName()), params);
|
this.metrics = await getMetricsForNodeNames(nodes.map(node => node.getName()), params);
|
||||||
this.metricsLoaded = true;
|
this.metricsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { action, comparer, computed, IReactionDisposer, IReactionOptions, observable, reaction } from "mobx";
|
import { action, comparer, computed, IReactionDisposer, IReactionOptions, observable, reaction } from "mobx";
|
||||||
import { autobind, createStorage } from "../../utils";
|
import { autobind, createStorage } from "../../utils";
|
||||||
import { IPodMetrics, Namespace, namespacesApi } from "../../api/endpoints";
|
import { IPodMetrics, Namespace, namespacesApi, getMetricsForNamespace } from "../../api/endpoints";
|
||||||
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
|
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
|
||||||
import { createPageParam } from "../../navigation";
|
import { createPageParam } from "../../navigation";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
@ -40,7 +40,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadMetrics(namespace: Namespace) {
|
async loadMetrics(namespace: Namespace) {
|
||||||
this.metrics = await namespacesApi.getMetrics(namespace.getName(), "");
|
this.metrics = await getMetricsForNamespace(namespace.getName(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async init() {
|
private async init() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { IIngressMetrics, Ingress, ingressApi } from "../../api/endpoints";
|
import { IIngressMetrics, Ingress, ingressApi, getMetricsForIngress } from "../../api/endpoints";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
@ -10,7 +10,7 @@ export class IngressStore extends KubeObjectStore<Ingress> {
|
|||||||
@observable metrics: IIngressMetrics = null;
|
@observable metrics: IIngressMetrics = null;
|
||||||
|
|
||||||
async loadMetrics(ingress: Ingress) {
|
async loadMetrics(ingress: Ingress) {
|
||||||
this.metrics = await this.api.getMetrics(ingress.getName(), ingress.getNs());
|
this.metrics = await getMetricsForIngress(ingress.getName(), ingress.getNs());
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { sum } from "lodash";
|
import { sum } from "lodash";
|
||||||
import { action, computed, observable } from "mobx";
|
import { action, computed, observable } from "mobx";
|
||||||
import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints";
|
import { IClusterMetrics, INodeMetrics, Node, nodesApi, getMetricsForAllNodes, getMetricsForNodeNames } from "../../api/endpoints";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
@ -19,7 +19,7 @@ export class NodesStore extends KubeObjectStore<Node> {
|
|||||||
this.metricsLoading = true;
|
this.metricsLoading = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.metrics = await nodesApi.getMetrics();
|
this.metrics = await getMetricsForAllNodes();
|
||||||
this.metricsLoaded = true;
|
this.metricsLoaded = true;
|
||||||
} finally {
|
} finally {
|
||||||
this.metricsLoading = false;
|
this.metricsLoading = false;
|
||||||
@ -28,7 +28,7 @@ export class NodesStore extends KubeObjectStore<Node> {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
async loadMetrics(nodeName: string) {
|
async loadMetrics(nodeName: string) {
|
||||||
this.nodeMetrics = await clusterApi.getMetrics([nodeName]);
|
this.nodeMetrics = await getMetricsForNodeNames([nodeName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@computed get masterNodes() {
|
@computed get masterNodes() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { action, observable } from "mobx";
|
import { action, observable } from "mobx";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { IPvcMetrics, PersistentVolumeClaim, pvcApi } from "../../api/endpoints";
|
import { getMetricsForPvc, IPvcMetrics, PersistentVolumeClaim, pvcApi } from "../../api/endpoints";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
|
|
||||||
@autobind()
|
@autobind()
|
||||||
@ -11,7 +11,7 @@ export class VolumeClaimStore extends KubeObjectStore<PersistentVolumeClaim> {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
async loadMetrics(pvc: PersistentVolumeClaim) {
|
async loadMetrics(pvc: PersistentVolumeClaim) {
|
||||||
this.metrics = await pvcApi.getMetrics(pvc.getName(), pvc.getNs());
|
this.metrics = await getMetricsForPvc(pvc);
|
||||||
}
|
}
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { DaemonSet, daemonSetApi, IPodMetrics, Pod, PodStatus } from "../../api/endpoints";
|
import { DaemonSet, daemonSetApi, IPodMetrics, Pod, PodStatus, getMetricsForDaemonSets } from "../../api/endpoints";
|
||||||
import { podsStore } from "../+workloads-pods/pods.store";
|
import { podsStore } from "../+workloads-pods/pods.store";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
|
|||||||
@observable metrics: IPodMetrics = null;
|
@observable metrics: IPodMetrics = null;
|
||||||
|
|
||||||
async loadMetrics(daemonSet: DaemonSet) {
|
async loadMetrics(daemonSet: DaemonSet) {
|
||||||
this.metrics = await daemonSetApi.getMetrics([daemonSet], daemonSet.getNs(), "");
|
this.metrics = await getMetricsForDaemonSets([daemonSet], daemonSet.getNs(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildPods(daemonSet: DaemonSet): Pod[] {
|
getChildPods(daemonSet: DaemonSet): Pod[] {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { Deployment, deploymentApi, IPodMetrics, PodStatus } from "../../api/endpoints";
|
import { Deployment, deploymentApi, IPodMetrics, PodStatus, getMetricsForDeployments } from "../../api/endpoints";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { podsStore } from "../+workloads-pods/pods.store";
|
import { podsStore } from "../+workloads-pods/pods.store";
|
||||||
@ -17,7 +17,7 @@ export class DeploymentStore extends KubeObjectStore<Deployment> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadMetrics(deployment: Deployment) {
|
async loadMetrics(deployment: Deployment) {
|
||||||
this.metrics = await deploymentApi.getMetrics([deployment], deployment.getNs(), "");
|
this.metrics = await getMetricsForDeployments([deployment], deployment.getNs(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatuses(deployments?: Deployment[]) {
|
getStatuses(deployments?: Deployment[]) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { Job, jobApi } from "../../api/endpoints/job.api";
|
import { Job, jobApi, getMetricsForJobs } from "../../api/endpoints/job.api";
|
||||||
import { CronJob, IPodMetrics, Pod, PodStatus } from "../../api/endpoints";
|
import { CronJob, IPodMetrics, Pod, PodStatus } from "../../api/endpoints";
|
||||||
import { podsStore } from "../+workloads-pods/pods.store";
|
import { podsStore } from "../+workloads-pods/pods.store";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
@ -13,7 +13,7 @@ export class JobStore extends KubeObjectStore<Job> {
|
|||||||
@observable metrics: IPodMetrics = null;
|
@observable metrics: IPodMetrics = null;
|
||||||
|
|
||||||
async loadMetrics(job: Job) {
|
async loadMetrics(job: Job) {
|
||||||
this.metrics = await jobApi.getMetrics([job], job.getNs(), "");
|
this.metrics = await getMetricsForJobs([job], job.getNs(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildPods(job: Job): Pod[] {
|
getChildPods(job: Job): Pod[] {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import countBy from "lodash/countBy";
|
|||||||
import { action, observable } from "mobx";
|
import { action, observable } from "mobx";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { autobind, cpuUnitsToNumber, unitsToBytes } from "../../utils";
|
import { autobind, cpuUnitsToNumber, unitsToBytes } from "../../utils";
|
||||||
import { IPodMetrics, Pod, PodMetrics, podMetricsApi, podsApi } from "../../api/endpoints";
|
import { getMetricsForPods, IPodMetrics, Pod, PodMetrics, podMetricsApi, podsApi } from "../../api/endpoints";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
import { WorkloadKubeObject } from "../../api/workload-kube-object";
|
||||||
|
|
||||||
@ -15,11 +15,11 @@ export class PodsStore extends KubeObjectStore<Pod> {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
async loadMetrics(pod: Pod) {
|
async loadMetrics(pod: Pod) {
|
||||||
this.metrics = await podsApi.getMetrics([pod], pod.getNs());
|
this.metrics = await getMetricsForPods([pod], pod.getNs());
|
||||||
}
|
}
|
||||||
|
|
||||||
loadContainerMetrics(pod: Pod) {
|
loadContainerMetrics(pod: Pod) {
|
||||||
return podsApi.getMetrics([pod], pod.getNs(), "container, namespace");
|
return getMetricsForPods([pod], pod.getNs(), "container, namespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadKubeMetrics(namespace?: string) {
|
async loadKubeMetrics(namespace?: string) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { Deployment, ReplicaSet, replicaSetApi } from "../../api/endpoints";
|
import { Deployment, ReplicaSet, replicaSetApi, getMetricsForReplicaSets } from "../../api/endpoints";
|
||||||
import { podsStore } from "../+workloads-pods/pods.store";
|
import { podsStore } from "../+workloads-pods/pods.store";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
import { IPodMetrics, PodStatus } from "../../api/endpoints/pods.api";
|
import { IPodMetrics, PodStatus } from "../../api/endpoints/pods.api";
|
||||||
@ -12,7 +12,7 @@ export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> {
|
|||||||
@observable metrics: IPodMetrics = null;
|
@observable metrics: IPodMetrics = null;
|
||||||
|
|
||||||
async loadMetrics(replicaSet: ReplicaSet) {
|
async loadMetrics(replicaSet: ReplicaSet) {
|
||||||
this.metrics = await replicaSetApi.getMetrics([replicaSet], replicaSet.getNs(), "");
|
this.metrics = await getMetricsForReplicaSets([replicaSet], replicaSet.getNs(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildPods(replicaSet: ReplicaSet) {
|
getChildPods(replicaSet: ReplicaSet) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { autobind } from "../../utils";
|
import { autobind } from "../../utils";
|
||||||
import { KubeObjectStore } from "../../kube-object.store";
|
import { KubeObjectStore } from "../../kube-object.store";
|
||||||
import { IPodMetrics, PodStatus, StatefulSet, statefulSetApi } from "../../api/endpoints";
|
import { IPodMetrics, PodStatus, StatefulSet, statefulSetApi, getMetricsForStatefulSets } from "../../api/endpoints";
|
||||||
import { podsStore } from "../+workloads-pods/pods.store";
|
import { podsStore } from "../+workloads-pods/pods.store";
|
||||||
import { apiManager } from "../../api/api-manager";
|
import { apiManager } from "../../api/api-manager";
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ export class StatefulSetStore extends KubeObjectStore<StatefulSet> {
|
|||||||
@observable metrics: IPodMetrics = null;
|
@observable metrics: IPodMetrics = null;
|
||||||
|
|
||||||
async loadMetrics(statefulSet: StatefulSet) {
|
async loadMetrics(statefulSet: StatefulSet) {
|
||||||
this.metrics = await statefulSetApi.getMetrics([statefulSet], statefulSet.getNs(), "");
|
this.metrics = await getMetricsForStatefulSets([statefulSet], statefulSet.getNs(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildPods(statefulSet: StatefulSet) {
|
getChildPods(statefulSet: StatefulSet) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user