mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
cleanup
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
029694a3ca
commit
a23f38f2bd
@ -1,9 +1,9 @@
|
||||
import get from "lodash/get";
|
||||
import { IPodContainer } from "./pods.api";
|
||||
import { IPodContainer, IPodMetrics } from "./pods.api";
|
||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { IResourceMetrics, metricsApi } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
|
||||
@autobind()
|
||||
export class DaemonSet extends WorkloadKubeObject {
|
||||
@ -74,7 +74,7 @@ export class DaemonSet extends WorkloadKubeObject {
|
||||
|
||||
|
||||
export class DaemonSetApi extends KubeApi<DaemonSet> {
|
||||
getMetrics(daemonsets: DaemonSet[], namespace: string, selector = ""): Promise<IResourceMetrics> {
|
||||
getMetrics(daemonsets: DaemonSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||
const podSelector = daemonsets.map(daemonset => `${daemonset.getName()}-[[:alnum:]]{5}`).join("|");
|
||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||
|
||||
|
||||
@ -3,7 +3,8 @@ import moment from "moment";
|
||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { IResourceMetrics, metricsApi } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import { IPodMetrics } from "./pods.api";
|
||||
|
||||
export class DeploymentApi extends KubeApi<Deployment> {
|
||||
protected getScaleApiUrl(params: { namespace: string; name: string }) {
|
||||
@ -46,7 +47,7 @@ export class DeploymentApi extends KubeApi<Deployment> {
|
||||
});
|
||||
}
|
||||
|
||||
getMetrics(deployments: Deployment[], namespace: string, selector = ""): Promise<IResourceMetrics> {
|
||||
getMetrics(deployments: Deployment[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||
const podSelector = deployments.map(deployment => `${deployment.getName()}-[[:alnum:]]{9,}-[[:alnum:]]{5}`).join("|");
|
||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import get from "lodash/get";
|
||||
import { autobind } from "../../utils";
|
||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { IPodContainer } from "./pods.api";
|
||||
import { IPodContainer, IPodMetrics } from "./pods.api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { JsonApiParams } from "../json-api";
|
||||
import { IResourceMetrics, metricsApi } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
|
||||
@autobind()
|
||||
export class Job extends WorkloadKubeObject {
|
||||
@ -110,7 +110,7 @@ export class Job extends WorkloadKubeObject {
|
||||
|
||||
|
||||
export class JobApi extends KubeApi<Job> {
|
||||
getMetrics(jobs: Job[], namespace: string, selector = ""): Promise<IResourceMetrics> {
|
||||
getMetrics(jobs: Job[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||
const podSelector = jobs.map(job => `${job.getName()}-[[:alnum:]]{5}`).join("|");
|
||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { autobind } from "../../utils";
|
||||
import { IResourceMetrics, metricsApi } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
import { IPodMetrics } from "./pods.api";
|
||||
|
||||
export enum NamespaceStatus {
|
||||
ACTIVE = "Active",
|
||||
@ -24,7 +25,7 @@ export class Namespace extends KubeObject {
|
||||
}
|
||||
|
||||
export class NamespaceApi extends KubeApi<Namespace> {
|
||||
getMetrics(namespace: string, selector = ""): Promise<IResourceMetrics> {
|
||||
getMetrics(namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||
const opts = { category: "pods", pods: ".*", namespace, selector };
|
||||
|
||||
return metricsApi.getMetrics({
|
||||
|
||||
@ -33,14 +33,14 @@ export class PodsApi extends KubeApi<Pod> {
|
||||
export interface IPodMetrics<T = IMetrics> {
|
||||
[metric: string]: T;
|
||||
cpuUsage: T;
|
||||
cpuRequests: T;
|
||||
cpuLimits: T;
|
||||
memoryUsage: T;
|
||||
memoryRequests: T;
|
||||
memoryLimits: T;
|
||||
fsUsage: T;
|
||||
networkReceive: T;
|
||||
networkTransmit: T;
|
||||
cpuRequests?: T;
|
||||
cpuLimits?: T;
|
||||
memoryRequests?: T;
|
||||
memoryLimits?: T;
|
||||
}
|
||||
|
||||
// Reference: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#read-log-pod-v1-core
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import get from "lodash/get";
|
||||
import { autobind } from "../../utils";
|
||||
import { WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { IPodContainer, Pod } from "./pods.api";
|
||||
import { IPodContainer, IPodMetrics, Pod } from "./pods.api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { IResourceMetrics, metricsApi } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
|
||||
export class ReplicaSetApi extends KubeApi<ReplicaSet> {
|
||||
protected getScaleApiUrl(params: { namespace: string; name: string }) {
|
||||
@ -27,7 +27,7 @@ export class ReplicaSetApi extends KubeApi<ReplicaSet> {
|
||||
});
|
||||
}
|
||||
|
||||
getMetrics(replicasets: ReplicaSet[], namespace: string, selector = ""): Promise<IResourceMetrics> {
|
||||
getMetrics(replicasets: ReplicaSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||
const podSelector = replicasets.map(replicaset => `${replicaset.getName()}-[[:alnum:]]{5}`).join("|");
|
||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import get from "lodash/get";
|
||||
import { IPodContainer } from "./pods.api";
|
||||
import { IPodContainer, IPodMetrics } from "./pods.api";
|
||||
import { IAffinity, WorkloadKubeObject } from "../workload-kube-object";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { IResourceMetrics, metricsApi } from "./metrics.api";
|
||||
import { metricsApi } from "./metrics.api";
|
||||
|
||||
export class StatefulSetApi extends KubeApi<StatefulSet> {
|
||||
protected getScaleApiUrl(params: { namespace: string; name: string }) {
|
||||
@ -27,7 +27,7 @@ export class StatefulSetApi extends KubeApi<StatefulSet> {
|
||||
});
|
||||
}
|
||||
|
||||
getMetrics(statefulSets: StatefulSet[], namespace: string, selector = ""): Promise<IResourceMetrics> {
|
||||
getMetrics(statefulSets: StatefulSet[], namespace: string, selector = ""): Promise<IPodMetrics> {
|
||||
const podSelector = statefulSets.map(statefulset => `${statefulset.getName()}-[[:digit:]]+`).join("|");
|
||||
const opts = { category: "pods", pods: podSelector, namespace, selector };
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { action, comparer, observable, reaction } from "mobx";
|
||||
import { autobind, createStorage } from "../../utils";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { INamespaceMetrics, Namespace, namespacesApi } from "../../api/endpoints";
|
||||
import { IPodMetrics, Namespace, namespacesApi } from "../../api/endpoints";
|
||||
import { createPageParam } from "../../navigation";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { isAllowedResource } from "../../../common/rbac";
|
||||
@ -22,7 +22,7 @@ export const namespaceUrlParam = createPageParam<string[]>({
|
||||
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
api = namespacesApi;
|
||||
contextNs = observable.array<string>();
|
||||
@observable metrics: INamespaceMetrics = null;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { observable } from "mobx";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { DaemonSet, daemonSetApi, IDaemonSetMetrics, Pod, PodStatus } from "../../api/endpoints";
|
||||
import { DaemonSet, daemonSetApi, IPodMetrics, Pod, PodStatus } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@ -9,7 +9,7 @@ import { apiManager } from "../../api/api-manager";
|
||||
export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
|
||||
api = daemonSetApi;
|
||||
|
||||
@observable metrics: IDaemonSetMetrics = null;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
async loadMetrics(daemonSet: DaemonSet) {
|
||||
this.metrics = await daemonSetApi.getMetrics([daemonSet], daemonSet.getNs(), "");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { observable } from "mobx";
|
||||
import { Deployment, deploymentApi, IDeploymentMetrics, PodStatus } from "../../api/endpoints";
|
||||
import { Deployment, deploymentApi, IPodMetrics, PodStatus } from "../../api/endpoints";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
@ -8,7 +8,7 @@ import { apiManager } from "../../api/api-manager";
|
||||
@autobind()
|
||||
export class DeploymentStore extends KubeObjectStore<Deployment> {
|
||||
api = deploymentApi;
|
||||
@observable metrics: IDeploymentMetrics = null;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
protected sortItems(items: Deployment[]) {
|
||||
return super.sortItems(items, [
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { IJobMetrics, Job, jobApi } from "../../api/endpoints/job.api";
|
||||
import { CronJob, Pod, PodStatus } from "../../api/endpoints";
|
||||
import { Job, jobApi } from "../../api/endpoints/job.api";
|
||||
import { CronJob, IPodMetrics, Pod, PodStatus } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { observable } from "mobx";
|
||||
@ -10,7 +10,7 @@ import { observable } from "mobx";
|
||||
export class JobStore extends KubeObjectStore<Job> {
|
||||
api = jobApi;
|
||||
|
||||
@observable metrics: IJobMetrics = null;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
async loadMetrics(job: Job) {
|
||||
this.metrics = await jobApi.getMetrics([job], job.getNs(), "");
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import { observable } from "mobx";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { Deployment, IReplicaSetMetrics, ReplicaSet, replicaSetApi } from "../../api/endpoints";
|
||||
import { Deployment, ReplicaSet, replicaSetApi } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { PodStatus } from "../../api/endpoints/pods.api";
|
||||
import { IPodMetrics, PodStatus } from "../../api/endpoints/pods.api";
|
||||
|
||||
@autobind()
|
||||
export class ReplicaSetStore extends KubeObjectStore<ReplicaSet> {
|
||||
api = replicaSetApi;
|
||||
@observable metrics: IReplicaSetMetrics = null;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
async loadMetrics(replicaSet: ReplicaSet) {
|
||||
this.metrics = await replicaSetApi.getMetrics([replicaSet], replicaSet.getNs(), "");
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { observable } from "mobx";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { IStatefulSetMetrics, PodStatus, StatefulSet, statefulSetApi } from "../../api/endpoints";
|
||||
import { IPodMetrics, PodStatus, StatefulSet, statefulSetApi } from "../../api/endpoints";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@autobind()
|
||||
export class StatefulSetStore extends KubeObjectStore<StatefulSet> {
|
||||
api = statefulSetApi;
|
||||
@observable metrics: IStatefulSetMetrics = null;
|
||||
@observable metrics: IPodMetrics = null;
|
||||
|
||||
async loadMetrics(statefulSet: StatefulSet) {
|
||||
this.metrics = await statefulSetApi.getMetrics([statefulSet], statefulSet.getNs(), "");
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import React from "react";
|
||||
import { getMetricLastPoints, IResourceMetrics, IMetrics } from "../../api/endpoints/metrics.api";
|
||||
import { IPodMetrics } from "../../api/endpoints";
|
||||
import { getMetricLastPoints, IMetrics } from "../../api/endpoints/metrics.api";
|
||||
import { bytesToUnits } from "../../utils";
|
||||
import { Badge } from "../badge";
|
||||
import { DrawerItem } from "../drawer";
|
||||
|
||||
interface Props {
|
||||
metrics: IResourceMetrics<IMetrics>;
|
||||
metrics: IPodMetrics<IMetrics>;
|
||||
}
|
||||
|
||||
export function ResourceMetricsText(props: Props) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user