Skip to content

Allow to run node shell on Bootlerocket and Windows nodes#7965

Open
dex4er wants to merge 2 commits into
lensapp:masterfrom
dex4er:feature/node-shell-windows
Open

Allow to run node shell on Bootlerocket and Windows nodes#7965
dex4er wants to merge 2 commits into
lensapp:masterfrom
dex4er:feature/node-shell-windows

Conversation

@dex4er
Copy link
Copy Markdown
Contributor

@dex4er dex4er commented Oct 23, 2023

This is a reworked node-shell feature. It allows to run it on Bottlerocket OS and Windows nodes where there is no sh nor bash command.

Unfortunately, node-shell pods cannot be autoremoved anymore with sleep command. It is because now single pod is created and then kubectl attach is run. It is because kubectl exec with nsenter command won't work: Bottlerocket OS is SELinux hardened then nsenter won't have privileges to run in kubectl exec context.

Anyway: node-shell pods are correctly removed after the terminal is closed.

Because Windows needs separate image, there is a separate setting now:

image

Node shell for Ubuntu:

image

Node shell for Bottlerocket:

image

Node shell for Windows 2022:

image

@dex4er dex4er requested a review from a team as a code owner October 23, 2023 09:09
@dex4er dex4er requested review from aleksfront and ixrock and removed request for a team October 23, 2023 09:09
Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
@dex4er dex4er force-pushed the feature/node-shell-windows branch from 00eb857 to 83b2ce6 Compare October 23, 2023 09:09
Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
@moebaca
Copy link
Copy Markdown

moebaca commented Feb 13, 2024

Any update on this? Would love to pop into Bottlerocket using Lens like I do for AL2.

@ajaykumarmandapati
Copy link
Copy Markdown

Would this be available soon? 🙏🏾

@ixrock ixrock requested review from a team, Nokel81 and ixrock and removed request for a team, aleksfront and ixrock April 8, 2024 07:07
@matti
Copy link
Copy Markdown

matti commented Feb 8, 2025

@CodiumAI-Agent /review

@QodoAI-Agent
Copy link
Copy Markdown

QodoAI-Agent commented Feb 8, 2025

PR Reviewer Guide 🔍

(Review updated until commit 0a83a96)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The logic for determining the args for Bottlerocket OS and Windows nodes seems complex and could lead to unexpected behavior if the nodeOsImage or nodeOs values are not as expected. This should be carefully validated.

const nodeOs = node.getOperatingSystem();
const nodeOsImage = node.getOperatingSystemImage();

let image: string;
let command: string[]; 
let args: string[];
let securityContext: any;

switch (nodeOs) {
  default:
    this.dependencies.logger.warn(`[NODE-SHELL-SESSION]: could not determine node OS, falling back with assumption of linux`);
    // fallthrough
  case "linux":
    image = nodeShellImage || initialNodeShellImage;
    command = ["nsenter"];

    if (nodeOsImage && nodeOsImage.startsWith("Bottlerocket OS")) {
      args = ["-t", "1", "-m", "-u", "-i", "-n", "-p", "--", "apiclient", "exec", "admin", "bash", "-l"];
    } else {
      args = ["-t", "1", "-m", "-u", "-i", "-n", "-p", "--", "bash", "-l"];
    }

    securityContext = {
      privileged: true,
    };
    break;
  case "windows":
    image = nodeShellImage || initialNodeShellWindowsImage;
    command = ["cmd.exe"];
    args = ["/c", "%CONTAINER_SANDBOX_MOUNT_POINT%\\Program Files\\PowerShell\\latest\\pwsh.exe", "-nol", "-wd", "C:\\"];
    securityContext = {
      privileged: true,
      windowsOptions: {
        hostProcess: true,
        runAsUserName: "NT AUTHORITY\\SYSTEM",
      },
UI Consistency

The added input fields for Linux and Windows node shell images should be checked for consistent behavior, including placeholder text, reset functionality, and hint messages.

  <SubTitle title="Node shell image for Linux" id="node-shell-image"/>
  <Input
    theme="round-black"
    placeholder={`Default image: ${initialNodeShellImage}`}
    value={this.nodeShellImage}
    onChange={value => this.nodeShellImage = value}
    iconRight={
      this.nodeShellImage
        ? (
          <Icon
            smallest
            material="close"
            onClick={() => this.nodeShellImage = ""}
            tooltip="Reset"
          />
        )
        : undefined
    }
  />
  <small className="hint">
    Node shell image. Used for creating node shell pod on Linux nodes.
  </small>
</section>
<Gutter />
<section>
  <SubTitle title="Node shell image for Windows" id="node-shell-windows-image"/>
  <Input
    theme="round-black"
    placeholder={`Default image: ${initialNodeShellWindowsImage}`}
    value={this.nodeShellWindowsImage}
    onChange={value => this.nodeShellWindowsImage = value}
    iconRight={
      this.nodeShellWindowsImage
        ? (
          <Icon
            smallest
            material="close"
            onClick={() => this.nodeShellWindowsImage = ""}
            tooltip="Reset"
          />
        )
        : undefined
    }
  />
  <small className="hint">
    Node shell image. Used for creating node shell pod on Windows nodes.
  </small>

@ajaykumarmandapati
Copy link
Copy Markdown

Hi, circling back? Is there a timeframe for releases in general and when this might be released if at all.
Thanks!

@QodoAI-Agent
Copy link
Copy Markdown

Persistent review updated to latest commit 0a83a96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants