Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

mruoss/kino_k8s_term

Repository files navigation

⚠️ 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

Run in Livebook

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.

kino_k8s_term.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 calling K8s.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.

About

A Livebook Kino and Smart Cell rendering a terminal to connect to a Kubernetes Pod.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published