A simple demo to bind a TCP port with k8s exec channel.k8s.io websocket API.

Overview

k8s-webterm-connector

Tired with web terminals? Let's use it with CLI!

This is just a simple demo to bind a TCP port with k8s exec websocket API, which use channel.k8s.io as subprotocol.

You can tweak it to suit your needs.

Usage

cargo run <tcp-address-to-bind> [websocket-url|file-url]

You can also use the latest release instead of cargo run.

WebSocket URL Example

For example, bind localhost:27730 with wss://example.com/k8s-pod/exec?token=TOKEN:

cargo run localhost:27730 'wss://example.com/k8s-pod/exec?token=TOKEN'

Keep it running, and then you can test it with:

socat - tcp:localhost:27730

File URL Example

For example, a file in /tmp/k8s-webterm-connector-ws-27730-url.txt contains the websocket URL:

wss://example.com/k8s-pod/exec?token=TOKEN

Then you can bind localhost:27730 to the webterm URL in that file with:

cargo run localhost:27730 file:///tmp/k8s-webterm-connector-ws-27730-url.txt

Keep it running, and then you can test it with:

socat - tcp:localhost:27730

SSH via k8s-webterm-connector

As long as an IO method exists, you can use it for SSH conneciton.

socat and openssh-server should be installed in the image of the target containers.

You can use tools/proxy-ssh-via-k8s-webterm.sh as ProxyCommand in your ~/.ssh/config.

Host <hostname-you-like>
  ProxyCommand <...>/k8s-webterm-connector/tools/proxy-ssh-via-k8s-webterm.sh <connector-bind-port> <port-inside-container>
  HostName <any-valid-hostname>
  User <username-in-container>
  ServerAliveInterval 15

Example

For example, k8s-webterm-connector is running and binds 27730. Inside the target container, 10022 TCP port is available or used for SSH.

Host k8s-container
  ProxyCommand ~/k8s-webterm-connector/tools/proxy-ssh-via-k8s-webterm.sh 27730 10022
  HostName container
  User root
  ServerAliveInterval 15

Then you can ssh into the container:

ssh k8s-container

Multiplex SSH via k8s-webterm-connector and port forwarding

This tool wraps tools/proxy-ssh-via-k8s-webterm.sh and forward SSH port to the local machine.

It will be more stable if URL to the webterm is constantly changing, but less efficient as only one connection is created.

./tools/k8s-webterm-ssh-forward.sh <k8s-webterm-connector-bind-port> <pod-ssh-port> <forward-ssh-bind-port>

socat and openssh-server should be installed in the image of the target containers.

Example

For example, k8s-webterm-connector is running and binds 27730. Inside the target container, 10022 TCP port is available or used for SSH. And you would like to use SSH locally to connect the container on 27731.

./tools/k8s-webterm-ssh-forward.sh 27730 10022 27731

Keep it running, and then you can ssh to the container:

ssh -p 27731 USERNAME-IN-CONTAINER@localhost
You might also like...
GraphQL Summit 2023 Workshop Demo for Federated Subscriptions in GraphOS.

Kahoot Clone Demo App - Subgraphs Welcome to the project for GraphQL Summit 2023 "Federated Subscriptions in GraphOS" workshop! ⚠️ Before the workshop

rust+slint+candle+openchat3.5 demo
rust+slint+candle+openchat3.5 demo

Slint Chatbot Demo This is a demo of Rust + Slint + Candle + OpenChat LLM, it looks like this: Do it by yourself Make sure you have downloaded opencha

Demo Repo for BSides 2024 Live Training: "Blue Crab Shells: Getting Started with Offensive Rust Programming"

Blue Crab Shells: Getting Started with Offensive Rust Programming This repository contains example code for the live training provided for BSides San

List public items (public API) of library crates. Enables diffing public API between releases.

cargo-public-items List public items (the public API) of a Rust library crate by analyzing the rustdoc JSON of the crate. Automatically builds the rus

Api testing tool made with rust to use for api developement (Kind of Tui)
Api testing tool made with rust to use for api developement (Kind of Tui)

Api testing tool made with rust to use for api developement (Kind of Tui) This Rust project provides a simple yet powerful tool for making HTTP reques

Rust port of pexpect

rexpect Spawn, control, and respond to expected patterns of child applications and processes, enabling the automation of interactions and testing. Com

Dog command for *nix systems, Rust port of dog.

dog-rs Dog command for *nix systems, Rust port of dog. Because there is a cat command, should be a dog command too. It was written completely using VS

Rust port of InfectedRose.Interface

Rust port of Wincent's InfectedRose.Interface. It is not finished; only adding to the database is possible at the moment, editing and removing is not,

This is a command line port of the game Wordle in Rust
This is a command line port of the game Wordle in Rust

Wordle.rs Welcome to Wordle.rs! This is a command line port of the game Wordle in Rust. I built this in order to get more familiar with programming in

Releases(v0.1.2)
Owner
Chielo
Chielo
Rust based Kubernetes Operator to deploy K8s objects minimally.

kube-nimble nimble /ˈnɪmbl/ - quick and light in movement or action; agile. This project began from a place of curiosity about Kubernetes CRDs and the

Meet Vasani 3 Feb 26, 2024
A high-performance WebSocket integration library for streaming public market data. Used as a key dependency of the `barter-rs` project.

Barter-Data A high-performance WebSocket integration library for streaming public market data from leading cryptocurrency exchanges - batteries includ

Barter 23 Feb 3, 2023
Core lightning (CLN) plugin to watch channel health, gossip health and ping amboss for online status

vitality Core lightning (CLN) plugin to watch channel health, gossip health and ping amboss for online status Installation Building Usage Telegram Opt

null 4 Oct 6, 2023
Show active TCP connections on a TUI world map.

Maperick Show active TCP connections on a TUI world map. Still WIP, but it's gonna be good. Setup git clone [email protected]:schlunsen/maperick.git cd m

Rasmus Schlünsen 5 Jul 8, 2022
A small cli demo of rust&wasm hostcall framework.

A Cli Example for Rust and WebAssembly Hostcall Usage # build wasms for ervery module in the `wasm` directory and move them to the root directory # ex

BC2022 3 Aug 29, 2022
Demo Rust Cursive crate for terminal user interface (TUI)

Demo Rust Cursive Demonstration of the Rust programming language and Cursvie crate for terminal user interface (TUI). Setup Create: cargo new demo Add

Joel Parker Henderson 5 Dec 27, 2022
Polyexen demo of Plonkish Arithmetiation Format (Plaf) on the zkevm-circuits

Plaf demo This is a demo of Plaf: Plonkish Arithmetiation Format on the zkevm-circuits Steps to run this: Clone these three repositories in the same f

Eduard S. 17 Apr 6, 2023
Demo app duplicated in 5 languages (Go/JavaScript/Python/Ruby/Rust) showing how to go from source code to container image using melange+apko

hello-melange-apko ?? This repo contains an example app duplicated across 5 languages showing how to: Package source code into APKs using melange Buil

Chainguard 16 Jan 23, 2023
A demo for a cross-chain lending using chainsight

demo-crosschain-lending A demo of crosschain lending, using chainsight. Overview This demo shows how to use the chainsight protocol to deposit assets

HorizonX 5 Jun 5, 2023
A set of demo projects for the Fyrox Game Engine.

Fyrox Demo Projects A set of demo projects for the Fyrox Game Engine. Most of the projects located in this repository in the respective folders. Navig

Fyrox Engine 8 Oct 4, 2023