1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

support shell to windows pod (powershell) (#136)

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen 2020-03-18 18:26:54 +02:00 committed by GitHub
parent 957c810e1e
commit 7499b981c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View File

@ -145,6 +145,15 @@ export class Node extends KubeObject {
return this.status.nodeInfo.kubeletVersion;
}
getOperatingSystem(): string {
const label = this.getLabels().find(label => label.startsWith("kubernetes.io/os="))
if (label) {
return label.split("=", 2)[1]
}
return "linux"
}
isUnschedulable() {
return this.spec.unschedulable
}

View File

@ -401,6 +401,10 @@ export class Pod extends WorkloadKubeObject {
);
return probe;
}
getNodeName() {
return this.spec?.nodeName
}
}
export const podsApi = new PodsApi({

View File

@ -3,7 +3,7 @@ import "./pod-menu.scss";
import * as React from "react";
import { t, Trans } from "@lingui/macro";
import { MenuItem, SubMenu } from "../menu";
import { IPodContainer, Pod } from "../../api/endpoints";
import { IPodContainer, Pod, nodesApi } from "../../api/endpoints";
import { Icon } from "../icon";
import { StatusBrick } from "../status-brick";
import { PodLogsDialog } from "./pod-logs-dialog";
@ -17,11 +17,18 @@ interface Props extends KubeObjectMenuProps<Pod> {
}
export class PodMenu extends React.Component<Props> {
execShell(container?: string) {
async execShell(container?: string) {
hideDetails();
const { object: pod } = this.props
const containerParam = container ? `-c ${container}` : ""
const command = `kubectl exec -i -t -n ${pod.getNs()} ${pod.getName()} ${containerParam} "--" sh -c "((clear && bash) || (clear && ash) || (clear && sh))"`
const node = await nodesApi.get({name: pod.getNodeName()})
let command = `kubectl exec -i -t -n ${pod.getNs()} ${pod.getName()} ${containerParam} "--"`
if (node.getOperatingSystem() == "windows") {
command = `${command} powershell`
} else {
command = `${command} sh -c "clear; (bash || ash || sh)"`
}
terminalStore.sendCommand(command, {
enter: true,
newTab: true,