mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Support window nodes for node-shells (#3624)
* Support window nodes for node-shells Signed-off-by: Sebastian Malton <sebastian@malton.name> * Also check beta.kubernetes/os label Signed-off-by: Sebastian Malton <sebastian@malton.name> * Add comment about linux fallback Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
c09a57370e
commit
5eb1b8553d
5 files changed
+47
-24
No files matched your search
@@ -236,13 +236,10 @@ export class Node extends KubeObject {
|
||||
}
|
||||
|
||||
getOperatingSystem(): string {
|
||||
const label = this.getLabels().find(label => label.startsWith("kubernetes.io/os="));
|
||||
|
||||
if (label) {
|
||||
return label.split("=", 2)[1];
|
||||
}
|
||||
|
||||
return "linux";
|
||||
return this.metadata?.labels?.["kubernetes.io/os"]
|
||||
|| this.metadata?.labels?.["beta.kubernetes.io/os"]
|
||||
|| this.status?.nodeInfo?.operatingSystem
|
||||
|| "linux";
|
||||
}
|
||||
|
||||
isUnschedulable() {
|
||||
|
||||
@@ -224,10 +224,7 @@ export class KubeApi<T extends KubeObject> {
|
||||
isNamespaced = options.objectConstructor?.namespaced,
|
||||
} = options || {};
|
||||
|
||||
if (!options.apiBase) {
|
||||
options.apiBase = objectConstructor.apiBase;
|
||||
}
|
||||
const { apiBase, apiPrefix, apiGroup, apiVersion, resource } = parseKubeApi(options.apiBase);
|
||||
const { apiBase, apiPrefix, apiGroup, apiVersion, resource } = parseKubeApi(options.apiBase || objectConstructor.apiBase);
|
||||
|
||||
this.kind = kind;
|
||||
this.isNamespaced = isNamespaced;
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
import { JsonApi, JsonApiData, JsonApiError } from "./json-api";
|
||||
import type { Response } from "node-fetch";
|
||||
import type { Cluster } from "../../main/cluster";
|
||||
import { LensProxy } from "../../main/lens-proxy";
|
||||
import { apiKubePrefix, isDebugging } from "../vars";
|
||||
|
||||
export interface KubeJsonApiListMetadata {
|
||||
resourceVersion: string;
|
||||
@@ -70,6 +73,20 @@ export interface KubeJsonApiError extends JsonApiError {
|
||||
}
|
||||
|
||||
export class KubeJsonApi extends JsonApi<KubeJsonApiData> {
|
||||
static forCluster(cluster: Cluster): KubeJsonApi {
|
||||
const port = LensProxy.getInstance().port;
|
||||
|
||||
return new this({
|
||||
serverAddress: `http://127.0.0.1:${port}`,
|
||||
apiBase: apiKubePrefix,
|
||||
debug: isDebugging,
|
||||
}, {
|
||||
headers: {
|
||||
"Host": `${cluster.id}.localhost:${port}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
protected parseError(error: KubeJsonApiError | any, res: Response): string[] {
|
||||
const { status, reason, message } = error;
|
||||
|
||||
@@ -80,4 +97,3 @@ export class KubeJsonApi extends JsonApi<KubeJsonApiData> {
|
||||
return super.parseError(error, res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user