mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'master' into improve-logging
This commit is contained in:
commit
536a22c053
229 files changed
+4074
-1692
No files matched your search
@@ -77,4 +77,4 @@ describe("search store tests", () => {
|
||||
searchStore.onSearch(logs, "Starting");
|
||||
expect(searchStore.totalFinds).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -101,4 +101,4 @@ describe("user store tests", () => {
|
||||
expect(us.lastSeenAppVersion).toBe("0.0.0");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -36,6 +36,13 @@ describe("workspace store tests", () => {
|
||||
expect(ws.getById(WorkspaceStore.defaultId)).not.toBe(null);
|
||||
});
|
||||
|
||||
it("default workspace should be enabled", () => {
|
||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||
|
||||
expect(ws.workspaces.size).toBe(1);
|
||||
expect(ws.getById(WorkspaceStore.defaultId).enabled).toBe(true);
|
||||
});
|
||||
|
||||
it("cannot remove the default workspace", () => {
|
||||
const ws = WorkspaceStore.getInstance<WorkspaceStore>();
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ export class ExecValidationNotFoundError extends Error {
|
||||
this.name = this.constructor.name;
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,4 +175,4 @@ export function validateKubeConfig (config: KubeConfig) {
|
||||
throw new ExecValidationNotFoundError(execCommand, isAbsolute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,4 @@ import { PrometheusProviderRegistry } from "../main/prometheus/provider-registry
|
||||
PrometheusProviderRegistry.registerProvider(provider.id, provider);
|
||||
});
|
||||
|
||||
export const prometheusProviders = PrometheusProviderRegistry.getProviders();
|
||||
export const prometheusProviders = PrometheusProviderRegistry.getProviders();
|
||||
+28
-26
@@ -1,42 +1,44 @@
|
||||
import { getHostedCluster } from "./cluster-store";
|
||||
|
||||
export type KubeResource =
|
||||
"namespaces" | "nodes" | "events" | "resourcequotas" | "services" |
|
||||
"namespaces" | "nodes" | "events" | "resourcequotas" | "services" | "limitranges" |
|
||||
"secrets" | "configmaps" | "ingresses" | "networkpolicies" | "persistentvolumeclaims" | "persistentvolumes" | "storageclasses" |
|
||||
"pods" | "daemonsets" | "deployments" | "statefulsets" | "replicasets" | "jobs" | "cronjobs" |
|
||||
"endpoints" | "customresourcedefinitions" | "horizontalpodautoscalers" | "podsecuritypolicies" | "poddisruptionbudgets";
|
||||
|
||||
export interface KubeApiResource {
|
||||
resource: KubeResource; // valid resource name
|
||||
kind: string; // resource type (e.g. "Namespace")
|
||||
apiName: KubeResource; // valid api resource name (e.g. "namespaces")
|
||||
group?: string; // api-group
|
||||
}
|
||||
|
||||
// TODO: auto-populate all resources dynamically (see: kubectl api-resources -o=wide -v=7)
|
||||
export const apiResources: KubeApiResource[] = [
|
||||
{ resource: "configmaps" },
|
||||
{ resource: "cronjobs", group: "batch" },
|
||||
{ resource: "customresourcedefinitions", group: "apiextensions.k8s.io" },
|
||||
{ resource: "daemonsets", group: "apps" },
|
||||
{ resource: "deployments", group: "apps" },
|
||||
{ resource: "endpoints" },
|
||||
{ resource: "events" },
|
||||
{ resource: "horizontalpodautoscalers" },
|
||||
{ resource: "ingresses", group: "networking.k8s.io" },
|
||||
{ resource: "jobs", group: "batch" },
|
||||
{ resource: "namespaces" },
|
||||
{ resource: "networkpolicies", group: "networking.k8s.io" },
|
||||
{ resource: "nodes" },
|
||||
{ resource: "persistentvolumes" },
|
||||
{ resource: "persistentvolumeclaims" },
|
||||
{ resource: "pods" },
|
||||
{ resource: "poddisruptionbudgets" },
|
||||
{ resource: "podsecuritypolicies" },
|
||||
{ resource: "resourcequotas" },
|
||||
{ resource: "replicasets", group: "apps" },
|
||||
{ resource: "secrets" },
|
||||
{ resource: "services" },
|
||||
{ resource: "statefulsets", group: "apps" },
|
||||
{ resource: "storageclasses", group: "storage.k8s.io" },
|
||||
{ kind: "ConfigMap", apiName: "configmaps" },
|
||||
{ kind: "CronJob", apiName: "cronjobs", group: "batch" },
|
||||
{ kind: "CustomResourceDefinition", apiName: "customresourcedefinitions", group: "apiextensions.k8s.io" },
|
||||
{ kind: "DaemonSet", apiName: "daemonsets", group: "apps" },
|
||||
{ kind: "Deployment", apiName: "deployments", group: "apps" },
|
||||
{ kind: "Endpoint", apiName: "endpoints" },
|
||||
{ kind: "Event", apiName: "events" },
|
||||
{ kind: "HorizontalPodAutoscaler", apiName: "horizontalpodautoscalers" },
|
||||
{ kind: "Ingress", apiName: "ingresses", group: "networking.k8s.io" },
|
||||
{ kind: "Job", apiName: "jobs", group: "batch" },
|
||||
{ kind: "Namespace", apiName: "namespaces" },
|
||||
{ kind: "LimitRange", apiName: "limitranges" },
|
||||
{ kind: "NetworkPolicy", apiName: "networkpolicies", group: "networking.k8s.io" },
|
||||
{ kind: "Node", apiName: "nodes" },
|
||||
{ kind: "PersistentVolume", apiName: "persistentvolumes" },
|
||||
{ kind: "PersistentVolumeClaim", apiName: "persistentvolumeclaims" },
|
||||
{ kind: "Pod", apiName: "pods" },
|
||||
{ kind: "PodDisruptionBudget", apiName: "poddisruptionbudgets" },
|
||||
{ kind: "PodSecurityPolicy", apiName: "podsecuritypolicies" },
|
||||
{ kind: "ResourceQuota", apiName: "resourcequotas" },
|
||||
{ kind: "ReplicaSet", apiName: "replicasets", group: "apps" },
|
||||
{ kind: "Secret", apiName: "secrets" },
|
||||
{ kind: "Service", apiName: "services" },
|
||||
{ kind: "StatefulSet", apiName: "statefulsets", group: "apps" },
|
||||
{ kind: "StorageClass", apiName: "storageclasses", group: "storage.k8s.io" },
|
||||
];
|
||||
|
||||
export function isAllowedResource(resources: KubeResource | KubeResource[]) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { action, computed, observable } from "mobx";
|
||||
import { action, computed, observable,reaction } from "mobx";
|
||||
import { dockStore } from "../renderer/components/dock/dock.store";
|
||||
import { autobind } from "../renderer/utils";
|
||||
|
||||
export class SearchStore {
|
||||
@@ -6,6 +7,12 @@ export class SearchStore {
|
||||
@observable occurrences: number[] = []; // Array with line numbers, eg [0, 0, 10, 21, 21, 40...]
|
||||
@observable activeOverlayIndex = -1; // Index withing the occurences array. Showing where is activeOverlay currently located
|
||||
|
||||
constructor() {
|
||||
reaction(() => dockStore.selectedTabId, () => {
|
||||
searchStore.reset();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets default activeOverlayIndex
|
||||
* @param text An array of any textual data (logs, for example)
|
||||
@@ -133,4 +140,4 @@ export class SearchStore {
|
||||
}
|
||||
}
|
||||
|
||||
export const searchStore = new SearchStore;
|
||||
export const searchStore = new SearchStore;
|
||||
@@ -28,6 +28,7 @@ export interface UserPreferences {
|
||||
downloadBinariesPath?: string;
|
||||
kubectlBinariesPath?: string;
|
||||
openAtLogin?: boolean;
|
||||
hiddenTableColumns?: Record<string, string[]>
|
||||
}
|
||||
|
||||
export class UserStore extends BaseStore<UserStoreModel> {
|
||||
@@ -54,6 +55,7 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
downloadMirror: "default",
|
||||
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
|
||||
openAtLogin: false,
|
||||
hiddenTableColumns: {},
|
||||
};
|
||||
|
||||
protected async handleOnLoad() {
|
||||
@@ -82,6 +84,15 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
return semver.gt(getAppVersion(), this.lastSeenAppVersion);
|
||||
}
|
||||
|
||||
@action
|
||||
setHiddenTableColumns(tableId: string, names: Set<string> | string[]) {
|
||||
this.preferences.hiddenTableColumns[tableId] = Array.from(names);
|
||||
}
|
||||
|
||||
getHiddenTableColumns(tableId: string): Set<string> {
|
||||
return new Set(this.preferences.hiddenTableColumns[tableId]);
|
||||
}
|
||||
|
||||
@action
|
||||
resetKubeConfigPath() {
|
||||
this.kubeConfigPath = kubeConfigDefaultPath;
|
||||
|
||||
@@ -28,4 +28,4 @@ describe("split array on element tests", () => {
|
||||
test("ten elements, in end array", () => {
|
||||
expect(splitArray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 9)).toStrictEqual([[0, 1, 2, 3, 4, 5, 6, 7, 8], [], true]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
// Create async delay for provided timeout in milliseconds
|
||||
|
||||
export async function delay(timeoutMs = 1000) {
|
||||
if (!timeoutMs) return;
|
||||
await new Promise(resolve => setTimeout(resolve, timeoutMs));
|
||||
}
|
||||
@@ -7,6 +7,7 @@ export * from "./autobind";
|
||||
export * from "./base64";
|
||||
export * from "./camelCase";
|
||||
export * from "./cloneJson";
|
||||
export * from "./delay";
|
||||
export * from "./debouncePromise";
|
||||
export * from "./defineGlobal";
|
||||
export * from "./getRandId";
|
||||
|
||||
@@ -26,4 +26,4 @@ class Singleton {
|
||||
}
|
||||
|
||||
export { Singleton };
|
||||
export default Singleton;
|
||||
export default Singleton;
|
||||
@@ -58,14 +58,7 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
||||
* @observable
|
||||
*/
|
||||
@observable ownerRef?: string;
|
||||
/**
|
||||
* Is workspace enabled
|
||||
*
|
||||
* Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace.
|
||||
*
|
||||
* @observable
|
||||
*/
|
||||
@observable enabled: boolean;
|
||||
|
||||
/**
|
||||
* Last active cluster id
|
||||
*
|
||||
@@ -73,6 +66,9 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
||||
*/
|
||||
@observable lastActiveClusterId?: ClusterId;
|
||||
|
||||
|
||||
@observable private _enabled: boolean;
|
||||
|
||||
constructor(data: WorkspaceModel) {
|
||||
Object.assign(this, data);
|
||||
|
||||
@@ -83,6 +79,21 @@ export class Workspace implements WorkspaceModel, WorkspaceState {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is workspace enabled
|
||||
*
|
||||
* Workspaces that don't have ownerRef will be enabled by default. Workspaces with ownerRef need to explicitly enable a workspace.
|
||||
*
|
||||
* @observable
|
||||
*/
|
||||
get enabled(): boolean {
|
||||
return !this.isManaged || this._enabled;
|
||||
}
|
||||
|
||||
set enabled(enabled: boolean) {
|
||||
this._enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is workspace managed by an extension
|
||||
*/
|
||||
@@ -134,10 +145,18 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
||||
static readonly defaultId: WorkspaceId = "default";
|
||||
private static stateRequestChannel = "workspace:states";
|
||||
|
||||
@observable currentWorkspaceId = WorkspaceStore.defaultId;
|
||||
@observable workspaces = observable.map<WorkspaceId, Workspace>();
|
||||
|
||||
private constructor() {
|
||||
super({
|
||||
configName: "lens-workspace-store",
|
||||
});
|
||||
|
||||
this.workspaces.set(WorkspaceStore.defaultId, new Workspace({
|
||||
id: WorkspaceStore.defaultId,
|
||||
name: "default"
|
||||
}));
|
||||
}
|
||||
|
||||
async load() {
|
||||
@@ -186,15 +205,6 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
|
||||
ipcRenderer.removeAllListeners("workspace:state");
|
||||
}
|
||||
|
||||
@observable currentWorkspaceId = WorkspaceStore.defaultId;
|
||||
|
||||
@observable workspaces = observable.map<WorkspaceId, Workspace>({
|
||||
[WorkspaceStore.defaultId]: new Workspace({
|
||||
id: WorkspaceStore.defaultId,
|
||||
name: "default"
|
||||
})
|
||||
});
|
||||
|
||||
@computed get currentWorkspace(): Workspace {
|
||||
return this.getById(this.currentWorkspaceId);
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from "./registrations";
|
||||
export * from "./registrations";
|
||||
@@ -5,4 +5,4 @@ export type { KubeObjectMenuRegistration, KubeObjectMenuComponents } from "../re
|
||||
export type { KubeObjectStatusRegistration } from "../registries/kube-object-status-registry";
|
||||
export type { PageRegistration, RegisteredPage, PageParams, PageComponentProps, PageComponents, PageTarget } from "../registries/page-registry";
|
||||
export type { PageMenuRegistration, ClusterPageMenuRegistration, PageMenuComponents } from "../registries/page-menu-registry";
|
||||
export type { StatusBarRegistration } from "../registries/status-bar-registry";
|
||||
export type { StatusBarRegistration } from "../registries/status-bar-registry";
|
||||
@@ -38,4 +38,4 @@ export * from "../../renderer/components/+events/kube-event-details";
|
||||
// specific exports
|
||||
export * from "../../renderer/components/status-brick";
|
||||
export { terminalStore, createTerminalTab } from "../../renderer/components/dock/terminal.store";
|
||||
export { createPodLogsTab } from "../../renderer/components/dock/pod-logs.store";
|
||||
export { logTabStore } from "../../renderer/components/dock/log-tab.store";
|
||||
@@ -14,6 +14,7 @@ export { ConfigMap, configMapApi } from "../../renderer/api/endpoints";
|
||||
export { Secret, secretsApi, ISecretRef } from "../../renderer/api/endpoints";
|
||||
export { ReplicaSet, replicaSetApi } from "../../renderer/api/endpoints";
|
||||
export { ResourceQuota, resourceQuotaApi } from "../../renderer/api/endpoints";
|
||||
export { LimitRange, limitRangeApi } from "../../renderer/api/endpoints";
|
||||
export { HorizontalPodAutoscaler, hpaApi } from "../../renderer/api/endpoints";
|
||||
export { PodDisruptionBudget, pdbApi } from "../../renderer/api/endpoints";
|
||||
export { Service, serviceApi } from "../../renderer/api/endpoints";
|
||||
@@ -46,6 +47,7 @@ export type { ConfigMapsStore } from "../../renderer/components/+config-maps/con
|
||||
export type { SecretsStore } from "../../renderer/components/+config-secrets/secrets.store";
|
||||
export type { ReplicaSetStore } from "../../renderer/components/+workloads-replicasets/replicasets.store";
|
||||
export type { ResourceQuotasStore } from "../../renderer/components/+config-resource-quotas/resource-quotas.store";
|
||||
export type { LimitRangesStore } from "../../renderer/components/+config-limit-ranges/limit-ranges.store";
|
||||
export type { HPAStore } from "../../renderer/components/+config-autoscalers/hpa.store";
|
||||
export type { PodDisruptionBudgetsStore } from "../../renderer/components/+config-pod-disruption-budgets/pod-disruption-budgets.store";
|
||||
export type { ServiceStore } from "../../renderer/components/+network-services/services.store";
|
||||
|
||||
@@ -8,4 +8,4 @@ export enum KubeObjectStatusLevel {
|
||||
INFO = 1,
|
||||
WARNING = 2,
|
||||
CRITICAL = 3
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,4 @@ import { themeStore } from "../../renderer/theme.store";
|
||||
|
||||
export function getActiveTheme() {
|
||||
return themeStore.activeTheme;
|
||||
}
|
||||
}
|
||||
@@ -31,4 +31,4 @@ export class BaseClusterDetector {
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,4 @@ export class ClusterIdDetector extends BaseClusterDetector {
|
||||
|
||||
return response.metadata.uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,4 +48,4 @@ detectorRegistry.add(ClusterIdDetector);
|
||||
detectorRegistry.add(LastSeenDetector);
|
||||
detectorRegistry.add(VersionDetector);
|
||||
detectorRegistry.add(DistributionDetector);
|
||||
detectorRegistry.add(NodesCountDetector);
|
||||
detectorRegistry.add(NodesCountDetector);
|
||||
@@ -11,4 +11,4 @@ export class LastSeenDetector extends BaseClusterDetector {
|
||||
|
||||
return { value: new Date().toJSON(), accuracy: 100 };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,4 +16,4 @@ export class NodesCountDetector extends BaseClusterDetector {
|
||||
|
||||
return response.items.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,4 +16,4 @@ export class VersionDetector extends BaseClusterDetector {
|
||||
|
||||
return response.gitVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export class ClusterManager extends Singleton {
|
||||
// auto-init clusters
|
||||
autorun(() => {
|
||||
clusterStore.enabledClustersList.forEach(cluster => {
|
||||
if (!cluster.initialized) {
|
||||
if (!cluster.initialized && !cluster.initializing) {
|
||||
logger.info(`[CLUSTER-MANAGER]: init cluster`, cluster.getMeta());
|
||||
cluster.init(port);
|
||||
}
|
||||
|
||||
+40
-12
@@ -84,6 +84,14 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
whenInitialized = when(() => this.initialized);
|
||||
whenReady = when(() => this.ready);
|
||||
|
||||
/**
|
||||
* Is cluster object initializinng on-going
|
||||
*
|
||||
* @observable
|
||||
*/
|
||||
@observable initializing = false;
|
||||
|
||||
|
||||
/**
|
||||
* Is cluster object initialized
|
||||
*
|
||||
@@ -182,7 +190,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
*/
|
||||
@observable metadata: ClusterMetadata = {};
|
||||
/**
|
||||
* List of allowed namespaces
|
||||
* List of allowed namespaces verified via K8S::SelfSubjectAccessReview api
|
||||
*
|
||||
* @observable
|
||||
*/
|
||||
@@ -195,7 +203,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
*/
|
||||
@observable allowedResources: string[] = [];
|
||||
/**
|
||||
* List of accessible namespaces
|
||||
* List of accessible namespaces provided by user in the Cluster Settings
|
||||
*
|
||||
* @observable
|
||||
*/
|
||||
@@ -216,7 +224,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
* @computed
|
||||
*/
|
||||
@computed get name() {
|
||||
return this.preferences.clusterName || this.contextName;
|
||||
return this.preferences.clusterName || this.contextName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,8 +279,10 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
* @param port port where internal auth proxy is listening
|
||||
* @internal
|
||||
*/
|
||||
@action async init(port: number) {
|
||||
@action
|
||||
async init(port: number) {
|
||||
try {
|
||||
this.initializing = true;
|
||||
this.contextHandler = new ContextHandler(this);
|
||||
this.kubeconfigManager = await KubeconfigManager.create(this, this.contextHandler, port);
|
||||
this.kubeProxyUrl = `http://localhost:${port}${apiKubePrefix}`;
|
||||
@@ -287,6 +297,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
id: this.id,
|
||||
error: err,
|
||||
});
|
||||
} finally {
|
||||
this.initializing = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +335,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
* @param force force activation
|
||||
* @internal
|
||||
*/
|
||||
@action async activate(force = false) {
|
||||
@action
|
||||
async activate(force = false) {
|
||||
if (this.activated && !force) {
|
||||
return this.pushState();
|
||||
}
|
||||
@@ -362,7 +375,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@action async reconnect() {
|
||||
@action
|
||||
async reconnect() {
|
||||
logger.info(`[CLUSTER]: reconnect`, this.getMeta());
|
||||
this.contextHandler?.stopServer();
|
||||
await this.contextHandler?.ensureServer();
|
||||
@@ -389,7 +403,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
* @internal
|
||||
* @param opts refresh options
|
||||
*/
|
||||
@action async refresh(opts: ClusterRefreshOptions = {}) {
|
||||
@action
|
||||
async refresh(opts: ClusterRefreshOptions = {}) {
|
||||
logger.info(`[CLUSTER]: refresh`, this.getMeta());
|
||||
await this.whenInitialized;
|
||||
await this.refreshConnectionStatus();
|
||||
@@ -409,7 +424,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@action async refreshMetadata() {
|
||||
@action
|
||||
async refreshMetadata() {
|
||||
logger.info(`[CLUSTER]: refreshMetadata`, this.getMeta());
|
||||
const metadata = await detectorRegistry.detectForCluster(this);
|
||||
const existingMetadata = this.metadata;
|
||||
@@ -420,7 +436,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@action async refreshConnectionStatus() {
|
||||
@action
|
||||
async refreshConnectionStatus() {
|
||||
const connectionStatus = await this.getConnectionStatus();
|
||||
|
||||
this.online = connectionStatus > ClusterStatus.Offline;
|
||||
@@ -430,7 +447,8 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@action async refreshAllowedResources() {
|
||||
@action
|
||||
async refreshAllowedResources() {
|
||||
this.allowedNamespaces = await this.getAllowedNamespaces();
|
||||
this.allowedResources = await this.getAllowedResources();
|
||||
}
|
||||
@@ -657,7 +675,7 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
for (const namespace of this.allowedNamespaces.slice(0, 10)) {
|
||||
if (!this.resourceAccessStatuses.get(apiResource)) {
|
||||
const result = await this.canI({
|
||||
resource: apiResource.resource,
|
||||
resource: apiResource.apiName,
|
||||
group: apiResource.group,
|
||||
verb: "list",
|
||||
namespace
|
||||
@@ -672,9 +690,19 @@ export class Cluster implements ClusterModel, ClusterState {
|
||||
|
||||
return apiResources
|
||||
.filter((resource) => this.resourceAccessStatuses.get(resource))
|
||||
.map(apiResource => apiResource.resource);
|
||||
.map(apiResource => apiResource.apiName);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
isAllowedResource(kind: string): boolean {
|
||||
const apiResource = apiResources.find(resource => resource.kind === kind || resource.apiName === kind);
|
||||
|
||||
if (apiResource) {
|
||||
return this.allowedResources.includes(apiResource.apiName);
|
||||
}
|
||||
|
||||
return true; // allowed by default for other resources
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -23,10 +23,10 @@ const kubectlMap: Map<string, string> = new Map([
|
||||
["1.14", "1.14.10"],
|
||||
["1.15", "1.15.11"],
|
||||
["1.16", "1.16.15"],
|
||||
["1.17", bundledVersion],
|
||||
["1.18", "1.18.14"],
|
||||
["1.19", "1.19.5"],
|
||||
["1.20", "1.20.0"]
|
||||
["1.17", "1.17.17"],
|
||||
["1.18", bundledVersion],
|
||||
["1.19", "1.19.7"],
|
||||
["1.20", "1.20.2"]
|
||||
]);
|
||||
const packageMirrors: Map<string, string> = new Map([
|
||||
["default", "https://storage.googleapis.com/kubernetes-release/release"],
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ export class Router {
|
||||
this.router.add({ method: "get", path: `${apiPrefix}/kubeconfig/service-account/{namespace}/{account}` }, kubeconfigRoute.routeServiceAccountRoute.bind(kubeconfigRoute));
|
||||
|
||||
// Watch API
|
||||
this.router.add({ method: "get", path: `${apiPrefix}/watch` }, watchRoute.routeWatch.bind(watchRoute));
|
||||
this.router.add({ method: "post", path: `${apiPrefix}/watch` }, watchRoute.routeWatch.bind(watchRoute));
|
||||
|
||||
// Metrics API
|
||||
this.router.add({ method: "post", path: `${apiPrefix}/metrics` }, metricsRoute.routeMetrics.bind(metricsRoute));
|
||||
|
||||
@@ -1,10 +1,29 @@
|
||||
import type { KubeJsonApiData, KubeJsonApiError } from "../../renderer/api/kube-json-api";
|
||||
|
||||
import plimit from "p-limit";
|
||||
import { delay } from "../../common/utils";
|
||||
import { LensApiRequest } from "../router";
|
||||
import { LensApi } from "../lens-api";
|
||||
import { Watch, KubeConfig } from "@kubernetes/client-node";
|
||||
import { KubeConfig, Watch } from "@kubernetes/client-node";
|
||||
import { ServerResponse } from "http";
|
||||
import { Request } from "request";
|
||||
import logger from "../logger";
|
||||
|
||||
export interface IKubeWatchEvent<T = KubeJsonApiData | KubeJsonApiError> {
|
||||
type: "ADDED" | "MODIFIED" | "DELETED" | "ERROR" | "STREAM_END";
|
||||
object?: T;
|
||||
}
|
||||
|
||||
export interface IKubeWatchEventStreamEnd extends IKubeWatchEvent {
|
||||
type: "STREAM_END";
|
||||
url: string;
|
||||
status: number;
|
||||
}
|
||||
|
||||
export interface IWatchRoutePayload {
|
||||
apis: string[]; // kube-api url list for subscribing to watch events
|
||||
}
|
||||
|
||||
class ApiWatcher {
|
||||
private apiUrl: string;
|
||||
private response: ServerResponse;
|
||||
@@ -24,6 +43,7 @@ class ApiWatcher {
|
||||
clearInterval(this.processor);
|
||||
}
|
||||
this.processor = setInterval(() => {
|
||||
if (this.response.finished) return;
|
||||
const events = this.eventBuffer.splice(0);
|
||||
|
||||
events.map(event => this.sendEvent(event));
|
||||
@@ -33,7 +53,9 @@ class ApiWatcher {
|
||||
}
|
||||
|
||||
public stop() {
|
||||
if (!this.watchRequest) { return; }
|
||||
if (!this.watchRequest) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.processor) {
|
||||
clearInterval(this.processor);
|
||||
@@ -42,11 +64,14 @@ class ApiWatcher {
|
||||
|
||||
try {
|
||||
this.watchRequest.abort();
|
||||
this.sendEvent({
|
||||
|
||||
const event: IKubeWatchEventStreamEnd = {
|
||||
type: "STREAM_END",
|
||||
url: this.apiUrl,
|
||||
status: 410,
|
||||
});
|
||||
};
|
||||
|
||||
this.sendEvent(event);
|
||||
logger.debug("watch aborted");
|
||||
} catch (error) {
|
||||
logger.error(`Watch abort errored:${error}`);
|
||||
@@ -65,50 +90,72 @@ class ApiWatcher {
|
||||
this.watchRequest.abort();
|
||||
}
|
||||
|
||||
private sendEvent(evt: any) {
|
||||
// convert to "text/event-stream" format
|
||||
this.response.write(`data: ${JSON.stringify(evt)}\n\n`);
|
||||
private sendEvent(evt: IKubeWatchEvent) {
|
||||
this.response.write(`${JSON.stringify(evt)}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
class WatchRoute extends LensApi {
|
||||
private response: ServerResponse;
|
||||
|
||||
public async routeWatch(request: LensApiRequest) {
|
||||
const { response, cluster} = request;
|
||||
const apis: string[] = request.query.getAll("api");
|
||||
const watchers: ApiWatcher[] = [];
|
||||
private setResponse(response: ServerResponse) {
|
||||
// clean up previous connection and stop all corresponding watch-api requests
|
||||
// otherwise it happens only by request timeout or something else..
|
||||
this.response?.destroy();
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
if (!apis.length) {
|
||||
public async routeWatch(request: LensApiRequest<IWatchRoutePayload>) {
|
||||
const { response, cluster, payload: { apis } = {} } = request;
|
||||
|
||||
if (!apis?.length) {
|
||||
this.respondJson(response, {
|
||||
message: "Empty request. Query params 'api' are not provided.",
|
||||
example: "?api=/api/v1/pods&api=/api/v1/nodes",
|
||||
message: "watch apis list is empty"
|
||||
}, 400);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
response.setHeader("Content-Type", "text/event-stream");
|
||||
this.setResponse(response);
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setHeader("Connection", "keep-alive");
|
||||
logger.debug(`watch using kubeconfig:${JSON.stringify(cluster.getProxyKubeconfig(), null, 2)}`);
|
||||
|
||||
// limit concurrent k8s requests to avoid possible ECONNRESET-error
|
||||
const requests = plimit(5);
|
||||
const watchers = new Map<string, ApiWatcher>();
|
||||
let isWatchRequestEnded = false;
|
||||
|
||||
apis.forEach(apiUrl => {
|
||||
const watcher = new ApiWatcher(apiUrl, cluster.getProxyKubeconfig(), response);
|
||||
|
||||
watcher.start();
|
||||
watchers.push(watcher);
|
||||
watchers.set(apiUrl, watcher);
|
||||
|
||||
requests(async () => {
|
||||
if (isWatchRequestEnded) return;
|
||||
await watcher.start();
|
||||
await delay(100);
|
||||
});
|
||||
});
|
||||
|
||||
function onRequestEnd() {
|
||||
if (isWatchRequestEnded) return;
|
||||
isWatchRequestEnded = true;
|
||||
requests.clearQueue();
|
||||
watchers.forEach(watcher => watcher.stop());
|
||||
watchers.clear();
|
||||
}
|
||||
|
||||
request.raw.req.on("end", () => {
|
||||
logger.info("Watch request end");
|
||||
onRequestEnd();
|
||||
});
|
||||
|
||||
request.raw.req.on("close", () => {
|
||||
logger.debug("Watch request closed");
|
||||
watchers.map(watcher => watcher.stop());
|
||||
logger.info("Watch request close");
|
||||
onRequestEnd();
|
||||
});
|
||||
|
||||
request.raw.req.on("end", () => {
|
||||
logger.debug("Watch request ended");
|
||||
watchers.map(watcher => watcher.stop());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,4 +18,4 @@ export default {
|
||||
...version270Beta1,
|
||||
...version360Beta1,
|
||||
...snap
|
||||
};
|
||||
};
|
||||
@@ -79,4 +79,4 @@ describe("KubeApi", () => {
|
||||
expect(kubeApi.apiPrefix).toEqual("/apis");
|
||||
expect(kubeApi.apiGroup).toEqual("extensions");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@ import type { KubeObjectStore } from "../kube-object.store";
|
||||
|
||||
import { action, observable } from "mobx";
|
||||
import { autobind } from "../utils";
|
||||
import { KubeApi } from "./kube-api";
|
||||
import { KubeApi, parseKubeApi } from "./kube-api";
|
||||
|
||||
@autobind()
|
||||
export class ApiManager {
|
||||
@@ -11,7 +11,7 @@ export class ApiManager {
|
||||
|
||||
getApi(pathOrCallback: string | ((api: KubeApi) => boolean)) {
|
||||
if (typeof pathOrCallback === "string") {
|
||||
return this.apis.get(pathOrCallback) || this.apis.get(KubeApi.parseApi(pathOrCallback).apiBase);
|
||||
return this.apis.get(pathOrCallback) || this.apis.get(parseKubeApi(pathOrCallback).apiBase);
|
||||
}
|
||||
|
||||
return Array.from(this.apis.values()).find(pathOrCallback ?? (() => true));
|
||||
|
||||
@@ -86,7 +86,7 @@ export class HelmChart {
|
||||
tillerVersion?: string;
|
||||
|
||||
getId() {
|
||||
return this.digest;
|
||||
return `${this.apiVersion}/${this.name}@${this.getAppVersion()}`;
|
||||
}
|
||||
|
||||
getName() {
|
||||
|
||||
@@ -14,6 +14,7 @@ export * from "./events.api";
|
||||
export * from "./hpa.api";
|
||||
export * from "./ingress.api";
|
||||
export * from "./job.api";
|
||||
export * from "./limit-range.api";
|
||||
export * from "./namespaces.api";
|
||||
export * from "./network-policy.api";
|
||||
export * from "./nodes.api";
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { KubeObject } from "../kube-object";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import { autobind } from "../../utils";
|
||||
|
||||
export enum LimitType {
|
||||
CONTAINER = "Container",
|
||||
POD = "Pod",
|
||||
PVC = "PersistentVolumeClaim",
|
||||
}
|
||||
|
||||
export enum Resource {
|
||||
MEMORY = "memory",
|
||||
CPU = "cpu",
|
||||
STORAGE = "storage",
|
||||
EPHEMERAL_STORAGE = "ephemeral-storage",
|
||||
}
|
||||
|
||||
export enum LimitPart {
|
||||
MAX = "max",
|
||||
MIN = "min",
|
||||
DEFAULT = "default",
|
||||
DEFAULT_REQUEST = "defaultRequest",
|
||||
MAX_LIMIT_REQUEST_RATIO = "maxLimitRequestRatio",
|
||||
}
|
||||
|
||||
type LimitRangeParts = Partial<Record<LimitPart, Record<string, string>>>;
|
||||
|
||||
export interface LimitRangeItem extends LimitRangeParts {
|
||||
type: string
|
||||
}
|
||||
|
||||
@autobind()
|
||||
export class LimitRange extends KubeObject {
|
||||
static kind = "LimitRange";
|
||||
static namespaced = true;
|
||||
static apiBase = "/api/v1/limitranges";
|
||||
|
||||
spec: {
|
||||
limits: LimitRangeItem[];
|
||||
};
|
||||
|
||||
getContainerLimits() {
|
||||
return this.spec.limits.filter(limit => limit.type === LimitType.CONTAINER);
|
||||
}
|
||||
|
||||
getPodLimits() {
|
||||
return this.spec.limits.filter(limit => limit.type === LimitType.POD);
|
||||
}
|
||||
|
||||
getPVCLimits() {
|
||||
return this.spec.limits.filter(limit => limit.type === LimitType.PVC);
|
||||
}
|
||||
}
|
||||
|
||||
export const limitRangeApi = new KubeApi({
|
||||
objectConstructor: LimitRange,
|
||||
});
|
||||
@@ -92,14 +92,6 @@ export function ensureObjectSelfLink(api: KubeApi, object: KubeJsonApiData) {
|
||||
}
|
||||
|
||||
export class KubeApi<T extends KubeObject = any> {
|
||||
static parseApi = parseKubeApi;
|
||||
|
||||
static watchAll(...apis: KubeApi[]) {
|
||||
const disposers = apis.map(api => api.watch());
|
||||
|
||||
return () => disposers.forEach(unwatch => unwatch());
|
||||
}
|
||||
|
||||
readonly kind: string;
|
||||
readonly apiBase: string;
|
||||
readonly apiPrefix: string;
|
||||
@@ -124,7 +116,7 @@ export class KubeApi<T extends KubeObject = any> {
|
||||
if (!options.apiBase) {
|
||||
options.apiBase = objectConstructor.apiBase;
|
||||
}
|
||||
const { apiBase, apiPrefix, apiGroup, apiVersion, resource } = KubeApi.parseApi(options.apiBase);
|
||||
const { apiBase, apiPrefix, apiGroup, apiVersion, resource } = parseKubeApi(options.apiBase);
|
||||
|
||||
this.kind = kind;
|
||||
this.isNamespaced = isNamespaced;
|
||||
@@ -157,7 +149,7 @@ export class KubeApi<T extends KubeObject = any> {
|
||||
|
||||
for (const apiUrl of apiBases) {
|
||||
// Split e.g. "/apis/extensions/v1beta1/ingresses" to parts
|
||||
const { apiPrefix, apiGroup, apiVersionWithGroup, resource } = KubeApi.parseApi(apiUrl);
|
||||
const { apiPrefix, apiGroup, apiVersionWithGroup, resource } = parseKubeApi(apiUrl);
|
||||
|
||||
// Request available resources
|
||||
try {
|
||||
@@ -366,7 +358,7 @@ export class KubeApi<T extends KubeObject = any> {
|
||||
}
|
||||
|
||||
watch(): () => void {
|
||||
return kubeWatchApi.subscribe(this);
|
||||
return kubeWatchApi.subscribeApi(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface KubeJsonApiData extends JsonApiData {
|
||||
resourceVersion: string;
|
||||
continue?: string;
|
||||
finalizers?: string[];
|
||||
selfLink: string;
|
||||
selfLink?: string;
|
||||
labels?: {
|
||||
[label: string]: string;
|
||||
};
|
||||
|
||||
+291
-126
@@ -1,184 +1,349 @@
|
||||
// Kubernetes watch-api consumer
|
||||
// Kubernetes watch-api client
|
||||
// API: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams
|
||||
|
||||
import { computed, observable, reaction } from "mobx";
|
||||
import { stringify } from "querystring";
|
||||
import { autobind, EventEmitter } from "../utils";
|
||||
import { KubeJsonApiData } from "./kube-json-api";
|
||||
import type { Cluster } from "../../main/cluster";
|
||||
import type { IKubeWatchEvent, IKubeWatchEventStreamEnd, IWatchRoutePayload } from "../../main/routes/watch-route";
|
||||
import type { KubeObject } from "./kube-object";
|
||||
import type { KubeObjectStore } from "../kube-object.store";
|
||||
import { ensureObjectSelfLink, KubeApi } from "./kube-api";
|
||||
import type { NamespaceStore } from "../components/+namespaces/namespace.store";
|
||||
|
||||
import plimit from "p-limit";
|
||||
import debounce from "lodash/debounce";
|
||||
import { comparer, computed, observable, reaction } from "mobx";
|
||||
import { autobind, EventEmitter } from "../utils";
|
||||
import { ensureObjectSelfLink, KubeApi, parseKubeApi } from "./kube-api";
|
||||
import { KubeJsonApiData, KubeJsonApiError } from "./kube-json-api";
|
||||
import { apiPrefix, isDebugging, isProduction } from "../../common/vars";
|
||||
import { apiManager } from "./api-manager";
|
||||
import { apiPrefix, isDevelopment } from "../../common/vars";
|
||||
import { getHostedCluster } from "../../common/cluster-store";
|
||||
|
||||
export interface IKubeWatchEvent<T = any> {
|
||||
type: "ADDED" | "MODIFIED" | "DELETED";
|
||||
object?: T;
|
||||
export { IKubeWatchEvent, IKubeWatchEventStreamEnd };
|
||||
|
||||
export interface IKubeWatchMessage<T extends KubeObject = any> {
|
||||
data?: IKubeWatchEvent<KubeJsonApiData>
|
||||
error?: IKubeWatchEvent<KubeJsonApiError>;
|
||||
api?: KubeApi<T>;
|
||||
store?: KubeObjectStore<T>;
|
||||
}
|
||||
|
||||
export interface IKubeWatchRouteEvent {
|
||||
type: "STREAM_END";
|
||||
url: string;
|
||||
status: number;
|
||||
export interface IKubeWatchSubscribeStoreOptions {
|
||||
preload?: boolean; // preload store items, default: true
|
||||
waitUntilLoaded?: boolean; // subscribe only after loading all stores, default: true
|
||||
cacheLoading?: boolean; // when enabled loading store will be skipped, default: false
|
||||
}
|
||||
|
||||
export interface IKubeWatchRouteQuery {
|
||||
api: string | string[];
|
||||
export interface IKubeWatchReconnectOptions {
|
||||
reconnectAttempts: number;
|
||||
timeout: number;
|
||||
}
|
||||
|
||||
export interface IKubeWatchLog {
|
||||
message: string | Error;
|
||||
meta?: object;
|
||||
}
|
||||
|
||||
@autobind()
|
||||
export class KubeWatchApi {
|
||||
protected evtSource: EventSource;
|
||||
protected onData = new EventEmitter<[IKubeWatchEvent]>();
|
||||
protected subscribers = observable.map<KubeApi, number>();
|
||||
protected reconnectTimeoutMs = 5000;
|
||||
protected maxReconnectsOnError = 10;
|
||||
protected reconnectAttempts = this.maxReconnectsOnError;
|
||||
private cluster: Cluster;
|
||||
private namespaceStore: NamespaceStore;
|
||||
|
||||
constructor() {
|
||||
reaction(() => this.activeApis, () => this.connect(), {
|
||||
fireImmediately: true,
|
||||
delay: 500,
|
||||
});
|
||||
private requestId = 0;
|
||||
private isConnected = false;
|
||||
private reader: ReadableStreamReader<string>;
|
||||
private subscribers = observable.map<KubeApi, number>();
|
||||
|
||||
// events
|
||||
public onMessage = new EventEmitter<[IKubeWatchMessage]>();
|
||||
|
||||
@computed get isActive(): boolean {
|
||||
return this.apis.length > 0;
|
||||
}
|
||||
|
||||
@computed get activeApis() {
|
||||
return Array.from(this.subscribers.keys());
|
||||
@computed get apis(): string[] {
|
||||
const { cluster, namespaceStore } = this;
|
||||
const activeApis = Array.from(this.subscribers.keys());
|
||||
|
||||
return activeApis.map(api => {
|
||||
if (!cluster.isAllowedResource(api.kind)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (api.isNamespaced) {
|
||||
return namespaceStore.getContextNamespaces().map(namespace => api.getWatchUrl(namespace));
|
||||
} else {
|
||||
return api.getWatchUrl();
|
||||
}
|
||||
}).flat();
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
private async init() {
|
||||
const { getHostedCluster } = await import("../../common/cluster-store");
|
||||
const { namespaceStore } = await import("../components/+namespaces/namespace.store");
|
||||
|
||||
await namespaceStore.whenReady;
|
||||
|
||||
this.cluster = getHostedCluster();
|
||||
this.namespaceStore = namespaceStore;
|
||||
this.bindAutoConnect();
|
||||
}
|
||||
|
||||
private bindAutoConnect() {
|
||||
const connect = debounce(() => this.connect(), 1000);
|
||||
|
||||
reaction(() => this.apis, connect, {
|
||||
fireImmediately: true,
|
||||
equals: comparer.structural,
|
||||
});
|
||||
|
||||
window.addEventListener("online", () => this.connect());
|
||||
window.addEventListener("offline", () => this.disconnect());
|
||||
setInterval(() => this.connectionCheck(), 60000 * 5); // every 5m
|
||||
}
|
||||
|
||||
getSubscribersCount(api: KubeApi) {
|
||||
return this.subscribers.get(api) || 0;
|
||||
}
|
||||
|
||||
subscribe(...apis: KubeApi[]) {
|
||||
isAllowedApi(api: KubeApi): boolean {
|
||||
return !!this?.cluster.isAllowedResource(api.kind);
|
||||
}
|
||||
|
||||
subscribeApi(api: KubeApi | KubeApi[]): () => void {
|
||||
const apis: KubeApi[] = [api].flat();
|
||||
|
||||
apis.forEach(api => {
|
||||
if (!this.isAllowedApi(api)) return; // skip
|
||||
this.subscribers.set(api, this.getSubscribersCount(api) + 1);
|
||||
});
|
||||
|
||||
return () => apis.forEach(api => {
|
||||
const count = this.getSubscribersCount(api) - 1;
|
||||
return () => {
|
||||
apis.forEach(api => {
|
||||
const count = this.getSubscribersCount(api) - 1;
|
||||
|
||||
if (count <= 0) this.subscribers.delete(api);
|
||||
else this.subscribers.set(api, count);
|
||||
});
|
||||
}
|
||||
|
||||
protected getQuery(): Partial<IKubeWatchRouteQuery> {
|
||||
const { isAdmin, allowedNamespaces } = getHostedCluster();
|
||||
|
||||
return {
|
||||
api: this.activeApis.map(api => {
|
||||
if (isAdmin) return api.getWatchUrl();
|
||||
|
||||
return allowedNamespaces.map(namespace => api.getWatchUrl(namespace));
|
||||
}).flat()
|
||||
if (count <= 0) this.subscribers.delete(api);
|
||||
else this.subscribers.set(api, count);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// todo: maybe switch to websocket to avoid often reconnects
|
||||
@autobind()
|
||||
protected connect() {
|
||||
if (this.evtSource) this.disconnect(); // close previous connection
|
||||
subscribeStores(stores: KubeObjectStore[], options: IKubeWatchSubscribeStoreOptions = {}): () => void {
|
||||
const { preload = true, waitUntilLoaded = true, cacheLoading = false } = options;
|
||||
const limitRequests = plimit(1); // load stores one by one to allow quick skipping when fast clicking btw pages
|
||||
const preloading: Promise<any>[] = [];
|
||||
const apis = new Set(stores.map(store => store.getSubscribeApis()).flat());
|
||||
const unsubscribeList: (() => void)[] = [];
|
||||
let isUnsubscribed = false;
|
||||
|
||||
if (!this.activeApis.length) {
|
||||
return;
|
||||
const subscribe = () => {
|
||||
if (isUnsubscribed) return;
|
||||
apis.forEach(api => unsubscribeList.push(this.subscribeApi(api)));
|
||||
};
|
||||
|
||||
if (preload) {
|
||||
for (const store of stores) {
|
||||
preloading.push(limitRequests(async () => {
|
||||
if (cacheLoading && store.isLoaded) return; // skip
|
||||
|
||||
return store.loadAll();
|
||||
}));
|
||||
}
|
||||
}
|
||||
const query = this.getQuery();
|
||||
const apiUrl = `${apiPrefix}/watch?${stringify(query)}`;
|
||||
|
||||
this.evtSource = new EventSource(apiUrl);
|
||||
this.evtSource.onmessage = this.onMessage;
|
||||
this.evtSource.onerror = this.onError;
|
||||
this.writeLog("CONNECTING", query.api);
|
||||
if (waitUntilLoaded) {
|
||||
Promise.all(preloading).then(subscribe, error => {
|
||||
this.log({
|
||||
message: new Error("Loading stores has failed"),
|
||||
meta: { stores, error, options },
|
||||
});
|
||||
});
|
||||
} else {
|
||||
subscribe();
|
||||
}
|
||||
|
||||
// unsubscribe
|
||||
return () => {
|
||||
if (isUnsubscribed) return;
|
||||
isUnsubscribed = true;
|
||||
limitRequests.clearQueue();
|
||||
unsubscribeList.forEach(unsubscribe => unsubscribe());
|
||||
};
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
if (!this.evtSource || this.evtSource.readyState !== EventSource.OPEN) {
|
||||
this.reconnectAttempts = this.maxReconnectsOnError;
|
||||
this.connect();
|
||||
protected async connectionCheck() {
|
||||
if (!this.isConnected) {
|
||||
this.log({ message: "Offline: reconnecting.." });
|
||||
await this.connect();
|
||||
}
|
||||
|
||||
this.log({
|
||||
message: `Connection check: ${this.isConnected ? "online" : "offline"}`,
|
||||
meta: { connected: this.isConnected },
|
||||
});
|
||||
}
|
||||
|
||||
protected async connect(apis = this.apis) {
|
||||
this.disconnect(); // close active connections first
|
||||
|
||||
if (!navigator.onLine || !apis.length) {
|
||||
this.isConnected = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this.log({
|
||||
message: "Connecting",
|
||||
meta: { apis }
|
||||
});
|
||||
|
||||
try {
|
||||
const requestId = ++this.requestId;
|
||||
const abortController = new AbortController();
|
||||
|
||||
const request = await fetch(`${apiPrefix}/watch`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ apis } as IWatchRoutePayload),
|
||||
signal: abortController.signal,
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
}
|
||||
});
|
||||
|
||||
// request above is stale since new request-id has been issued
|
||||
if (this.requestId !== requestId) {
|
||||
abortController.abort();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let jsonBuffer = "";
|
||||
const stream = request.body.pipeThrough(new TextDecoderStream());
|
||||
const reader = stream.getReader();
|
||||
|
||||
this.isConnected = true;
|
||||
this.reader = reader;
|
||||
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
|
||||
if (done) break; // exit
|
||||
|
||||
const events = (jsonBuffer + value).split("\n");
|
||||
|
||||
jsonBuffer = this.processBuffer(events);
|
||||
}
|
||||
} catch (error) {
|
||||
this.log({ message: error });
|
||||
} finally {
|
||||
this.isConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected disconnect() {
|
||||
if (!this.evtSource) return;
|
||||
this.evtSource.close();
|
||||
this.evtSource.onmessage = null;
|
||||
this.evtSource = null;
|
||||
this.reader?.cancel();
|
||||
this.reader = null;
|
||||
this.isConnected = false;
|
||||
}
|
||||
|
||||
protected onMessage(evt: MessageEvent) {
|
||||
if (!evt.data) return;
|
||||
const data = JSON.parse(evt.data);
|
||||
// process received stream events, returns unprocessed buffer chunk if any
|
||||
protected processBuffer(events: string[]): string {
|
||||
for (const json of events) {
|
||||
try {
|
||||
const kubeEvent: IKubeWatchEvent = JSON.parse(json);
|
||||
const message = this.getMessage(kubeEvent);
|
||||
|
||||
if ((data as IKubeWatchEvent).object) {
|
||||
this.onData.emit(data);
|
||||
} else {
|
||||
this.onRouteEvent(data);
|
||||
this.onMessage.emit(message);
|
||||
} catch (error) {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
protected async onRouteEvent(event: IKubeWatchRouteEvent) {
|
||||
if (event.type === "STREAM_END") {
|
||||
this.disconnect();
|
||||
const { apiBase, namespace } = KubeApi.parseApi(event.url);
|
||||
const api = apiManager.getApi(apiBase);
|
||||
protected getMessage(event: IKubeWatchEvent): IKubeWatchMessage {
|
||||
const message: IKubeWatchMessage = {};
|
||||
|
||||
if (api) {
|
||||
try {
|
||||
await api.refreshResourceVersion({ namespace });
|
||||
this.reconnect();
|
||||
} catch (error) {
|
||||
console.error("failed to refresh resource version", error);
|
||||
switch (event.type) {
|
||||
case "ADDED":
|
||||
case "DELETED":
|
||||
|
||||
if (this.subscribers.size > 0) {
|
||||
setTimeout(() => {
|
||||
this.onRouteEvent(event);
|
||||
}, 1000);
|
||||
}
|
||||
case "MODIFIED": {
|
||||
const data = event as IKubeWatchEvent<KubeJsonApiData>;
|
||||
const api = apiManager.getApiByKind(data.object.kind, data.object.apiVersion);
|
||||
|
||||
message.data = data;
|
||||
|
||||
if (api) {
|
||||
ensureObjectSelfLink(api, data.object);
|
||||
|
||||
const { namespace, resourceVersion } = data.object.metadata;
|
||||
|
||||
api.setResourceVersion(namespace, resourceVersion);
|
||||
api.setResourceVersion("", resourceVersion);
|
||||
|
||||
message.api = api;
|
||||
message.store = apiManager.getStore(api);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "ERROR":
|
||||
message.error = event as IKubeWatchEvent<KubeJsonApiError>;
|
||||
break;
|
||||
|
||||
case "STREAM_END": {
|
||||
this.onServerStreamEnd(event as IKubeWatchEventStreamEnd, {
|
||||
reconnectAttempts: 5,
|
||||
timeout: 1000,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
protected async onServerStreamEnd(event: IKubeWatchEventStreamEnd, opts?: IKubeWatchReconnectOptions) {
|
||||
const { apiBase, namespace } = parseKubeApi(event.url);
|
||||
const api = apiManager.getApi(apiBase);
|
||||
|
||||
if (!api) return;
|
||||
|
||||
try {
|
||||
await api.refreshResourceVersion({ namespace });
|
||||
this.connect();
|
||||
} catch (error) {
|
||||
this.log({
|
||||
message: new Error(`Failed to connect on single stream end: ${error}`),
|
||||
meta: { event, error },
|
||||
});
|
||||
|
||||
if (this.isActive && opts?.reconnectAttempts > 0) {
|
||||
opts.reconnectAttempts--;
|
||||
setTimeout(() => this.onServerStreamEnd(event, opts), opts.timeout); // repeat event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected onError(evt: MessageEvent) {
|
||||
const { reconnectAttempts: attemptsRemain, reconnectTimeoutMs } = this;
|
||||
|
||||
if (evt.eventPhase === EventSource.CLOSED) {
|
||||
if (attemptsRemain > 0) {
|
||||
this.reconnectAttempts--;
|
||||
setTimeout(() => this.connect(), reconnectTimeoutMs);
|
||||
}
|
||||
protected log({ message, meta = {} }: IKubeWatchLog) {
|
||||
if (isProduction && !isDebugging) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected writeLog(...data: any[]) {
|
||||
if (isDevelopment) {
|
||||
console.log("%cKUBE-WATCH-API:", `font-weight: bold`, ...data);
|
||||
const logMessage = `%c[KUBE-WATCH-API]: ${String(message).toUpperCase()}`;
|
||||
const isError = message instanceof Error;
|
||||
const textStyle = `font-weight: bold;`;
|
||||
const time = new Date().toLocaleString();
|
||||
|
||||
if (isError) {
|
||||
console.error(logMessage, textStyle, { time, ...meta });
|
||||
} else {
|
||||
console.info(logMessage, textStyle, { time, ...meta });
|
||||
}
|
||||
}
|
||||
|
||||
addListener(store: KubeObjectStore, callback: (evt: IKubeWatchEvent) => void) {
|
||||
const listener = (evt: IKubeWatchEvent<KubeJsonApiData>) => {
|
||||
const { namespace, resourceVersion } = evt.object.metadata;
|
||||
const api = apiManager.getApiByKind(evt.object.kind, evt.object.apiVersion);
|
||||
|
||||
api.setResourceVersion(namespace, resourceVersion);
|
||||
api.setResourceVersion("", resourceVersion);
|
||||
|
||||
ensureObjectSelfLink(api, evt.object);
|
||||
|
||||
if (store == apiManager.getStore(api)) {
|
||||
callback(evt);
|
||||
}
|
||||
};
|
||||
|
||||
this.onData.addListener(listener);
|
||||
|
||||
return () => this.onData.removeListener(listener);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.subscribers.clear();
|
||||
}
|
||||
}
|
||||
|
||||
export const kubeWatchApi = new KubeWatchApi();
|
||||
@@ -1,7 +1,7 @@
|
||||
import get from "lodash/get";
|
||||
import { KubeObject } from "./kube-object";
|
||||
|
||||
interface IToleration {
|
||||
export interface IToleration {
|
||||
key?: string;
|
||||
operator?: string;
|
||||
effect?: string;
|
||||
@@ -82,4 +82,4 @@ export class WorkloadKubeObject extends KubeObject {
|
||||
|
||||
return Object.keys(affinity).length;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,4 @@ export interface IHelmChartsRouteParams {
|
||||
repo?: string;
|
||||
}
|
||||
|
||||
export const helmChartsURL = buildURL<IHelmChartsRouteParams>(helmChartsRoute.path);
|
||||
export const helmChartsURL = buildURL<IHelmChartsRouteParams>(helmChartsRoute.path);
|
||||
@@ -11,8 +11,11 @@ import { navigation } from "../../navigation";
|
||||
import { ItemListLayout } from "../item-object-list/item-list-layout";
|
||||
import { SearchInputUrl } from "../input";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
description = "description",
|
||||
version = "version",
|
||||
appVersion = "app-version",
|
||||
repo = "repo",
|
||||
}
|
||||
|
||||
@@ -53,13 +56,15 @@ export class HelmCharts extends Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<ItemListLayout
|
||||
isConfigurable
|
||||
tableId="helm_charts"
|
||||
className="HelmCharts"
|
||||
store={helmChartStore}
|
||||
isClusterScoped={true}
|
||||
isSelectable={false}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (chart: HelmChart) => chart.getName(),
|
||||
[sortBy.repo]: (chart: HelmChart) => chart.getRepository(),
|
||||
[columnId.name]: (chart: HelmChart) => chart.getName(),
|
||||
[columnId.repo]: (chart: HelmChart) => chart.getRepository(),
|
||||
}}
|
||||
searchFilters={[
|
||||
(chart: HelmChart) => chart.getName(),
|
||||
@@ -74,13 +79,12 @@ export class HelmCharts extends Component<Props> {
|
||||
<SearchInputUrl placeholder={`Search Helm Charts`} />
|
||||
)}
|
||||
renderTableHeader={[
|
||||
{ className: "icon" },
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ title: "Description", className: "description" },
|
||||
{ title: "Version", className: "version" },
|
||||
{ title: "App Version", className: "app-version" },
|
||||
{ title: "Repository", className: "repository", sortBy: sortBy.repo },
|
||||
|
||||
{ className: "icon", showWithColumn: columnId.name },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ title: "Description", className: "description", id: columnId.description },
|
||||
{ title: "Version", className: "version", id: columnId.version },
|
||||
{ title: "App Version", className: "app-version", id: columnId.appVersion },
|
||||
{ title: "Repository", className: "repository", sortBy: columnId.repo, id: columnId.repo },
|
||||
]}
|
||||
renderTableContents={(chart: HelmChart) => [
|
||||
<figure key="image">
|
||||
@@ -93,7 +97,8 @@ export class HelmCharts extends Component<Props> {
|
||||
chart.getDescription(),
|
||||
chart.getVersion(),
|
||||
chart.getAppVersion(),
|
||||
{ title: chart.getRepository(), className: chart.getRepository().toLowerCase() }
|
||||
{ title: chart.getRepository(), className: chart.getRepository().toLowerCase() },
|
||||
{ className: "menu" }
|
||||
]}
|
||||
detailsItem={this.selectedChart}
|
||||
onDetails={this.showDetails}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "./helm-charts";
|
||||
export * from "./helm-charts.route";
|
||||
export * from "./helm-charts.route";
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "./releases";
|
||||
export * from "./release.route";
|
||||
export * from "./release.route";
|
||||
@@ -5,7 +5,7 @@ import { HelmRelease, helmReleasesApi, IReleaseCreatePayload, IReleaseUpdatePayl
|
||||
import { ItemStore } from "../../item.store";
|
||||
import { Secret } from "../../api/endpoints";
|
||||
import { secretsStore } from "../+config-secrets/secrets.store";
|
||||
import { getHostedCluster } from "../../../common/cluster-store";
|
||||
import { namespaceStore } from "../+namespaces/namespace.store";
|
||||
|
||||
@autobind()
|
||||
export class ReleaseStore extends ItemStore<HelmRelease> {
|
||||
@@ -60,30 +60,23 @@ export class ReleaseStore extends ItemStore<HelmRelease> {
|
||||
@action
|
||||
async loadAll() {
|
||||
this.isLoading = true;
|
||||
let items;
|
||||
|
||||
try {
|
||||
const { isAdmin, allowedNamespaces } = getHostedCluster();
|
||||
const items = await this.loadItems(namespaceStore.getContextNamespaces());
|
||||
|
||||
items = await this.loadItems(!isAdmin ? allowedNamespaces : null);
|
||||
} finally {
|
||||
if (items) {
|
||||
items = this.sortItems(items);
|
||||
this.items.replace(items);
|
||||
}
|
||||
this.items.replace(this.sortItems(items));
|
||||
this.isLoaded = true;
|
||||
} catch (error) {
|
||||
console.error(`Loading Helm Chart releases has failed: ${error}`);
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async loadItems(namespaces?: string[]) {
|
||||
if (!namespaces) {
|
||||
return helmReleasesApi.list();
|
||||
} else {
|
||||
return Promise
|
||||
.all(namespaces.map(namespace => helmReleasesApi.list(namespace)))
|
||||
.then(items => items.flat());
|
||||
}
|
||||
async loadItems(namespaces: string[]) {
|
||||
return Promise
|
||||
.all(namespaces.map(namespace => helmReleasesApi.list(namespace)))
|
||||
.then(items => items.flat());
|
||||
}
|
||||
|
||||
async create(payload: IReleaseCreatePayload) {
|
||||
|
||||
@@ -14,11 +14,13 @@ import { ItemListLayout } from "../item-object-list/item-list-layout";
|
||||
import { HelmReleaseMenu } from "./release-menu";
|
||||
import { secretsStore } from "../+config-secrets/secrets.store";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
revision = "revision",
|
||||
chart = "chart",
|
||||
version = "version",
|
||||
appVersion = "app-version",
|
||||
status = "status",
|
||||
updated = "update"
|
||||
}
|
||||
@@ -81,16 +83,18 @@ export class HelmReleases extends Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<ItemListLayout
|
||||
isConfigurable
|
||||
tableId="helm_releases"
|
||||
className="HelmReleases"
|
||||
store={releaseStore}
|
||||
dependentStores={[secretsStore]}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (release: HelmRelease) => release.getName(),
|
||||
[sortBy.namespace]: (release: HelmRelease) => release.getNs(),
|
||||
[sortBy.revision]: (release: HelmRelease) => release.getRevision(),
|
||||
[sortBy.chart]: (release: HelmRelease) => release.getChart(),
|
||||
[sortBy.status]: (release: HelmRelease) => release.getStatus(),
|
||||
[sortBy.updated]: (release: HelmRelease) => release.getUpdated(false, false),
|
||||
[columnId.name]: (release: HelmRelease) => release.getName(),
|
||||
[columnId.namespace]: (release: HelmRelease) => release.getNs(),
|
||||
[columnId.revision]: (release: HelmRelease) => release.getRevision(),
|
||||
[columnId.chart]: (release: HelmRelease) => release.getChart(),
|
||||
[columnId.status]: (release: HelmRelease) => release.getStatus(),
|
||||
[columnId.updated]: (release: HelmRelease) => release.getUpdated(false, false),
|
||||
}}
|
||||
searchFilters={[
|
||||
(release: HelmRelease) => release.getName(),
|
||||
@@ -101,14 +105,14 @@ export class HelmReleases extends Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Releases"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Chart", className: "chart", sortBy: sortBy.chart },
|
||||
{ title: "Revision", className: "revision", sortBy: sortBy.revision },
|
||||
{ title: "Version", className: "version" },
|
||||
{ title: "App Version", className: "app-version" },
|
||||
{ title: "Status", className: "status", sortBy: sortBy.status },
|
||||
{ title: "Updated", className: "updated", sortBy: sortBy.updated },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Chart", className: "chart", sortBy: columnId.chart, id: columnId.chart },
|
||||
{ title: "Revision", className: "revision", sortBy: columnId.revision, id: columnId.revision },
|
||||
{ title: "Version", className: "version", id: columnId.version },
|
||||
{ title: "App Version", className: "app-version", id: columnId.appVersion },
|
||||
{ title: "Status", className: "status", sortBy: columnId.status, id: columnId.status },
|
||||
{ title: "Updated", className: "updated", sortBy: columnId.updated, id: columnId.updated },
|
||||
]}
|
||||
renderTableContents={(release: HelmRelease) => {
|
||||
const version = release.getVersion();
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "./apps";
|
||||
export * from "./apps.route";
|
||||
export * from "./apps.route";
|
||||
@@ -48,4 +48,4 @@ export class ClusterHomeDirSetting extends React.Component<Props> {
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,4 +45,4 @@ export class ClusterNameSetting extends React.Component<Props> {
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,4 +45,4 @@ export class ClusterProxySetting extends React.Component<Props> {
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,4 +25,4 @@ export class General extends React.Component<Props> {
|
||||
<ClusterAccessibleNamespaces cluster={this.props.cluster} />
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,4 @@ export class Removal extends React.Component<Props> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,4 @@ export class Status extends React.Component<Props> {
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,13 @@ interface IWarning extends ItemObject {
|
||||
kind: string;
|
||||
message: string;
|
||||
selfLink: string;
|
||||
age: string | number;
|
||||
}
|
||||
|
||||
enum sortBy {
|
||||
type = "type",
|
||||
object = "object"
|
||||
object = "object",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
@observer
|
||||
@@ -35,6 +37,7 @@ export class ClusterIssues extends React.Component<Props> {
|
||||
private sortCallbacks = {
|
||||
[sortBy.type]: (warning: IWarning) => warning.kind,
|
||||
[sortBy.object]: (warning: IWarning) => warning.getName(),
|
||||
[sortBy.age]: (warning: IWarning) => warning.age || "",
|
||||
};
|
||||
|
||||
@computed get warnings() {
|
||||
@@ -42,15 +45,16 @@ export class ClusterIssues extends React.Component<Props> {
|
||||
|
||||
// Node bad conditions
|
||||
nodesStore.items.forEach(node => {
|
||||
const { kind, selfLink, getId, getName } = node;
|
||||
const { kind, selfLink, getId, getName, getAge } = node;
|
||||
|
||||
node.getWarningConditions().forEach(({ message }) => {
|
||||
warnings.push({
|
||||
kind,
|
||||
age: getAge(),
|
||||
getId,
|
||||
getName,
|
||||
selfLink,
|
||||
kind,
|
||||
message,
|
||||
selfLink,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -59,12 +63,13 @@ export class ClusterIssues extends React.Component<Props> {
|
||||
const events = eventStore.getWarnings();
|
||||
|
||||
events.forEach(error => {
|
||||
const { message, involvedObject } = error;
|
||||
const { message, involvedObject, getAge } = error;
|
||||
const { uid, name, kind } = involvedObject;
|
||||
|
||||
warnings.push({
|
||||
getId: () => uid,
|
||||
getName: () => name,
|
||||
age: getAge(),
|
||||
message,
|
||||
kind,
|
||||
selfLink: lookupApiLink(involvedObject, error),
|
||||
@@ -78,7 +83,7 @@ export class ClusterIssues extends React.Component<Props> {
|
||||
getTableRow(uid: string) {
|
||||
const { warnings } = this;
|
||||
const warning = warnings.find(warn => warn.getId() == uid);
|
||||
const { getId, getName, message, kind, selfLink } = warning;
|
||||
const { getId, getName, message, kind, selfLink, age } = warning;
|
||||
|
||||
return (
|
||||
<TableRow
|
||||
@@ -96,6 +101,9 @@ export class ClusterIssues extends React.Component<Props> {
|
||||
<TableCell className="kind">
|
||||
{kind}
|
||||
</TableCell>
|
||||
<TableCell className="age">
|
||||
{age}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
);
|
||||
}
|
||||
@@ -139,6 +147,7 @@ export class ClusterIssues extends React.Component<Props> {
|
||||
<TableCell className="message">Message</TableCell>
|
||||
<TableCell className="object" sortBy={sortBy.object}>Object</TableCell>
|
||||
<TableCell className="kind" sortBy={sortBy.type}>Type</TableCell>
|
||||
<TableCell className="timestamp" sortBy={sortBy.age}>Age</TableCell>
|
||||
</TableHead>
|
||||
</Table>
|
||||
</>
|
||||
|
||||
@@ -95,4 +95,4 @@ export const ClusterMetrics = observer(() => {
|
||||
{renderMetrics()}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -3,13 +3,9 @@ import "./cluster-overview.scss";
|
||||
import React from "react";
|
||||
import { reaction } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
|
||||
import { eventStore } from "../+events/event.store";
|
||||
import { nodesStore } from "../+nodes/nodes.store";
|
||||
import { podsStore } from "../+workloads-pods/pods.store";
|
||||
import { getHostedCluster } from "../../../common/cluster-store";
|
||||
import { isAllowedResource } from "../../../common/rbac";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { interval } from "../../utils";
|
||||
import { TabLayout } from "../layout/tab-layout";
|
||||
import { Spinner } from "../spinner";
|
||||
@@ -17,45 +13,33 @@ import { ClusterIssues } from "./cluster-issues";
|
||||
import { ClusterMetrics } from "./cluster-metrics";
|
||||
import { clusterOverviewStore } from "./cluster-overview.store";
|
||||
import { ClusterPieCharts } from "./cluster-pie-charts";
|
||||
import { eventStore } from "../+events/event.store";
|
||||
import { kubeWatchApi } from "../../api/kube-watch-api";
|
||||
|
||||
@observer
|
||||
export class ClusterOverview extends React.Component {
|
||||
private stores: KubeObjectStore<any>[] = [];
|
||||
private subscribers: Array<() => void> = [];
|
||||
private metricPoller = interval(60, this.loadMetrics);
|
||||
|
||||
@disposeOnUnmount
|
||||
fetchMetrics = reaction(
|
||||
() => clusterOverviewStore.metricNodeRole, // Toggle Master/Worker node switcher
|
||||
() => this.metricPoller.restart(true)
|
||||
);
|
||||
private metricPoller = interval(60, () => this.loadMetrics());
|
||||
|
||||
loadMetrics() {
|
||||
getHostedCluster().available && clusterOverviewStore.loadMetrics();
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
if (isAllowedResource("nodes")) {
|
||||
this.stores.push(nodesStore);
|
||||
}
|
||||
componentDidMount() {
|
||||
this.metricPoller.start(true);
|
||||
|
||||
if (isAllowedResource("pods")) {
|
||||
this.stores.push(podsStore);
|
||||
}
|
||||
disposeOnUnmount(this, [
|
||||
kubeWatchApi.subscribeStores([nodesStore, podsStore, eventStore], {
|
||||
preload: true,
|
||||
}),
|
||||
|
||||
if (isAllowedResource("events")) {
|
||||
this.stores.push(eventStore);
|
||||
}
|
||||
|
||||
await Promise.all(this.stores.map(store => store.loadAll()));
|
||||
this.loadMetrics();
|
||||
|
||||
this.subscribers = this.stores.map(store => store.subscribe());
|
||||
this.metricPoller.start();
|
||||
reaction(
|
||||
() => clusterOverviewStore.metricNodeRole, // Toggle Master/Worker node switcher
|
||||
() => this.metricPoller.restart(true)
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.subscribers.forEach(dispose => dispose()); // unsubscribe all
|
||||
this.metricPoller.stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,13 +11,15 @@ import { Badge } from "../badge";
|
||||
import { cssNames } from "../../utils";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
metrics = "metrics",
|
||||
minPods = "min-pods",
|
||||
maxPods = "max-pods",
|
||||
replicas = "replicas",
|
||||
age = "age",
|
||||
status = "status"
|
||||
}
|
||||
|
||||
interface Props extends RouteComponentProps<IHpaRouteParams> {
|
||||
@@ -37,28 +39,30 @@ export class HorizontalPodAutoscalers extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="configuration_hpa"
|
||||
className="HorizontalPodAutoscalers" store={hpaStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: HorizontalPodAutoscaler) => item.getName(),
|
||||
[sortBy.namespace]: (item: HorizontalPodAutoscaler) => item.getNs(),
|
||||
[sortBy.minPods]: (item: HorizontalPodAutoscaler) => item.getMinPods(),
|
||||
[sortBy.maxPods]: (item: HorizontalPodAutoscaler) => item.getMaxPods(),
|
||||
[sortBy.replicas]: (item: HorizontalPodAutoscaler) => item.getReplicas()
|
||||
[columnId.name]: (item: HorizontalPodAutoscaler) => item.getName(),
|
||||
[columnId.namespace]: (item: HorizontalPodAutoscaler) => item.getNs(),
|
||||
[columnId.minPods]: (item: HorizontalPodAutoscaler) => item.getMinPods(),
|
||||
[columnId.maxPods]: (item: HorizontalPodAutoscaler) => item.getMaxPods(),
|
||||
[columnId.replicas]: (item: HorizontalPodAutoscaler) => item.getReplicas()
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: HorizontalPodAutoscaler) => item.getSearchFields()
|
||||
]}
|
||||
renderHeaderTitle="Horizontal Pod Autoscalers"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Metrics", className: "metrics" },
|
||||
{ title: "Min Pods", className: "min-pods", sortBy: sortBy.minPods },
|
||||
{ title: "Max Pods", className: "max-pods", sortBy: sortBy.maxPods },
|
||||
{ title: "Replicas", className: "replicas", sortBy: sortBy.replicas },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Status", className: "status" },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Metrics", className: "metrics", id: columnId.metrics },
|
||||
{ title: "Min Pods", className: "min-pods", sortBy: columnId.minPods, id: columnId.minPods },
|
||||
{ title: "Max Pods", className: "max-pods", sortBy: columnId.maxPods, id: columnId.maxPods },
|
||||
{ title: "Replicas", className: "replicas", sortBy: columnId.replicas, id: columnId.replicas },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
{ title: "Status", className: "status", id: columnId.status },
|
||||
]}
|
||||
renderTableContents={(hpa: HorizontalPodAutoscaler) => [
|
||||
hpa.getName(),
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from "./limit-ranges";
|
||||
export * from "./limit-ranges.route";
|
||||
export * from "./limit-range-details";
|
||||
@@ -0,0 +1,12 @@
|
||||
.LimitRangeDetails {
|
||||
|
||||
.DrawerItem {
|
||||
> .name {
|
||||
font-weight: $font-weight-normal;
|
||||
padding-left: 4px;
|
||||
}
|
||||
.DrawerItem {
|
||||
padding-top: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import "./limit-range-details.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { KubeObjectDetailsProps } from "../kube-object";
|
||||
import { LimitPart, LimitRange, LimitRangeItem, Resource } from "../../api/endpoints/limit-range.api";
|
||||
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||
import { DrawerItem } from "../drawer/drawer-item";
|
||||
import { Badge } from "../badge";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<LimitRange> {
|
||||
}
|
||||
|
||||
function renderLimit(limit: LimitRangeItem, part: LimitPart, resource: Resource) {
|
||||
|
||||
const resourceLimit = limit[part]?.[resource];
|
||||
|
||||
if (!resourceLimit) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <Badge label={`${part}:${resourceLimit}`}/>;
|
||||
}
|
||||
|
||||
function renderResourceLimits(limit: LimitRangeItem, resource: Resource) {
|
||||
return (
|
||||
<React.Fragment key={limit.type + resource}>
|
||||
{renderLimit(limit, LimitPart.MIN, resource)}
|
||||
{renderLimit(limit, LimitPart.MAX, resource)}
|
||||
{renderLimit(limit, LimitPart.DEFAULT, resource)}
|
||||
{renderLimit(limit, LimitPart.DEFAULT_REQUEST, resource)}
|
||||
{renderLimit(limit, LimitPart.MAX_LIMIT_REQUEST_RATIO, resource)}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
function renderLimitDetails(limits: LimitRangeItem[], resources: Resource[]) {
|
||||
|
||||
return resources.map(resource =>
|
||||
<DrawerItem key={resource} name={resource}>
|
||||
{
|
||||
limits.map(limit =>
|
||||
renderResourceLimits(limit, resource)
|
||||
)
|
||||
}
|
||||
</DrawerItem>
|
||||
);
|
||||
}
|
||||
|
||||
@observer
|
||||
export class LimitRangeDetails extends React.Component<Props> {
|
||||
render() {
|
||||
const { object: limitRange } = this.props;
|
||||
|
||||
if (!limitRange) return null;
|
||||
const containerLimits = limitRange.getContainerLimits();
|
||||
const podLimits = limitRange.getPodLimits();
|
||||
const pvcLimits = limitRange.getPVCLimits();
|
||||
|
||||
return (
|
||||
<div className="LimitRangeDetails">
|
||||
<KubeObjectMeta object={limitRange}/>
|
||||
|
||||
{containerLimits.length > 0 &&
|
||||
<DrawerItem name={`Container Limits`} labelsOnly>
|
||||
{
|
||||
renderLimitDetails(containerLimits, [Resource.CPU, Resource.MEMORY, Resource.EPHEMERAL_STORAGE])
|
||||
}
|
||||
</DrawerItem>
|
||||
}
|
||||
{podLimits.length > 0 &&
|
||||
<DrawerItem name={`Pod Limits`} labelsOnly>
|
||||
{
|
||||
renderLimitDetails(podLimits, [Resource.CPU, Resource.MEMORY, Resource.EPHEMERAL_STORAGE])
|
||||
}
|
||||
</DrawerItem>
|
||||
}
|
||||
{pvcLimits.length > 0 &&
|
||||
<DrawerItem name={`Persistent Volume Claim Limits`} labelsOnly>
|
||||
{
|
||||
renderLimitDetails(pvcLimits, [Resource.STORAGE])
|
||||
}
|
||||
</DrawerItem>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
kubeObjectDetailRegistry.add({
|
||||
kind: "LimitRange",
|
||||
apiVersions: ["v1"],
|
||||
components: {
|
||||
Details: (props) => <LimitRangeDetails {...props} />
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { RouteProps } from "react-router";
|
||||
import { buildURL } from "../../../common/utils/buildUrl";
|
||||
|
||||
export const limitRangesRoute: RouteProps = {
|
||||
path: "/limitranges"
|
||||
};
|
||||
|
||||
export interface LimitRangeRouteParams {
|
||||
}
|
||||
|
||||
export const limitRangeURL = buildURL<LimitRangeRouteParams>(limitRangesRoute.path);
|
||||
@@ -0,0 +1,7 @@
|
||||
.LimitRanges {
|
||||
.TableCell {
|
||||
&.warning {
|
||||
@include table-cell-warning;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { autobind } from "../../../common/utils/autobind";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { LimitRange, limitRangeApi } from "../../api/endpoints/limit-range.api";
|
||||
|
||||
@autobind()
|
||||
export class LimitRangesStore extends KubeObjectStore<LimitRange> {
|
||||
api = limitRangeApi;
|
||||
}
|
||||
|
||||
export const limitRangeStore = new LimitRangesStore();
|
||||
apiManager.registerStore(limitRangeStore);
|
||||
@@ -0,0 +1,55 @@
|
||||
import "./limit-ranges.scss";
|
||||
|
||||
import { RouteComponentProps } from "react-router";
|
||||
import { observer } from "mobx-react";
|
||||
import { KubeObjectListLayout } from "../kube-object/kube-object-list-layout";
|
||||
import { limitRangeStore } from "./limit-ranges.store";
|
||||
import { LimitRangeRouteParams } from "./limit-ranges.route";
|
||||
import React from "react";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import { LimitRange } from "../../api/endpoints/limit-range.api";
|
||||
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
interface Props extends RouteComponentProps<LimitRangeRouteParams> {
|
||||
}
|
||||
|
||||
@observer
|
||||
export class LimitRanges extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="configuration_limitranges"
|
||||
className="LimitRanges"
|
||||
store={limitRangeStore}
|
||||
sortingCallbacks={{
|
||||
[columnId.name]: (item: LimitRange) => item.getName(),
|
||||
[columnId.namespace]: (item: LimitRange) => item.getNs(),
|
||||
[columnId.age]: (item: LimitRange) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: LimitRange) => item.getName(),
|
||||
(item: LimitRange) => item.getNs(),
|
||||
]}
|
||||
renderHeaderTitle={"Limit Ranges"}
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(limitRange: LimitRange) => [
|
||||
limitRange.getName(),
|
||||
<KubeObjectStatusIcon key="icon" object={limitRange}/>,
|
||||
limitRange.getNs(),
|
||||
limitRange.getAge(),
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import { KubeObjectListLayout } from "../kube-object";
|
||||
import { IConfigMapsRouteParams } from "./config-maps.route";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
keys = "keys",
|
||||
@@ -24,12 +24,14 @@ export class ConfigMaps extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="configuration_configmaps"
|
||||
className="ConfigMaps" store={configMapsStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: ConfigMap) => item.getName(),
|
||||
[sortBy.namespace]: (item: ConfigMap) => item.getNs(),
|
||||
[sortBy.keys]: (item: ConfigMap) => item.getKeys(),
|
||||
[sortBy.age]: (item: ConfigMap) => item.metadata.creationTimestamp,
|
||||
[columnId.name]: (item: ConfigMap) => item.getName(),
|
||||
[columnId.namespace]: (item: ConfigMap) => item.getNs(),
|
||||
[columnId.keys]: (item: ConfigMap) => item.getKeys(),
|
||||
[columnId.age]: (item: ConfigMap) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: ConfigMap) => item.getSearchFields(),
|
||||
@@ -37,11 +39,11 @@ export class ConfigMaps extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Config Maps"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Keys", className: "keys", sortBy: sortBy.keys },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Keys", className: "keys", sortBy: columnId.keys, id: columnId.keys },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(configMap: ConfigMap) => [
|
||||
configMap.getName(),
|
||||
|
||||
@@ -7,7 +7,7 @@ import { PodDisruptionBudget } from "../../api/endpoints/poddisruptionbudget.api
|
||||
import { KubeObjectDetailsProps, KubeObjectListLayout } from "../kube-object";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
minAvailable = "min-available",
|
||||
@@ -25,30 +25,32 @@ export class PodDisruptionBudgets extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="configuration_distribution_budgets"
|
||||
className="PodDisruptionBudgets"
|
||||
store={podDisruptionBudgetsStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (pdb: PodDisruptionBudget) => pdb.getName(),
|
||||
[sortBy.namespace]: (pdb: PodDisruptionBudget) => pdb.getNs(),
|
||||
[sortBy.minAvailable]: (pdb: PodDisruptionBudget) => pdb.getMinAvailable(),
|
||||
[sortBy.maxUnavailable]: (pdb: PodDisruptionBudget) => pdb.getMaxUnavailable(),
|
||||
[sortBy.currentHealthy]: (pdb: PodDisruptionBudget) => pdb.getCurrentHealthy(),
|
||||
[sortBy.desiredHealthy]: (pdb: PodDisruptionBudget) => pdb.getDesiredHealthy(),
|
||||
[sortBy.age]: (pdb: PodDisruptionBudget) => pdb.getAge(),
|
||||
[columnId.name]: (pdb: PodDisruptionBudget) => pdb.getName(),
|
||||
[columnId.namespace]: (pdb: PodDisruptionBudget) => pdb.getNs(),
|
||||
[columnId.minAvailable]: (pdb: PodDisruptionBudget) => pdb.getMinAvailable(),
|
||||
[columnId.maxUnavailable]: (pdb: PodDisruptionBudget) => pdb.getMaxUnavailable(),
|
||||
[columnId.currentHealthy]: (pdb: PodDisruptionBudget) => pdb.getCurrentHealthy(),
|
||||
[columnId.desiredHealthy]: (pdb: PodDisruptionBudget) => pdb.getDesiredHealthy(),
|
||||
[columnId.age]: (pdb: PodDisruptionBudget) => pdb.getAge(),
|
||||
}}
|
||||
searchFilters={[
|
||||
(pdb: PodDisruptionBudget) => pdb.getSearchFields(),
|
||||
]}
|
||||
renderHeaderTitle="Pod Disruption Budgets"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Min Available", className: "min-available", sortBy: sortBy.minAvailable },
|
||||
{ title: "Max Unavailable", className: "max-unavailable", sortBy: sortBy.maxUnavailable },
|
||||
{ title: "Current Healthy", className: "current-healthy", sortBy: sortBy.currentHealthy },
|
||||
{ title: "Desired Healthy", className: "desired-healthy", sortBy: sortBy.desiredHealthy },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Min Available", className: "min-available", sortBy: columnId.minAvailable, id: columnId.minAvailable },
|
||||
{ title: "Max Unavailable", className: "max-unavailable", sortBy: columnId.maxUnavailable, id: columnId.maxUnavailable },
|
||||
{ title: "Current Healthy", className: "current-healthy", sortBy: columnId.currentHealthy, id: columnId.currentHealthy },
|
||||
{ title: "Desired Healthy", className: "desired-healthy", sortBy: columnId.desiredHealthy, id: columnId.desiredHealthy },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(pdb: PodDisruptionBudget) => {
|
||||
return [
|
||||
|
||||
@@ -10,7 +10,7 @@ import { resourceQuotaStore } from "./resource-quotas.store";
|
||||
import { IResourceQuotaRouteParams } from "./resource-quotas.route";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
age = "age"
|
||||
@@ -25,11 +25,13 @@ export class ResourceQuotas extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="configuration_quotas"
|
||||
className="ResourceQuotas" store={resourceQuotaStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: ResourceQuota) => item.getName(),
|
||||
[sortBy.namespace]: (item: ResourceQuota) => item.getNs(),
|
||||
[sortBy.age]: (item: ResourceQuota) => item.metadata.creationTimestamp,
|
||||
[columnId.name]: (item: ResourceQuota) => item.getName(),
|
||||
[columnId.namespace]: (item: ResourceQuota) => item.getNs(),
|
||||
[columnId.age]: (item: ResourceQuota) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: ResourceQuota) => item.getSearchFields(),
|
||||
@@ -37,10 +39,10 @@ export class ResourceQuotas extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Resource Quotas"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(resourceQuota: ResourceQuota) => [
|
||||
resourceQuota.getName(),
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Badge } from "../badge";
|
||||
import { secretsStore } from "./secrets.store";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
labels = "labels",
|
||||
@@ -29,14 +29,16 @@ export class Secrets extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="configuration_secrets"
|
||||
className="Secrets" store={secretsStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: Secret) => item.getName(),
|
||||
[sortBy.namespace]: (item: Secret) => item.getNs(),
|
||||
[sortBy.labels]: (item: Secret) => item.getLabels(),
|
||||
[sortBy.keys]: (item: Secret) => item.getKeys(),
|
||||
[sortBy.type]: (item: Secret) => item.type,
|
||||
[sortBy.age]: (item: Secret) => item.metadata.creationTimestamp,
|
||||
[columnId.name]: (item: Secret) => item.getName(),
|
||||
[columnId.namespace]: (item: Secret) => item.getNs(),
|
||||
[columnId.labels]: (item: Secret) => item.getLabels(),
|
||||
[columnId.keys]: (item: Secret) => item.getKeys(),
|
||||
[columnId.type]: (item: Secret) => item.type,
|
||||
[columnId.age]: (item: Secret) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: Secret) => item.getSearchFields(),
|
||||
@@ -44,13 +46,13 @@ export class Secrets extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Secrets"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Labels", className: "labels", sortBy: sortBy.labels },
|
||||
{ title: "Keys", className: "keys", sortBy: sortBy.keys },
|
||||
{ title: "Type", className: "type", sortBy: sortBy.type },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Labels", className: "labels", sortBy: columnId.labels, id: columnId.labels },
|
||||
{ title: "Keys", className: "keys", sortBy: columnId.keys, id: columnId.keys },
|
||||
{ title: "Type", className: "type", sortBy: columnId.type, id: columnId.type },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(secret: Secret) => [
|
||||
secret.getName(),
|
||||
|
||||
@@ -8,6 +8,7 @@ import { resourceQuotaRoute, ResourceQuotas, resourceQuotaURL } from "../+config
|
||||
import { pdbRoute, pdbURL, PodDisruptionBudgets } from "../+config-pod-disruption-budgets";
|
||||
import { HorizontalPodAutoscalers, hpaRoute, hpaURL } from "../+config-autoscalers";
|
||||
import { isAllowedResource } from "../../../common/rbac";
|
||||
import { LimitRanges, limitRangesRoute, limitRangeURL } from "../+config-limit-ranges";
|
||||
|
||||
@observer
|
||||
export class Config extends React.Component {
|
||||
@@ -42,6 +43,15 @@ export class Config extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
if (isAllowedResource("limitranges")) {
|
||||
routes.push({
|
||||
title: "Limit Ranges",
|
||||
component: LimitRanges,
|
||||
url: limitRangeURL({ query }),
|
||||
routePath: limitRangesRoute.path.toString(),
|
||||
});
|
||||
}
|
||||
|
||||
if (isAllowedResource("horizontalpodautoscalers")) {
|
||||
routes.push({
|
||||
title: "HPA",
|
||||
|
||||
@@ -19,7 +19,7 @@ export const crdGroupsUrlParam = createPageParam<string[]>({
|
||||
defaultValue: [],
|
||||
});
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
kind = "kind",
|
||||
group = "group",
|
||||
version = "version",
|
||||
@@ -47,14 +47,16 @@ export class CrdList extends React.Component {
|
||||
render() {
|
||||
const selectedGroups = this.groups;
|
||||
const sortingCallbacks = {
|
||||
[sortBy.kind]: (crd: CustomResourceDefinition) => crd.getResourceKind(),
|
||||
[sortBy.group]: (crd: CustomResourceDefinition) => crd.getGroup(),
|
||||
[sortBy.version]: (crd: CustomResourceDefinition) => crd.getVersion(),
|
||||
[sortBy.scope]: (crd: CustomResourceDefinition) => crd.getScope(),
|
||||
[columnId.kind]: (crd: CustomResourceDefinition) => crd.getResourceKind(),
|
||||
[columnId.group]: (crd: CustomResourceDefinition) => crd.getGroup(),
|
||||
[columnId.version]: (crd: CustomResourceDefinition) => crd.getVersion(),
|
||||
[columnId.scope]: (crd: CustomResourceDefinition) => crd.getScope(),
|
||||
};
|
||||
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="crd"
|
||||
className="CrdList"
|
||||
isClusterScoped={true}
|
||||
store={crdStore}
|
||||
@@ -97,11 +99,11 @@ export class CrdList extends React.Component {
|
||||
};
|
||||
}}
|
||||
renderTableHeader={[
|
||||
{ title: "Resource", className: "kind", sortBy: sortBy.kind },
|
||||
{ title: "Group", className: "group", sortBy: sortBy.group },
|
||||
{ title: "Version", className: "version", sortBy: sortBy.group },
|
||||
{ title: "Scope", className: "scope", sortBy: sortBy.scope },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Resource", className: "kind", sortBy: columnId.kind, id: columnId.kind },
|
||||
{ title: "Group", className: "group", sortBy: columnId.group, id: columnId.group },
|
||||
{ title: "Version", className: "version", sortBy: columnId.version, id: columnId.version },
|
||||
{ title: "Scope", className: "scope", sortBy: columnId.scope, id: columnId.scope },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(crd: CustomResourceDefinition) => [
|
||||
<Link key="link" to={crd.getResourceUrl()} onClick={stopPropagation}>
|
||||
|
||||
@@ -16,7 +16,7 @@ import { parseJsonPath } from "../../utils/jsonPath";
|
||||
interface Props extends RouteComponentProps<ICRDRouteParams> {
|
||||
}
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
age = "age",
|
||||
@@ -55,9 +55,9 @@ export class CrdResources extends React.Component<Props> {
|
||||
const isNamespaced = crd.isNamespaced();
|
||||
const extraColumns = crd.getPrinterColumns(false); // Cols with priority bigger than 0 are shown in details
|
||||
const sortingCallbacks: { [sortBy: string]: TableSortCallback } = {
|
||||
[sortBy.name]: (item: KubeObject) => item.getName(),
|
||||
[sortBy.namespace]: (item: KubeObject) => item.getNs(),
|
||||
[sortBy.age]: (item: KubeObject) => item.metadata.creationTimestamp,
|
||||
[columnId.name]: (item: KubeObject) => item.getName(),
|
||||
[columnId.namespace]: (item: KubeObject) => item.getNs(),
|
||||
[columnId.age]: (item: KubeObject) => item.metadata.creationTimestamp,
|
||||
};
|
||||
|
||||
extraColumns.forEach(column => {
|
||||
@@ -66,6 +66,8 @@ export class CrdResources extends React.Component<Props> {
|
||||
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="crd_resources"
|
||||
className="CrdResources"
|
||||
isClusterScoped={!isNamespaced}
|
||||
store={store}
|
||||
@@ -75,18 +77,19 @@ export class CrdResources extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle={crd.getResourceTitle()}
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
isNamespaced && { title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
isNamespaced && { title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
...extraColumns.map(column => {
|
||||
const { name } = column;
|
||||
|
||||
return {
|
||||
title: name,
|
||||
className: name.toLowerCase(),
|
||||
sortBy: name
|
||||
sortBy: name,
|
||||
id: name
|
||||
};
|
||||
}),
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(crdInstance: KubeObject) => [
|
||||
crdInstance.getName(),
|
||||
|
||||
@@ -52,6 +52,10 @@ export class EventStore extends KubeObjectStore<KubeEvent> {
|
||||
|
||||
return compact(eventsWithError);
|
||||
}
|
||||
|
||||
getWarningsCount() {
|
||||
return this.getWarnings().length;
|
||||
}
|
||||
}
|
||||
|
||||
export const eventStore = new EventStore();
|
||||
|
||||
@@ -12,11 +12,13 @@ import { cssNames, IClassName, stopPropagation } from "../../utils";
|
||||
import { Icon } from "../icon";
|
||||
import { lookupApiLink } from "../../api/kube-api";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
message = "message",
|
||||
namespace = "namespace",
|
||||
object = "object",
|
||||
type = "type",
|
||||
count = "count",
|
||||
source = "source",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
@@ -39,15 +41,17 @@ export class Events extends React.Component<Props> {
|
||||
const events = (
|
||||
<KubeObjectListLayout
|
||||
{...layoutProps}
|
||||
isConfigurable
|
||||
tableId="events"
|
||||
className={cssNames("Events", className, { compact })}
|
||||
store={eventStore}
|
||||
isSelectable={false}
|
||||
sortingCallbacks={{
|
||||
[sortBy.namespace]: (event: KubeEvent) => event.getNs(),
|
||||
[sortBy.type]: (event: KubeEvent) => event.involvedObject.kind,
|
||||
[sortBy.object]: (event: KubeEvent) => event.involvedObject.name,
|
||||
[sortBy.count]: (event: KubeEvent) => event.count,
|
||||
[sortBy.age]: (event: KubeEvent) => event.metadata.creationTimestamp,
|
||||
[columnId.namespace]: (event: KubeEvent) => event.getNs(),
|
||||
[columnId.type]: (event: KubeEvent) => event.involvedObject.kind,
|
||||
[columnId.object]: (event: KubeEvent) => event.involvedObject.name,
|
||||
[columnId.count]: (event: KubeEvent) => event.count,
|
||||
[columnId.age]: (event: KubeEvent) => event.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(event: KubeEvent) => event.getSearchFields(),
|
||||
@@ -72,13 +76,13 @@ export class Events extends React.Component<Props> {
|
||||
})
|
||||
)}
|
||||
renderTableHeader={[
|
||||
{ title: "Message", className: "message" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Type", className: "type", sortBy: sortBy.type },
|
||||
{ title: "Involved Object", className: "object", sortBy: sortBy.object },
|
||||
{ title: "Source", className: "source" },
|
||||
{ title: "Count", className: "count", sortBy: sortBy.count },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Message", className: "message", id: columnId.message },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Type", className: "type", sortBy: columnId.type, id: columnId.type },
|
||||
{ title: "Involved Object", className: "object", sortBy: columnId.object, id: columnId.object },
|
||||
{ title: "Source", className: "source", id: columnId.source },
|
||||
{ title: "Count", className: "count", sortBy: columnId.count, id: columnId.count },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(event: KubeEvent) => {
|
||||
const { involvedObject, type, message } = event;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "./landing-page.route";
|
||||
export * from "./landing-page";
|
||||
export * from "./landing-page";
|
||||
@@ -12,6 +12,7 @@ import { Spinner } from "../spinner";
|
||||
import { resourceQuotaStore } from "../+config-resource-quotas/resource-quotas.store";
|
||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import { limitRangeStore } from "../+config-limit-ranges/limit-ranges.store";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<Namespace> {
|
||||
}
|
||||
@@ -24,8 +25,15 @@ export class NamespaceDetails extends React.Component<Props> {
|
||||
return resourceQuotaStore.getAllByNs(namespace);
|
||||
}
|
||||
|
||||
@computed get limitranges() {
|
||||
const namespace = this.props.object.getName();
|
||||
|
||||
return limitRangeStore.getAllByNs(namespace);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
resourceQuotaStore.loadAll();
|
||||
limitRangeStore.loadAll();
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -52,6 +60,16 @@ export class NamespaceDetails extends React.Component<Props> {
|
||||
);
|
||||
})}
|
||||
</DrawerItem>
|
||||
<DrawerItem name={`Limit Ranges`}>
|
||||
{!this.limitranges && limitRangeStore.isLoading && <Spinner/>}
|
||||
{this.limitranges.map(limitrange => {
|
||||
return (
|
||||
<Link key={limitrange.getId()} to={getDetailsUrl(limitrange.selfLink)}>
|
||||
{limitrange.getName()}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</DrawerItem>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@ import "./namespace-select.scss";
|
||||
|
||||
import React from "react";
|
||||
import { computed } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { Select, SelectOption, SelectProps } from "../select";
|
||||
import { cssNames, noop } from "../../utils";
|
||||
import { cssNames } from "../../utils";
|
||||
import { Icon } from "../icon";
|
||||
import { namespaceStore } from "./namespace.store";
|
||||
import { FilterIcon } from "../item-object-list/filter-icon";
|
||||
import { FilterType } from "../item-object-list/page-filters.store";
|
||||
import { kubeWatchApi } from "../../api/kube-watch-api";
|
||||
|
||||
interface Props extends SelectProps {
|
||||
showIcons?: boolean;
|
||||
@@ -28,17 +29,13 @@ const defaultProps: Partial<Props> = {
|
||||
@observer
|
||||
export class NamespaceSelect extends React.Component<Props> {
|
||||
static defaultProps = defaultProps as object;
|
||||
private unsubscribe = noop;
|
||||
|
||||
async componentDidMount() {
|
||||
if (!namespaceStore.isLoaded) {
|
||||
await namespaceStore.loadAll();
|
||||
}
|
||||
this.unsubscribe = namespaceStore.subscribe();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.unsubscribe();
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this, [
|
||||
kubeWatchApi.subscribeStores([namespaceStore], {
|
||||
preload: true,
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
@computed get options(): SelectOption[] {
|
||||
@@ -60,7 +57,7 @@ export class NamespaceSelect extends React.Component<Props> {
|
||||
|
||||
return label || (
|
||||
<>
|
||||
{showIcons && <Icon small material="layers" />}
|
||||
{showIcons && <Icon small material="layers"/>}
|
||||
{value}
|
||||
</>
|
||||
);
|
||||
@@ -103,9 +100,9 @@ export class NamespaceSelectFilter extends React.Component {
|
||||
|
||||
return (
|
||||
<div className="flex gaps align-center">
|
||||
<FilterIcon type={FilterType.NAMESPACE} />
|
||||
<FilterIcon type={FilterType.NAMESPACE}/>
|
||||
<span>{namespace}</span>
|
||||
{isSelected && <Icon small material="check" className="box right" />}
|
||||
{isSelected && <Icon small material="check" className="box right"/>}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
|
||||
@@ -1,91 +1,145 @@
|
||||
import { action, comparer, observable, reaction } from "mobx";
|
||||
import { action, comparer, IReactionDisposer, IReactionOptions, observable, reaction, toJS, when } from "mobx";
|
||||
import { autobind, createStorage } from "../../utils";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { Namespace, namespacesApi } from "../../api/endpoints";
|
||||
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
|
||||
import { Namespace, namespacesApi } from "../../api/endpoints/namespaces.api";
|
||||
import { createPageParam } from "../../navigation";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
import { isAllowedResource } from "../../../common/rbac";
|
||||
import { getHostedCluster } from "../../../common/cluster-store";
|
||||
import { clusterStore, getHostedCluster } from "../../../common/cluster-store";
|
||||
|
||||
const storage = createStorage<string[]>("context_namespaces", []);
|
||||
const storage = createStorage<string[]>("context_namespaces");
|
||||
|
||||
export const namespaceUrlParam = createPageParam<string[]>({
|
||||
name: "namespaces",
|
||||
isSystem: true,
|
||||
multiValues: true,
|
||||
get defaultValue() {
|
||||
return storage.get(); // initial namespaces coming from URL or local-storage (default)
|
||||
return storage.get() ?? []; // initial namespaces coming from URL or local-storage (default)
|
||||
}
|
||||
});
|
||||
|
||||
export function getDummyNamespace(name: string) {
|
||||
return new Namespace({
|
||||
kind: Namespace.kind,
|
||||
apiVersion: "v1",
|
||||
metadata: {
|
||||
name,
|
||||
uid: "",
|
||||
resourceVersion: "",
|
||||
selfLink: `/api/v1/namespaces/${name}`
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@autobind()
|
||||
export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
api = namespacesApi;
|
||||
contextNs = observable.array<string>();
|
||||
|
||||
@observable contextNs = observable.array<string>();
|
||||
@observable isReady = false;
|
||||
|
||||
whenReady = when(() => this.isReady);
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.init();
|
||||
}
|
||||
|
||||
private init() {
|
||||
this.setContext(this.initNamespaces);
|
||||
private async init() {
|
||||
await clusterStore.whenLoaded;
|
||||
if (!getHostedCluster()) return;
|
||||
await getHostedCluster().whenReady; // wait for cluster-state from main
|
||||
|
||||
return reaction(() => this.contextNs.toJS(), namespaces => {
|
||||
this.setContext(this.initialNamespaces);
|
||||
this.autoLoadAllowedNamespaces();
|
||||
this.autoUpdateUrlAndLocalStorage();
|
||||
|
||||
this.isReady = true;
|
||||
}
|
||||
|
||||
public onContextChange(callback: (contextNamespaces: string[]) => void, opts: IReactionOptions = {}): IReactionDisposer {
|
||||
return reaction(() => this.contextNs.toJS(), callback, {
|
||||
equals: comparer.shallow,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
|
||||
private autoUpdateUrlAndLocalStorage(): IReactionDisposer {
|
||||
return this.onContextChange(namespaces => {
|
||||
storage.set(namespaces); // save to local-storage
|
||||
namespaceUrlParam.set(namespaces, { replaceHistory: true }); // update url
|
||||
}, {
|
||||
fireImmediately: true,
|
||||
equals: comparer.identity,
|
||||
});
|
||||
}
|
||||
|
||||
get initNamespaces() {
|
||||
return namespaceUrlParam.get();
|
||||
private autoLoadAllowedNamespaces(): IReactionDisposer {
|
||||
return reaction(() => this.allowedNamespaces, () => this.loadAll(), {
|
||||
fireImmediately: true,
|
||||
equals: comparer.shallow,
|
||||
});
|
||||
}
|
||||
|
||||
getContextParams() {
|
||||
return {
|
||||
namespaces: this.contextNs.toJS(),
|
||||
};
|
||||
get allowedNamespaces(): string[] {
|
||||
return toJS(getHostedCluster().allowedNamespaces);
|
||||
}
|
||||
|
||||
subscribe(apis = [this.api]) {
|
||||
private get initialNamespaces(): string[] {
|
||||
const allowed = new Set(this.allowedNamespaces);
|
||||
const prevSelected = storage.get();
|
||||
|
||||
if (Array.isArray(prevSelected)) {
|
||||
return prevSelected.filter(namespace => allowed.has(namespace));
|
||||
}
|
||||
|
||||
// otherwise select "default" or first allowed namespace
|
||||
if (allowed.has("default")) {
|
||||
return ["default"];
|
||||
} else if (allowed.size) {
|
||||
return [Array.from(allowed)[0]];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
getContextNamespaces(): string[] {
|
||||
const namespaces = this.contextNs.toJS();
|
||||
|
||||
// show all namespaces when nothing selected
|
||||
if (!namespaces.length) {
|
||||
if (this.isLoaded) {
|
||||
// return actual namespaces list since "allowedNamespaces" updating every 30s in cluster and thus might be stale
|
||||
return this.items.map(namespace => namespace.getName());
|
||||
}
|
||||
|
||||
return this.allowedNamespaces;
|
||||
}
|
||||
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
getSubscribeApis() {
|
||||
const { accessibleNamespaces } = getHostedCluster();
|
||||
|
||||
// if user has given static list of namespaces let's not start watches because watch adds stuff that's not wanted
|
||||
if (accessibleNamespaces.length > 0) {
|
||||
return Function; // no-op
|
||||
}
|
||||
|
||||
return super.subscribe(apis);
|
||||
}
|
||||
|
||||
protected async loadItems(namespaces?: string[]) {
|
||||
if (!isAllowedResource("namespaces")) {
|
||||
if (namespaces) return namespaces.map(this.getDummyNamespace);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
if (namespaces) {
|
||||
return Promise.all(namespaces.map(name => this.api.get({ name })));
|
||||
} else {
|
||||
return super.loadItems();
|
||||
}
|
||||
return super.getSubscribeApis();
|
||||
}
|
||||
|
||||
protected getDummyNamespace(name: string) {
|
||||
return new Namespace({
|
||||
kind: "Namespace",
|
||||
apiVersion: "v1",
|
||||
metadata: {
|
||||
name,
|
||||
uid: "",
|
||||
resourceVersion: "",
|
||||
selfLink: `/api/v1/namespaces/${name}`
|
||||
}
|
||||
});
|
||||
protected async loadItems(params: KubeObjectStoreLoadingParams) {
|
||||
const { allowedNamespaces } = this;
|
||||
|
||||
let namespaces = await super.loadItems(params);
|
||||
|
||||
namespaces = namespaces.filter(namespace => allowedNamespaces.includes(namespace.getName()));
|
||||
|
||||
if (!namespaces.length && allowedNamespaces.length > 0) {
|
||||
return allowedNamespaces.map(getDummyNamespace);
|
||||
}
|
||||
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
@action
|
||||
@@ -105,12 +159,6 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
else this.contextNs.push(namespace);
|
||||
}
|
||||
|
||||
@action
|
||||
reset() {
|
||||
super.reset();
|
||||
this.contextNs.clear();
|
||||
}
|
||||
|
||||
@action
|
||||
async remove(item: Namespace) {
|
||||
await super.remove(item);
|
||||
|
||||
@@ -11,7 +11,7 @@ import { INamespacesRouteParams } from "./namespaces.route";
|
||||
import { namespaceStore } from "./namespace.store";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
labels = "labels",
|
||||
age = "age",
|
||||
@@ -27,12 +27,14 @@ export class Namespaces extends React.Component<Props> {
|
||||
<TabLayout>
|
||||
<KubeObjectListLayout
|
||||
isClusterScoped
|
||||
isConfigurable
|
||||
tableId="namespaces"
|
||||
className="Namespaces" store={namespaceStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (ns: Namespace) => ns.getName(),
|
||||
[sortBy.labels]: (ns: Namespace) => ns.getLabels(),
|
||||
[sortBy.age]: (ns: Namespace) => ns.metadata.creationTimestamp,
|
||||
[sortBy.status]: (ns: Namespace) => ns.getStatus(),
|
||||
[columnId.name]: (ns: Namespace) => ns.getName(),
|
||||
[columnId.labels]: (ns: Namespace) => ns.getLabels(),
|
||||
[columnId.age]: (ns: Namespace) => ns.metadata.creationTimestamp,
|
||||
[columnId.status]: (ns: Namespace) => ns.getStatus(),
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: Namespace) => item.getSearchFields(),
|
||||
@@ -40,11 +42,11 @@ export class Namespaces extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Namespaces"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Labels", className: "labels", sortBy: sortBy.labels },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Status", className: "status", sortBy: sortBy.status },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Labels", className: "labels", sortBy: columnId.labels, id: columnId.labels },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
{ title: "Status", className: "status", sortBy: columnId.status, id: columnId.status },
|
||||
]}
|
||||
renderTableContents={(item: Namespace) => [
|
||||
item.getName(),
|
||||
|
||||
@@ -9,9 +9,10 @@ import { endpointStore } from "./endpoints.store";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
endpoints = "endpoints",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
@@ -23,22 +24,24 @@ export class Endpoints extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="network_endpoints"
|
||||
className="Endpoints" store={endpointStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (endpoint: Endpoint) => endpoint.getName(),
|
||||
[sortBy.namespace]: (endpoint: Endpoint) => endpoint.getNs(),
|
||||
[sortBy.age]: (endpoint: Endpoint) => endpoint.metadata.creationTimestamp,
|
||||
[columnId.name]: (endpoint: Endpoint) => endpoint.getName(),
|
||||
[columnId.namespace]: (endpoint: Endpoint) => endpoint.getNs(),
|
||||
[columnId.age]: (endpoint: Endpoint) => endpoint.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(endpoint: Endpoint) => endpoint.getSearchFields()
|
||||
]}
|
||||
renderHeaderTitle="Endpoints"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Endpoints", className: "endpoints" },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Endpoints", className: "endpoints", id: columnId.endpoints },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(endpoint: Endpoint) => [
|
||||
endpoint.getName(),
|
||||
|
||||
@@ -9,9 +9,11 @@ import { ingressStore } from "./ingress.store";
|
||||
import { KubeObjectListLayout } from "../kube-object";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
loadBalancers ="load-balancers",
|
||||
rules = "rules",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
@@ -23,11 +25,13 @@ export class Ingresses extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="network_ingresses"
|
||||
className="Ingresses" store={ingressStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (ingress: Ingress) => ingress.getName(),
|
||||
[sortBy.namespace]: (ingress: Ingress) => ingress.getNs(),
|
||||
[sortBy.age]: (ingress: Ingress) => ingress.metadata.creationTimestamp,
|
||||
[columnId.name]: (ingress: Ingress) => ingress.getName(),
|
||||
[columnId.namespace]: (ingress: Ingress) => ingress.getNs(),
|
||||
[columnId.age]: (ingress: Ingress) => ingress.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(ingress: Ingress) => ingress.getSearchFields(),
|
||||
@@ -35,12 +39,12 @@ export class Ingresses extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Ingresses"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "LoadBalancers", className: "loadbalancers" },
|
||||
{ title: "Rules", className: "rules" },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "LoadBalancers", className: "loadbalancers", id: columnId.loadBalancers },
|
||||
{ title: "Rules", className: "rules", id: columnId.rules },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(ingress: Ingress) => [
|
||||
ingress.getName(),
|
||||
|
||||
@@ -9,9 +9,10 @@ import { INetworkPoliciesRouteParams } from "./network-policies.route";
|
||||
import { networkPolicyStore } from "./network-policy.store";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
types = "types",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
@@ -23,22 +24,24 @@ export class NetworkPolicies extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="network_policies"
|
||||
className="NetworkPolicies" store={networkPolicyStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: NetworkPolicy) => item.getName(),
|
||||
[sortBy.namespace]: (item: NetworkPolicy) => item.getNs(),
|
||||
[sortBy.age]: (item: NetworkPolicy) => item.metadata.creationTimestamp,
|
||||
[columnId.name]: (item: NetworkPolicy) => item.getName(),
|
||||
[columnId.namespace]: (item: NetworkPolicy) => item.getNs(),
|
||||
[columnId.age]: (item: NetworkPolicy) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: NetworkPolicy) => item.getSearchFields(),
|
||||
]}
|
||||
renderHeaderTitle="Network Policies"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Policy Types", className: "type" },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Policy Types", className: "type", id: columnId.types },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(item: NetworkPolicy) => [
|
||||
item.getName(),
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import "./service-details.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import { KubeEventDetails } from "../+events/kube-event-details";
|
||||
import { KubeObjectDetailsProps } from "../kube-object";
|
||||
import { Service, endpointApi } from "../../api/endpoints";
|
||||
import { Service } from "../../api/endpoints";
|
||||
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
|
||||
import { ServicePortComponent } from "./service-port-component";
|
||||
import { endpointStore } from "../+network-endpoints/endpoints.store";
|
||||
import { ServiceDetailsEndpoint } from "./service-details-endpoint";
|
||||
import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry";
|
||||
import { kubeWatchApi } from "../../api/kube-watch-api";
|
||||
|
||||
interface Props extends KubeObjectDetailsProps<Service> {
|
||||
}
|
||||
@@ -19,10 +20,11 @@ interface Props extends KubeObjectDetailsProps<Service> {
|
||||
@observer
|
||||
export class ServiceDetails extends React.Component<Props> {
|
||||
componentDidMount() {
|
||||
if (!endpointStore.isLoaded) {
|
||||
endpointStore.loadAll();
|
||||
}
|
||||
endpointApi.watch();
|
||||
disposeOnUnmount(this, [
|
||||
kubeWatchApi.subscribeStores([endpointStore], {
|
||||
preload: true,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -77,7 +79,7 @@ export class ServiceDetails extends React.Component<Props> {
|
||||
)}
|
||||
<DrawerTitle title={`Endpoint`}/>
|
||||
|
||||
<ServiceDetailsEndpoint endpoint={endpoint} />
|
||||
<ServiceDetailsEndpoint endpoint={endpoint}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,12 +10,13 @@ import { Badge } from "../badge";
|
||||
import { serviceStore } from "./services.store";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
selector = "selector",
|
||||
ports = "port",
|
||||
clusterIp = "cluster-ip",
|
||||
externalIp = "external-ip",
|
||||
age = "age",
|
||||
type = "type",
|
||||
status = "status",
|
||||
@@ -29,16 +30,18 @@ export class Services extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="network_services"
|
||||
className="Services" store={serviceStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (service: Service) => service.getName(),
|
||||
[sortBy.namespace]: (service: Service) => service.getNs(),
|
||||
[sortBy.selector]: (service: Service) => service.getSelector(),
|
||||
[sortBy.ports]: (service: Service) => (service.spec.ports || []).map(({ port }) => port)[0],
|
||||
[sortBy.clusterIp]: (service: Service) => service.getClusterIp(),
|
||||
[sortBy.type]: (service: Service) => service.getType(),
|
||||
[sortBy.age]: (service: Service) => service.metadata.creationTimestamp,
|
||||
[sortBy.status]: (service: Service) => service.getStatus(),
|
||||
[columnId.name]: (service: Service) => service.getName(),
|
||||
[columnId.namespace]: (service: Service) => service.getNs(),
|
||||
[columnId.selector]: (service: Service) => service.getSelector(),
|
||||
[columnId.ports]: (service: Service) => (service.spec.ports || []).map(({ port }) => port)[0],
|
||||
[columnId.clusterIp]: (service: Service) => service.getClusterIp(),
|
||||
[columnId.type]: (service: Service) => service.getType(),
|
||||
[columnId.age]: (service: Service) => service.metadata.creationTimestamp,
|
||||
[columnId.status]: (service: Service) => service.getStatus(),
|
||||
}}
|
||||
searchFilters={[
|
||||
(service: Service) => service.getSearchFields(),
|
||||
@@ -47,16 +50,16 @@ export class Services extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Services"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Type", className: "type", sortBy: sortBy.type },
|
||||
{ title: "Cluster IP", className: "clusterIp", sortBy: sortBy.clusterIp, },
|
||||
{ title: "Ports", className: "ports", sortBy: sortBy.ports },
|
||||
{ title: "External IP", className: "externalIp" },
|
||||
{ title: "Selector", className: "selector", sortBy: sortBy.selector },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Status", className: "status", sortBy: sortBy.status },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Type", className: "type", sortBy: columnId.type, id: columnId.type },
|
||||
{ title: "Cluster IP", className: "clusterIp", sortBy: columnId.clusterIp, id: columnId.clusterIp },
|
||||
{ title: "Ports", className: "ports", sortBy: columnId.ports, id: columnId.ports },
|
||||
{ title: "External IP", className: "externalIp", id: columnId.externalIp },
|
||||
{ title: "Selector", className: "selector", sortBy: columnId.selector, id: columnId.selector },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
{ title: "Status", className: "status", sortBy: columnId.status, id: columnId.status },
|
||||
]}
|
||||
renderTableContents={(service: Service) => [
|
||||
service.getName(),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { sum } from "lodash";
|
||||
import { action, computed, observable } from "mobx";
|
||||
import { clusterApi, IClusterMetrics, INodeMetrics, Node, nodesApi } from "../../api/endpoints";
|
||||
import { autobind } from "../../utils";
|
||||
@@ -62,6 +63,10 @@ export class NodesStore extends KubeObjectStore<Node> {
|
||||
});
|
||||
}
|
||||
|
||||
getWarningsCount(): number {
|
||||
return sum(this.items.map((node: Node) => node.getWarningConditions().length));
|
||||
}
|
||||
|
||||
reset() {
|
||||
super.reset();
|
||||
this.metrics = {};
|
||||
|
||||
@@ -17,7 +17,7 @@ import upperFirst from "lodash/upperFirst";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import { Badge } from "../badge/badge";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
cpu = "cpu",
|
||||
memory = "memory",
|
||||
@@ -51,6 +51,10 @@ export class Nodes extends React.Component<Props> {
|
||||
if (!metrics || !metrics[1]) return <LineProgress value={0}/>;
|
||||
const usage = metrics[0];
|
||||
const cores = metrics[1];
|
||||
const cpuUsagePercent = Math.ceil(usage * 100) / cores;
|
||||
const cpuUsagePercentLabel: String = cpuUsagePercent % 1 === 0
|
||||
? cpuUsagePercent.toString()
|
||||
: cpuUsagePercent.toFixed(2);
|
||||
|
||||
return (
|
||||
<LineProgress
|
||||
@@ -58,7 +62,7 @@ export class Nodes extends React.Component<Props> {
|
||||
value={usage}
|
||||
tooltip={{
|
||||
preferredPositions: TooltipPosition.BOTTOM,
|
||||
children: `CPU: ${Math.ceil(usage * 100) / cores}\%, cores: ${cores}`
|
||||
children: `CPU: ${cpuUsagePercentLabel}\%, cores: ${cores}`
|
||||
}}
|
||||
/>
|
||||
);
|
||||
@@ -131,21 +135,23 @@ export class Nodes extends React.Component<Props> {
|
||||
return (
|
||||
<TabLayout>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="nodes"
|
||||
className="Nodes"
|
||||
store={nodesStore} isClusterScoped
|
||||
isReady={nodesStore.isLoaded}
|
||||
dependentStores={[podsStore]}
|
||||
isSelectable={false}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (node: Node) => node.getName(),
|
||||
[sortBy.cpu]: (node: Node) => nodesStore.getLastMetricValues(node, ["cpuUsage"]),
|
||||
[sortBy.memory]: (node: Node) => nodesStore.getLastMetricValues(node, ["memoryUsage"]),
|
||||
[sortBy.disk]: (node: Node) => nodesStore.getLastMetricValues(node, ["fsUsage"]),
|
||||
[sortBy.conditions]: (node: Node) => node.getNodeConditionText(),
|
||||
[sortBy.taints]: (node: Node) => node.getTaints().length,
|
||||
[sortBy.roles]: (node: Node) => node.getRoleLabels(),
|
||||
[sortBy.age]: (node: Node) => node.metadata.creationTimestamp,
|
||||
[sortBy.version]: (node: Node) => node.getKubeletVersion(),
|
||||
[columnId.name]: (node: Node) => node.getName(),
|
||||
[columnId.cpu]: (node: Node) => nodesStore.getLastMetricValues(node, ["cpuUsage"]),
|
||||
[columnId.memory]: (node: Node) => nodesStore.getLastMetricValues(node, ["memoryUsage"]),
|
||||
[columnId.disk]: (node: Node) => nodesStore.getLastMetricValues(node, ["fsUsage"]),
|
||||
[columnId.conditions]: (node: Node) => node.getNodeConditionText(),
|
||||
[columnId.taints]: (node: Node) => node.getTaints().length,
|
||||
[columnId.roles]: (node: Node) => node.getRoleLabels(),
|
||||
[columnId.age]: (node: Node) => node.metadata.creationTimestamp,
|
||||
[columnId.version]: (node: Node) => node.getKubeletVersion(),
|
||||
}}
|
||||
searchFilters={[
|
||||
(node: Node) => node.getSearchFields(),
|
||||
@@ -155,16 +161,16 @@ export class Nodes extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Nodes"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "CPU", className: "cpu", sortBy: sortBy.cpu },
|
||||
{ title: "Memory", className: "memory", sortBy: sortBy.memory },
|
||||
{ title: "Disk", className: "disk", sortBy: sortBy.disk },
|
||||
{ title: "Taints", className: "taints", sortBy: sortBy.taints },
|
||||
{ title: "Roles", className: "roles", sortBy: sortBy.roles },
|
||||
{ title: "Version", className: "version", sortBy: sortBy.version },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Conditions", className: "conditions", sortBy: sortBy.conditions },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "CPU", className: "cpu", sortBy: columnId.cpu, id: columnId.cpu },
|
||||
{ title: "Memory", className: "memory", sortBy: columnId.memory, id: columnId.memory },
|
||||
{ title: "Disk", className: "disk", sortBy: columnId.disk, id: columnId.disk },
|
||||
{ title: "Taints", className: "taints", sortBy: columnId.taints, id: columnId.taints },
|
||||
{ title: "Roles", className: "roles", sortBy: columnId.roles, id: columnId.roles },
|
||||
{ title: "Version", className: "version", sortBy: columnId.version, id: columnId.version },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
{ title: "Conditions", className: "conditions", sortBy: columnId.conditions, id: columnId.conditions },
|
||||
]}
|
||||
renderTableContents={(node: Node) => {
|
||||
const tooltipId = `node-taints-${node.getId()}`;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from "./pod-security-policies.route";
|
||||
export * from "./pod-security-policies";
|
||||
export * from "./pod-security-policy-details";
|
||||
export * from "./pod-security-policy-details";
|
||||
@@ -7,7 +7,7 @@ import { podSecurityPoliciesStore } from "./pod-security-policies.store";
|
||||
import { PodSecurityPolicy } from "../../api/endpoints";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
volumes = "volumes",
|
||||
privileged = "privileged",
|
||||
@@ -19,14 +19,16 @@ export class PodSecurityPolicies extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="access_roles"
|
||||
className="PodSecurityPolicies"
|
||||
isClusterScoped={true}
|
||||
store={podSecurityPoliciesStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: PodSecurityPolicy) => item.getName(),
|
||||
[sortBy.volumes]: (item: PodSecurityPolicy) => item.getVolumes(),
|
||||
[sortBy.privileged]: (item: PodSecurityPolicy) => +item.isPrivileged(),
|
||||
[sortBy.age]: (item: PodSecurityPolicy) => item.metadata.creationTimestamp,
|
||||
[columnId.name]: (item: PodSecurityPolicy) => item.getName(),
|
||||
[columnId.volumes]: (item: PodSecurityPolicy) => item.getVolumes(),
|
||||
[columnId.privileged]: (item: PodSecurityPolicy) => +item.isPrivileged(),
|
||||
[columnId.age]: (item: PodSecurityPolicy) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: PodSecurityPolicy) => item.getSearchFields(),
|
||||
@@ -35,11 +37,11 @@ export class PodSecurityPolicies extends React.Component {
|
||||
]}
|
||||
renderHeaderTitle="Pod Security Policies"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Privileged", className: "privileged", sortBy: sortBy.privileged },
|
||||
{ title: "Volumes", className: "volumes", sortBy: sortBy.volumes },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Privileged", className: "privileged", sortBy: columnId.privileged, id: columnId.privileged },
|
||||
{ title: "Volumes", className: "volumes", sortBy: columnId.volumes, id: columnId.volumes },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(item: PodSecurityPolicy) => {
|
||||
return [
|
||||
|
||||
@@ -9,10 +9,11 @@ import { IStorageClassesRouteParams } from "./storage-classes.route";
|
||||
import { storageClassStore } from "./storage-class.store";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
age = "age",
|
||||
provisioner = "provision",
|
||||
default = "default",
|
||||
reclaimPolicy = "reclaim",
|
||||
}
|
||||
|
||||
@@ -24,13 +25,15 @@ export class StorageClasses extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="storage_classes"
|
||||
className="StorageClasses"
|
||||
store={storageClassStore} isClusterScoped
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: StorageClass) => item.getName(),
|
||||
[sortBy.age]: (item: StorageClass) => item.metadata.creationTimestamp,
|
||||
[sortBy.provisioner]: (item: StorageClass) => item.provisioner,
|
||||
[sortBy.reclaimPolicy]: (item: StorageClass) => item.reclaimPolicy,
|
||||
[columnId.name]: (item: StorageClass) => item.getName(),
|
||||
[columnId.age]: (item: StorageClass) => item.metadata.creationTimestamp,
|
||||
[columnId.provisioner]: (item: StorageClass) => item.provisioner,
|
||||
[columnId.reclaimPolicy]: (item: StorageClass) => item.reclaimPolicy,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: StorageClass) => item.getSearchFields(),
|
||||
@@ -38,12 +41,12 @@ export class StorageClasses extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Storage Classes"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Provisioner", className: "provisioner", sortBy: sortBy.provisioner },
|
||||
{ title: "Reclaim Policy", className: "reclaim-policy", sortBy: sortBy.reclaimPolicy },
|
||||
{ title: "Default", className: "is-default" },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Provisioner", className: "provisioner", sortBy: columnId.provisioner, id: columnId.provisioner },
|
||||
{ title: "Reclaim Policy", className: "reclaim-policy", sortBy: columnId.reclaimPolicy, id: columnId.reclaimPolicy },
|
||||
{ title: "Default", className: "is-default", id: columnId.default },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(storageClass: StorageClass) => [
|
||||
storageClass.getName(),
|
||||
|
||||
@@ -13,7 +13,7 @@ import { stopPropagation } from "../../utils";
|
||||
import { storageClassApi } from "../../api/endpoints";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
pods = "pods",
|
||||
@@ -31,17 +31,19 @@ export class PersistentVolumeClaims extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="storage_volume_claims"
|
||||
className="PersistentVolumeClaims"
|
||||
store={volumeClaimStore}
|
||||
dependentStores={[podsStore]}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (pvc: PersistentVolumeClaim) => pvc.getName(),
|
||||
[sortBy.namespace]: (pvc: PersistentVolumeClaim) => pvc.getNs(),
|
||||
[sortBy.pods]: (pvc: PersistentVolumeClaim) => pvc.getPods(podsStore.items).map(pod => pod.getName()),
|
||||
[sortBy.status]: (pvc: PersistentVolumeClaim) => pvc.getStatus(),
|
||||
[sortBy.size]: (pvc: PersistentVolumeClaim) => unitsToBytes(pvc.getStorage()),
|
||||
[sortBy.storageClass]: (pvc: PersistentVolumeClaim) => pvc.spec.storageClassName,
|
||||
[sortBy.age]: (pvc: PersistentVolumeClaim) => pvc.metadata.creationTimestamp,
|
||||
[columnId.name]: (pvc: PersistentVolumeClaim) => pvc.getName(),
|
||||
[columnId.namespace]: (pvc: PersistentVolumeClaim) => pvc.getNs(),
|
||||
[columnId.pods]: (pvc: PersistentVolumeClaim) => pvc.getPods(podsStore.items).map(pod => pod.getName()),
|
||||
[columnId.status]: (pvc: PersistentVolumeClaim) => pvc.getStatus(),
|
||||
[columnId.size]: (pvc: PersistentVolumeClaim) => unitsToBytes(pvc.getStorage()),
|
||||
[columnId.storageClass]: (pvc: PersistentVolumeClaim) => pvc.spec.storageClassName,
|
||||
[columnId.age]: (pvc: PersistentVolumeClaim) => pvc.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: PersistentVolumeClaim) => item.getSearchFields(),
|
||||
@@ -49,14 +51,14 @@ export class PersistentVolumeClaims extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Persistent Volume Claims"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Storage class", className: "storageClass", sortBy: sortBy.storageClass },
|
||||
{ title: "Size", className: "size", sortBy: sortBy.size },
|
||||
{ title: "Pods", className: "pods", sortBy: sortBy.pods },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Status", className: "status", sortBy: sortBy.status },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Storage class", className: "storageClass", sortBy: columnId.storageClass, id: columnId.storageClass },
|
||||
{ title: "Size", className: "size", sortBy: columnId.size, id: columnId.size },
|
||||
{ title: "Pods", className: "pods", sortBy: columnId.pods, id: columnId.pods },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
{ title: "Status", className: "status", sortBy: columnId.status, id: columnId.status },
|
||||
]}
|
||||
renderTableContents={(pvc: PersistentVolumeClaim) => {
|
||||
const pods = pvc.getPods(podsStore.items);
|
||||
|
||||
@@ -11,10 +11,11 @@ import { volumesStore } from "./volumes.store";
|
||||
import { pvcApi, storageClassApi } from "../../api/endpoints";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
storageClass = "storage-class",
|
||||
capacity = "capacity",
|
||||
claim = "claim",
|
||||
status = "status",
|
||||
age = "age",
|
||||
}
|
||||
@@ -27,14 +28,16 @@ export class PersistentVolumes extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="storage_volumes"
|
||||
className="PersistentVolumes"
|
||||
store={volumesStore} isClusterScoped
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (item: PersistentVolume) => item.getName(),
|
||||
[sortBy.storageClass]: (item: PersistentVolume) => item.spec.storageClassName,
|
||||
[sortBy.capacity]: (item: PersistentVolume) => item.getCapacity(true),
|
||||
[sortBy.status]: (item: PersistentVolume) => item.getStatus(),
|
||||
[sortBy.age]: (item: PersistentVolume) => item.metadata.creationTimestamp,
|
||||
[columnId.name]: (item: PersistentVolume) => item.getName(),
|
||||
[columnId.storageClass]: (item: PersistentVolume) => item.spec.storageClassName,
|
||||
[columnId.capacity]: (item: PersistentVolume) => item.getCapacity(true),
|
||||
[columnId.status]: (item: PersistentVolume) => item.getStatus(),
|
||||
[columnId.age]: (item: PersistentVolume) => item.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(item: PersistentVolume) => item.getSearchFields(),
|
||||
@@ -42,13 +45,13 @@ export class PersistentVolumes extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Persistent Volumes"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Storage Class", className: "storageClass", sortBy: sortBy.storageClass },
|
||||
{ title: "Capacity", className: "capacity", sortBy: sortBy.capacity },
|
||||
{ title: "Claim", className: "claim" },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Status", className: "status", sortBy: sortBy.status },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Storage Class", className: "storageClass", sortBy: columnId.storageClass, id: columnId.storageClass },
|
||||
{ title: "Capacity", className: "capacity", sortBy: columnId.capacity, id: columnId.capacity },
|
||||
{ title: "Claim", className: "claim", id: columnId.claim },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
{ title: "Status", className: "status", sortBy: columnId.status, id: columnId.status },
|
||||
]}
|
||||
renderTableContents={(volume: PersistentVolume) => {
|
||||
const { claimRef, storageClassName } = volume.spec;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import difference from "lodash/difference";
|
||||
import uniqBy from "lodash/uniqBy";
|
||||
import { clusterRoleBindingApi, IRoleBindingSubject, RoleBinding, roleBindingApi } from "../../api/endpoints";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
|
||||
import { autobind } from "../../utils";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@@ -9,8 +9,8 @@ import { apiManager } from "../../api/api-manager";
|
||||
export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
|
||||
api = clusterRoleBindingApi;
|
||||
|
||||
subscribe() {
|
||||
return super.subscribe([clusterRoleBindingApi, roleBindingApi]);
|
||||
getSubscribeApis() {
|
||||
return [clusterRoleBindingApi, roleBindingApi];
|
||||
}
|
||||
|
||||
protected sortItems(items: RoleBinding[]) {
|
||||
@@ -26,15 +26,13 @@ export class RoleBindingsStore extends KubeObjectStore<RoleBinding> {
|
||||
return clusterRoleBindingApi.get(params);
|
||||
}
|
||||
|
||||
protected loadItems(namespaces?: string[]) {
|
||||
if (namespaces) {
|
||||
return Promise.all(
|
||||
namespaces.map(namespace => roleBindingApi.list({ namespace }))
|
||||
).then(items => items.flat());
|
||||
} else {
|
||||
return Promise.all([clusterRoleBindingApi.list(), roleBindingApi.list()])
|
||||
.then(items => items.flat());
|
||||
}
|
||||
protected async loadItems(params: KubeObjectStoreLoadingParams): Promise<RoleBinding[]> {
|
||||
const items = await Promise.all([
|
||||
super.loadItems({ ...params, api: clusterRoleBindingApi }),
|
||||
super.loadItems({ ...params, api: roleBindingApi }),
|
||||
]);
|
||||
|
||||
return items.flat();
|
||||
}
|
||||
|
||||
protected async createItem(params: { name: string; namespace?: string }, data?: Partial<RoleBinding>) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { KubeObjectListLayout } from "../kube-object";
|
||||
import { AddRoleBindingDialog } from "./add-role-binding-dialog";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
bindings = "bindings",
|
||||
@@ -25,13 +25,15 @@ export class RoleBindings extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="access_role_bindings"
|
||||
className="RoleBindings"
|
||||
store={roleBindingsStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (binding: RoleBinding) => binding.getName(),
|
||||
[sortBy.namespace]: (binding: RoleBinding) => binding.getNs(),
|
||||
[sortBy.bindings]: (binding: RoleBinding) => binding.getSubjectNames(),
|
||||
[sortBy.age]: (binding: RoleBinding) => binding.metadata.creationTimestamp,
|
||||
[columnId.name]: (binding: RoleBinding) => binding.getName(),
|
||||
[columnId.namespace]: (binding: RoleBinding) => binding.getNs(),
|
||||
[columnId.bindings]: (binding: RoleBinding) => binding.getSubjectNames(),
|
||||
[columnId.age]: (binding: RoleBinding) => binding.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(binding: RoleBinding) => binding.getSearchFields(),
|
||||
@@ -39,11 +41,11 @@ export class RoleBindings extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Role Bindings"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Bindings", className: "bindings", sortBy: sortBy.bindings },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Bindings", className: "bindings", sortBy: columnId.bindings, id: columnId.bindings },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(binding: RoleBinding) => [
|
||||
binding.getName(),
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { clusterRoleApi, Role, roleApi } from "../../api/endpoints";
|
||||
import { autobind } from "../../utils";
|
||||
import { KubeObjectStore } from "../../kube-object.store";
|
||||
import { KubeObjectStore, KubeObjectStoreLoadingParams } from "../../kube-object.store";
|
||||
import { apiManager } from "../../api/api-manager";
|
||||
|
||||
@autobind()
|
||||
export class RolesStore extends KubeObjectStore<Role> {
|
||||
api = clusterRoleApi;
|
||||
|
||||
subscribe() {
|
||||
return super.subscribe([roleApi, clusterRoleApi]);
|
||||
getSubscribeApis() {
|
||||
return [roleApi, clusterRoleApi];
|
||||
}
|
||||
|
||||
protected sortItems(items: Role[]) {
|
||||
@@ -24,15 +24,13 @@ export class RolesStore extends KubeObjectStore<Role> {
|
||||
return clusterRoleApi.get(params);
|
||||
}
|
||||
|
||||
protected loadItems(namespaces?: string[]): Promise<Role[]> {
|
||||
if (namespaces) {
|
||||
return Promise.all(
|
||||
namespaces.map(namespace => roleApi.list({ namespace }))
|
||||
).then(items => items.flat());
|
||||
} else {
|
||||
return Promise.all([clusterRoleApi.list(), roleApi.list()])
|
||||
.then(items => items.flat());
|
||||
}
|
||||
protected async loadItems(params: KubeObjectStoreLoadingParams): Promise<Role[]> {
|
||||
const items = await Promise.all([
|
||||
super.loadItems({ ...params, api: clusterRoleApi }),
|
||||
super.loadItems({ ...params, api: roleApi }),
|
||||
]);
|
||||
|
||||
return items.flat();
|
||||
}
|
||||
|
||||
protected async createItem(params: { name: string; namespace?: string }, data?: Partial<Role>) {
|
||||
@@ -49,4 +47,4 @@ export const rolesStore = new RolesStore();
|
||||
apiManager.registerStore(rolesStore, [
|
||||
roleApi,
|
||||
clusterRoleApi,
|
||||
]);
|
||||
]);
|
||||
@@ -10,7 +10,7 @@ import { KubeObjectListLayout } from "../kube-object";
|
||||
import { AddRoleDialog } from "./add-role-dialog";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
age = "age",
|
||||
@@ -25,22 +25,24 @@ export class Roles extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="access_roles"
|
||||
className="Roles"
|
||||
store={rolesStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (role: Role) => role.getName(),
|
||||
[sortBy.namespace]: (role: Role) => role.getNs(),
|
||||
[sortBy.age]: (role: Role) => role.metadata.creationTimestamp,
|
||||
[columnId.name]: (role: Role) => role.getName(),
|
||||
[columnId.namespace]: (role: Role) => role.getNs(),
|
||||
[columnId.age]: (role: Role) => role.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(role: Role) => role.getSearchFields(),
|
||||
]}
|
||||
renderHeaderTitle="Roles"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(role: Role) => [
|
||||
role.getName(),
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from "./service-accounts";
|
||||
export * from "./service-accounts-details";
|
||||
export * from "./create-service-account-dialog";
|
||||
export * from "./create-service-account-dialog";
|
||||
@@ -15,7 +15,7 @@ import { CreateServiceAccountDialog } from "./create-service-account-dialog";
|
||||
import { kubeObjectMenuRegistry } from "../../../extensions/registries/kube-object-menu-registry";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
age = "age",
|
||||
@@ -30,21 +30,23 @@ export class ServiceAccounts extends React.Component<Props> {
|
||||
return (
|
||||
<>
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="access_service_accounts"
|
||||
className="ServiceAccounts" store={serviceAccountsStore}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (account: ServiceAccount) => account.getName(),
|
||||
[sortBy.namespace]: (account: ServiceAccount) => account.getNs(),
|
||||
[sortBy.age]: (account: ServiceAccount) => account.metadata.creationTimestamp,
|
||||
[columnId.name]: (account: ServiceAccount) => account.getName(),
|
||||
[columnId.namespace]: (account: ServiceAccount) => account.getNs(),
|
||||
[columnId.age]: (account: ServiceAccount) => account.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(account: ServiceAccount) => account.getSearchFields(),
|
||||
]}
|
||||
renderHeaderTitle="Service Accounts"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(account: ServiceAccount) => [
|
||||
account.getName(),
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export * from "./user-management";
|
||||
export * from "./user-management.route";
|
||||
export * from "./user-management.route";
|
||||
@@ -18,12 +18,13 @@ import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import { ConfirmDialog } from "../confirm-dialog/confirm-dialog";
|
||||
import { Notifications } from "../notifications/notifications";
|
||||
|
||||
enum sortBy {
|
||||
enum columnId {
|
||||
name = "name",
|
||||
namespace = "namespace",
|
||||
schedule = "schedule",
|
||||
suspend = "suspend",
|
||||
active = "active",
|
||||
lastSchedule = "schedule",
|
||||
lastSchedule = "last-schedule",
|
||||
age = "age",
|
||||
}
|
||||
|
||||
@@ -35,15 +36,17 @@ export class CronJobs extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<KubeObjectListLayout
|
||||
isConfigurable
|
||||
tableId="workload_cronjobs"
|
||||
className="CronJobs" store={cronJobStore}
|
||||
dependentStores={[jobStore, eventStore]}
|
||||
sortingCallbacks={{
|
||||
[sortBy.name]: (cronJob: CronJob) => cronJob.getName(),
|
||||
[sortBy.namespace]: (cronJob: CronJob) => cronJob.getNs(),
|
||||
[sortBy.suspend]: (cronJob: CronJob) => cronJob.getSuspendFlag(),
|
||||
[sortBy.active]: (cronJob: CronJob) => cronJobStore.getActiveJobsNum(cronJob),
|
||||
[sortBy.lastSchedule]: (cronJob: CronJob) => cronJob.getLastScheduleTime(),
|
||||
[sortBy.age]: (cronJob: CronJob) => cronJob.metadata.creationTimestamp,
|
||||
[columnId.name]: (cronJob: CronJob) => cronJob.getName(),
|
||||
[columnId.namespace]: (cronJob: CronJob) => cronJob.getNs(),
|
||||
[columnId.suspend]: (cronJob: CronJob) => cronJob.getSuspendFlag(),
|
||||
[columnId.active]: (cronJob: CronJob) => cronJobStore.getActiveJobsNum(cronJob),
|
||||
[columnId.lastSchedule]: (cronJob: CronJob) => cronJob.getLastScheduleTime(),
|
||||
[columnId.age]: (cronJob: CronJob) => cronJob.metadata.creationTimestamp,
|
||||
}}
|
||||
searchFilters={[
|
||||
(cronJob: CronJob) => cronJob.getSearchFields(),
|
||||
@@ -51,14 +54,14 @@ export class CronJobs extends React.Component<Props> {
|
||||
]}
|
||||
renderHeaderTitle="Cron Jobs"
|
||||
renderTableHeader={[
|
||||
{ title: "Name", className: "name", sortBy: sortBy.name },
|
||||
{ className: "warning" },
|
||||
{ title: "Namespace", className: "namespace", sortBy: sortBy.namespace },
|
||||
{ title: "Schedule", className: "schedule" },
|
||||
{ title: "Suspend", className: "suspend", sortBy: sortBy.suspend },
|
||||
{ title: "Active", className: "active", sortBy: sortBy.active },
|
||||
{ title: "Last schedule", className: "last-schedule", sortBy: sortBy.lastSchedule },
|
||||
{ title: "Age", className: "age", sortBy: sortBy.age },
|
||||
{ title: "Name", className: "name", sortBy: columnId.name, id: columnId.name },
|
||||
{ className: "warning", showWithColumn: columnId.name },
|
||||
{ title: "Namespace", className: "namespace", sortBy: columnId.namespace, id: columnId.namespace },
|
||||
{ title: "Schedule", className: "schedule", id: columnId.schedule },
|
||||
{ title: "Suspend", className: "suspend", sortBy: columnId.suspend, id: columnId.suspend },
|
||||
{ title: "Active", className: "active", sortBy: columnId.active, id: columnId.active },
|
||||
{ title: "Last schedule", className: "last-schedule", sortBy: columnId.lastSchedule, id: columnId.lastSchedule },
|
||||
{ title: "Age", className: "age", sortBy: columnId.age, id: columnId.age },
|
||||
]}
|
||||
renderTableContents={(cronJob: CronJob) => [
|
||||
cronJob.getName(),
|
||||
|
||||
@@ -18,7 +18,7 @@ export class DaemonSetStore extends KubeObjectStore<DaemonSet> {
|
||||
}
|
||||
|
||||
getChildPods(daemonSet: DaemonSet): Pod[] {
|
||||
return podsStore.getPodsByOwner(daemonSet);
|
||||
return podsStore.getPodsByOwnerId(daemonSet.getId());
|
||||
}
|
||||
|
||||
getStatuses(daemonSets?: DaemonSet[]) {
|
||||
|
||||
Loaded 100 of 229 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user