mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add Runtime Classes views (#6294)
* Show runtimeClassName in pods view Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com> * Runtime Classes view Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com> * Reverted formatting Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com> Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
This commit is contained in:
1 parent
6dc2a5c4e8
commit
79efe1be29
26 files changed
+609
-5
No files matched your search
@@ -34,6 +34,7 @@ export * from "./replica-set.api";
|
||||
export * from "./resource-quota.api";
|
||||
export * from "./role.api";
|
||||
export * from "./role-binding.api";
|
||||
export * from "./runtime-class.api";
|
||||
export * from "./secret.api";
|
||||
export * from "./self-subject-rules-reviews.api";
|
||||
export * from "./service.api";
|
||||
|
||||
@@ -677,6 +677,10 @@ export class Pod extends KubeObject<
|
||||
return this.spec?.priorityClassName || "";
|
||||
}
|
||||
|
||||
getRuntimeClassName() {
|
||||
return this.spec?.runtimeClassName || "";
|
||||
}
|
||||
|
||||
getServiceAccountName() {
|
||||
return this.spec?.serviceAccountName || "";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import assert from "assert";
|
||||
import { storesAndApisCanBeCreatedInjectionToken } from "../stores-apis-can-be-created.token";
|
||||
import { RuntimeClassApi } from "./runtime-class.api";
|
||||
import { kubeApiInjectionToken } from "../kube-api/kube-api-injection-token";
|
||||
|
||||
const runtimeClassApiInjectable = getInjectable({
|
||||
id: "runtime-class-api",
|
||||
instantiate: (di) => {
|
||||
assert(di.inject(storesAndApisCanBeCreatedInjectionToken), "RuntimeClassApi is only available in certain environments");
|
||||
|
||||
return new RuntimeClassApi();
|
||||
},
|
||||
|
||||
injectionToken: kubeApiInjectionToken,
|
||||
});
|
||||
|
||||
export default runtimeClassApiInjectable;
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { ClusterScopedMetadata, KubeObjectMetadata, KubeObjectScope, Toleration } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
|
||||
export interface RuntimeClassData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Cluster>, void, void> {
|
||||
handler: string;
|
||||
overhead?: RuntimeClassOverhead;
|
||||
scheduling?: RuntimeClassScheduling;
|
||||
}
|
||||
|
||||
export interface RuntimeClassOverhead {
|
||||
podFixed?: string;
|
||||
}
|
||||
|
||||
export interface RuntimeClassScheduling {
|
||||
nodeSelector?: Partial<Record<string, string>>;
|
||||
tolerations?: Toleration[];
|
||||
}
|
||||
|
||||
export class RuntimeClass extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "RuntimeClass";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/apis/node.k8s.io/v1/runtimeclasses";
|
||||
|
||||
handler: string;
|
||||
overhead?: RuntimeClassOverhead;
|
||||
scheduling?: RuntimeClassScheduling;
|
||||
|
||||
constructor({ handler, overhead, scheduling, ...rest }: RuntimeClassData) {
|
||||
super(rest);
|
||||
this.handler = handler;
|
||||
this.overhead = overhead;
|
||||
this.scheduling = scheduling;
|
||||
}
|
||||
|
||||
getHandler() {
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
getPodFixed() {
|
||||
return this.overhead?.podFixed ?? "";
|
||||
}
|
||||
|
||||
getNodeSelectors(): string[] {
|
||||
return Object.entries(this.scheduling?.nodeSelector ?? {})
|
||||
.map(values => values.join(": "));
|
||||
}
|
||||
|
||||
getTolerations() {
|
||||
return this.scheduling?.tolerations ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
export class RuntimeClassApi extends KubeApi<RuntimeClass, RuntimeClassData> {
|
||||
constructor(opts: DerivedKubeApiOptions = {}) {
|
||||
super({
|
||||
objectConstructor: RuntimeClass,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user