kino_k8s_term
kino_k8s_term copied to clipboard
A Livebook Kino and Smart Cell rendering a terminal to connect to a Kubernetes Pod.
⚠️ ARCHIVED ⚠️ KinoK8sTerm
[!IMPORTANT]
This repository is archived. The smart cell is now integrated in the "Connect to Pod" smart cell of kino_k8s. Check it out!
A Livebook Kino to run a Terminal for Kubernetes Pods.
Section
About
This Kino uses the Elixir library k8s to open a connection to a pod and Xterm.js to render a terminal in your livebook. Refer to these projects for inside information.
https://user-images.githubusercontent.com/695307/208457804-614b5a82-9108-4281-b711-df8ac4040be3.mp4
Installation
This Kino is currently not published on hex.pm. To use it, install it from git:
Mix.install([
{:kino_k8s_term, git: "https://github.com/mruoss/kino_k8s_term.git", branch: "main"}
])
Usage
You can either use the Smart Cell or call KinoK8sTerm.open/4
manually.
Arguments
-
conn
- a%K8s.Conn{}
struct that can be optained by callingK8s.Conn.from_file/2
-
namespace
- The namespace your pod runs in -
pod
- The name of your pod
Options
-
container
- If your pod runs multiple containers, define the container you want to connect to. -
command
- optional. The shell that is executed once connected. Defaults to/bin/sh
.
{:ok, conn} = K8s.Conn.from_file("~/.kube/config", context: "some_local_cluster")
# For local clusters, you might want to skip TLS verification
conn = struct!(conn, insecure_skip_tls_verify: true)
namespace = "default"
pod = "nginx-deployment-6595874d85-5kdf4"
container = "nginx"
command = "/bin/bash"
KinoK8sTerm.open(conn, namespace, pod, container: container, command: command)
Smart Cell
This Kino comes with a smart cell, too. Open this README in Livebook to see it in action.
IO.puts("Connection could not be established.
Please configure the connection to the pod and reevaluate the cell.")
:no_conn
Security
Note that the user defined in the conn
object needs permissions to the pods/exec
resource in your cluster. If this is not given, the terminal can't be opened.
Use this Kino for local clusters only. Or protect your livebook well from unwanted access.