mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
New resource view: Network -> Ingress Classes (#6808)
* added backbone for k8s-api/endpoints/ingress-class.api Signed-off-by: Roman <ixrock@gmail.com> * added ingress-class store, naming clean up Signed-off-by: Roman <ixrock@gmail.com> * navigate to ingress-classses injectable Signed-off-by: Roman <ixrock@gmail.com> * added new sidebar item: "Network -> Ingress Classes" Signed-off-by: Roman <ixrock@gmail.com> * added explicit returning type for `ingresses-sidebar-items.injectable` Signed-off-by: Roman <ixrock@gmail.com> * added initial ingress-class table-view + magic route-component.injectable Signed-off-by: Roman <ixrock@gmail.com> * fix: show loaded items from api into IngressClasses view Signed-off-by: Roman <ixrock@gmail.com> * fix: new bugs after master merging (with conflicts!), looks like breaking change if those apis where exported Signed-off-by: Roman <ixrock@gmail.com> * fix lint Signed-off-by: Roman <ixrock@gmail.com> * added icon-marker to see default ingress class in the list Signed-off-by: Roman <ixrock@gmail.com> * Page refresh is broken in development mode #6818 (upcoming fix) Signed-off-by: Roman <ixrock@gmail.com> * added "set as default" menu action for ingress classes Signed-off-by: Roman <ixrock@gmail.com> * fix: consistent sidebar items order by janne's request Signed-off-by: Roman <ixrock@gmail.com> * chore, fix lint Signed-off-by: Roman <ixrock@gmail.com> * fix: incorrect icons layout in ingress-class details Signed-off-by: Roman <ixrock@gmail.com> * some fixes, improved items search by values from `spec.parameters.*` Signed-off-by: Roman <ixrock@gmail.com> * fix: duplicating/overcaching items with each page visiting (Nnetwork -> Ingress classes) Signed-off-by: Roman <ixrock@gmail.com> * handling IngressClass drawer details Signed-off-by: Roman <ixrock@gmail.com> * fixes: remove duplicating / allow editing IngressClass items (due api's "namespaced=true") Signed-off-by: Roman <ixrock@gmail.com> * fix: incorrect `apiName` for `front-end-routing/cluster/network/ingress-class` Signed-off-by: Roman <ixrock@gmail.com> * fix: IngressClass proper metadata typing Signed-off-by: Roman <ixrock@gmail.com> * allow to mark as default IngressClass from menu item Signed-off-by: Roman <ixrock@gmail.com> * fix lint Signed-off-by: Roman <ixrock@gmail.com> * fixes & responding to comments Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
e5a67d535f
commit
1456e1e597
25 files changed
+651
-23
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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 { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token";
|
||||
import {
|
||||
shouldShowResourceInjectionToken,
|
||||
} from "../../../../../cluster-store/allowed-resources-injection-token";
|
||||
|
||||
const ingressClassesesRouteInjectable = getInjectable({
|
||||
id: "ingress-classes-route",
|
||||
|
||||
instantiate: (di) => {
|
||||
const isEnabled = di.inject(shouldShowResourceInjectionToken, {
|
||||
apiName: "ingressclasses",
|
||||
group: "networking.k8s.io",
|
||||
});
|
||||
|
||||
return {
|
||||
path: "/ingress-classes",
|
||||
clusterFrame: true,
|
||||
isEnabled,
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: frontEndRouteInjectionToken,
|
||||
});
|
||||
|
||||
export default ingressClassesesRouteInjectable;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
|
||||
import ingressClassesesRouteInjectable from "./ingress-classeses-route.injectable";
|
||||
|
||||
const navigateToIngressesInjectable = getInjectable({
|
||||
id: "navigate-to-ingress-classes",
|
||||
|
||||
instantiate: (di) => {
|
||||
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
|
||||
const route = di.inject(ingressClassesesRouteInjectable);
|
||||
|
||||
return () => navigateToRoute(route);
|
||||
},
|
||||
});
|
||||
|
||||
export default navigateToIngressesInjectable;
|
||||
@@ -18,6 +18,7 @@ export * from "./endpoint.api";
|
||||
export * from "./events.api";
|
||||
export * from "./horizontal-pod-autoscaler.api";
|
||||
export * from "./ingress.api";
|
||||
export * from "./ingress-class.api";
|
||||
export * from "./job.api";
|
||||
export * from "./lease.api";
|
||||
export * from "./limit-range.api";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 { IngressClassApi } from "./ingress-class.api";
|
||||
import { kubeApiInjectionToken } from "../kube-api/kube-api-injection-token";
|
||||
|
||||
const ingressClassApiInjectable = getInjectable({
|
||||
id: "ingress-class-api",
|
||||
instantiate: () => {
|
||||
return new IngressClassApi();
|
||||
},
|
||||
|
||||
injectionToken: kubeApiInjectionToken,
|
||||
});
|
||||
|
||||
export default ingressClassApiInjectable;
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { ResourceDescriptor } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
|
||||
export class IngressClassApi extends KubeApi<IngressClass> {
|
||||
constructor() {
|
||||
super({
|
||||
objectConstructor: IngressClass,
|
||||
checkPreferredVersion: true,
|
||||
fallbackApiBases: ["/apis/extensions/v1beta1/ingressclasses"],
|
||||
});
|
||||
}
|
||||
|
||||
setAsDefault({ name }: ResourceDescriptor, isDefault = true) {
|
||||
const reqUrl = this.formatUrlForNotListing({ name });
|
||||
|
||||
return this.request.patch(reqUrl, {
|
||||
data: {
|
||||
metadata: {
|
||||
annotations: {
|
||||
[IngressClass.ANNOTATION_IS_DEFAULT]: JSON.stringify(isDefault),
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
headers: {
|
||||
"content-type": "application/strategic-merge-patch+json",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// API docs: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.22/#ingressclass-v1-networking-k8s-io
|
||||
export type IngressClassMetadata = KubeObjectMetadata<KubeObjectScope.Cluster> & {
|
||||
"name": string;
|
||||
"labels"?: {
|
||||
[name: string]: string | undefined;
|
||||
"app.kubernetes.io/component"?: "controller";
|
||||
};
|
||||
"annotations"?: {
|
||||
[name: string]: string | undefined;
|
||||
"ingressclass.kubernetes.io/is-default-class"?: "true";
|
||||
};
|
||||
};
|
||||
|
||||
export interface IngressClassParametersReference {
|
||||
"apiGroup": string; // k8s.example.net
|
||||
"scope": "Namespace" | "Cluster";
|
||||
"kind": "ClusterIngressParameter" | "IngressParameter";
|
||||
"name": string; // external-config-1
|
||||
"namespace"?: string; // namespaced for IngressClass must be defined in `spec.parameters.namespace` instead of `metadata.namespace` (!)
|
||||
}
|
||||
|
||||
export interface IngressClassSpec {
|
||||
controller: string; // "example.com/ingress-controller"
|
||||
parameters?: IngressClassParametersReference;
|
||||
}
|
||||
|
||||
export interface IngressClassStatus {
|
||||
}
|
||||
|
||||
export class IngressClass extends KubeObject<IngressClassMetadata, IngressClassStatus, IngressClassSpec> {
|
||||
static readonly kind = "IngressClass";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/apis/networking.k8s.io/v1/ingressclasses";
|
||||
static readonly ANNOTATION_IS_DEFAULT = "ingressclass.kubernetes.io/is-default-class";
|
||||
|
||||
getController(): string {
|
||||
return this.spec.controller;
|
||||
}
|
||||
|
||||
getCtrlApiGroup() {
|
||||
return this.spec?.parameters?.apiGroup;
|
||||
}
|
||||
|
||||
getCtrlScope() {
|
||||
return this.spec?.parameters?.scope;
|
||||
}
|
||||
|
||||
getCtrlNs() {
|
||||
return this.spec?.parameters?.namespace;
|
||||
}
|
||||
|
||||
getCtrlKind() {
|
||||
return this.spec?.parameters?.kind;
|
||||
}
|
||||
|
||||
getCtrlName() {
|
||||
return this.spec?.parameters?.name as string;
|
||||
}
|
||||
|
||||
get isDefault() {
|
||||
return this.metadata.annotations?.[IngressClass.ANNOTATION_IS_DEFAULT] === "true";
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
export type KubeResource =
|
||||
"namespaces" | "nodes" | "events" | "resourcequotas" | "services" | "limitranges" | "leases" |
|
||||
"secrets" | "configmaps" | "ingresses" | "networkpolicies" | "persistentvolumeclaims" | "persistentvolumes" | "storageclasses" |
|
||||
"secrets" | "configmaps" | "ingresses" | "ingressclasses" | "networkpolicies" | "persistentvolumeclaims" | "persistentvolumes" | "storageclasses" |
|
||||
"pods" | "daemonsets" | "deployments" | "statefulsets" | "replicasets" | "jobs" | "cronjobs" |
|
||||
"endpoints" | "customresourcedefinitions" | "horizontalpodautoscalers" | "podsecuritypolicies" | "poddisruptionbudgets" |
|
||||
"priorityclasses" | "runtimeclasses" |
|
||||
@@ -87,6 +87,11 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
group: "networking.k8s.io",
|
||||
namespaced: true,
|
||||
},
|
||||
ingressclasses: {
|
||||
kind: "IngressClass",
|
||||
group: "networking.k8s.io",
|
||||
namespaced: false,
|
||||
},
|
||||
jobs: {
|
||||
kind: "Job",
|
||||
group: "batch",
|
||||
|
||||
Reference in new issue
Block a user