All Projects → mhausenblas → Kn

mhausenblas / Kn

Licence: apache-2.0
A collection of shell functions for Kubernetes native dabbling

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Kn

Kit
Tools for developing, documenting, and testing React component libraries
Stars: ✭ 1,201 (+2351.02%)
Mutual labels:  cli, development
N8n
Free and open fair-code licensed node based Workflow Automation Tool. Easily automate tasks across different services.
Stars: ✭ 19,252 (+39189.8%)
Mutual labels:  cli, development
Python Sploitkit
Devkit for building Metasploit-like consoles
Stars: ✭ 148 (+202.04%)
Mutual labels:  cli, development
Devspace
DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
Stars: ✭ 2,559 (+5122.45%)
Mutual labels:  cli, development
Micro Dev
The development environment for `micro`
Stars: ✭ 630 (+1185.71%)
Mutual labels:  cli, development
Wago
Automate the actions you do after saving code.
Stars: ✭ 60 (+22.45%)
Mutual labels:  cli, development
Webpack Serve
Takes your webpack config and creates a development server with hot module reloading and error overlay
Stars: ✭ 177 (+261.22%)
Mutual labels:  cli, development
Http Prompt
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
Stars: ✭ 8,329 (+16897.96%)
Mutual labels:  cli, development
Saws
A supercharged AWS command line interface (CLI).
Stars: ✭ 4,886 (+9871.43%)
Mutual labels:  cli, development
Httplab
The interactive web server
Stars: ✭ 3,752 (+7557.14%)
Mutual labels:  cli, development
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+108169.39%)
Mutual labels:  cli, development
Create Osdoc App
create-osdoc-app cli
Stars: ✭ 26 (-46.94%)
Mutual labels:  cli, development
Ok Mdx
Browser-based MDX editor
Stars: ✭ 681 (+1289.8%)
Mutual labels:  cli, development
Influx Prompt
An interactive command-line InfluxDB cli with auto completion.
Stars: ✭ 42 (-14.29%)
Mutual labels:  cli, development
1line Py
Enseñando pensamiento computacional a partir de python one-liners
Stars: ✭ 45 (-8.16%)
Mutual labels:  development
Gosearch
🔍 Search the Go packages via command-line
Stars: ✭ 48 (-2.04%)
Mutual labels:  cli
Lucid
A simple mock-application for programs that work with child processes
Stars: ✭ 45 (-8.16%)
Mutual labels:  cli
Bookmenu
Browse and download ebooks from your terminal.
Stars: ✭ 45 (-8.16%)
Mutual labels:  cli
Colorette
Easily set the color and style of text in the terminal.
Stars: ✭ 1,047 (+2036.73%)
Mutual labels:  cli
Graphql Zeus
GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native
Stars: ✭ 1,043 (+2028.57%)
Mutual labels:  cli

A Kubernetes native shell experience: kn

The basic idea behind kn is to use the fact that pods in Kubernetes are modelled after machines. That is, the apps running in containers in the pod can communicate with each other via localhost and transfer data via volumes they can mount into their own filesystem hierarchy as they see fit.

So, imagine you want to try something out real quick? Do a short iteration using a scripting language such as Python, Ruby, or Node.js? Might want to jump on a container to debug something in-cluster? Run a quick load test? Then, kn is for you: it offers a collection of shell functions allowing you to quickly launch a pod, jump into it and have the code and data available you need to carry out your task.

Note that this tool is meant to be used in dev and test environments. Use at your own risk.

Install

Simply Git clone or download this repo from the release page, and copy kn*.sh somewhere on your path. If you're super fancy, you can set an alias like so: (since I moved the script to /Users/mhausenblas/bin/):

alias kn='/Users/mhausenblas/bin/kn.sh'

I've tested kn in the Bash shell v3.2 on macOS and Linux. Note that in order to work kn requires you to have kubectl installed and configured. If you also want to use the (optional) feature to expose an environment to the public, you need to have ngrok installed and configured.

Use

Config

The following environment variables are used (set global or per invocation):

  • KN_BASE_IMAGE … set the base image to use; defaults to centos:7.
  • KN_SYNC … if set to true, the content of the current directory will be copied into the pod at /tmp/work; defaults to true.
  • KN_POLICY … if set to public, services will be made available on the public Web using ngrok; defaults to local.
  • KN_MODE … if set to daemon, the environment is detached and we assume there's some kind of networked service running; defaults to interactive.

Commands

The following commands are available:

  • up [NAME] [PORT] … creates environment, copies files of current directory unless disabled by KN_SYNC=false.
  • connect NAME … puts you into the running environment.
  • down NAME … deletes environment, removes all resources associated with it.
  • publish NAME PORT … publishes the daemonized environment NAME by using port-forwarding of PORT in the environment (assuming something serves on this port in the container) to port 9898 locally, and, if enabled by KN_POLICY, makes it also publicly available using ngrok.
  • ls … lists all resources manged by kn.

Examples

Launching an interactive environment with kn:

## launch interactive environment:
$ kn up
.......
Copied content of /Users/mhausenblas/tmp to /tmp/work in the environment
The environment [sandbox] is now ready!

## list all environments:
$ kn ls
NAME      SINCE
sandbox   2018-10-22T10:16:13Z

## jump into the environment:
$ kn connect
connecting to sandbox-64dc6d6bf9-s6gzjsh-4.2#
sh-4.2#
sh-4.2# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 10:16 ?        00:00:00 sleep 86400
root        27     0  0 10:17 pts/0    00:00:00 sh
root        36    27  0 10:17 pts/0    00:00:00 ps -ef
sh-4.2# exit
exit

## destroy the environment:
$ kn down
The environment [sandbox] has been destroyed, all data is gone the way of the dodo

Publishing a daemonized environment using the container image quay.io/mhausenblas/pingsvc:2 that serves on port 8888:

## launch as daemonized env:
$ KN_BASE_IMAGE=quay.io/mhausenblas/pingsvc:2 KN_MODE=daemon kn up psvc 8888
The daemonized environment [psvc] is now ready!
To publish your environment, do: kn publish psvc 8888

## now make it publicly available using ngrok:
$ KN_POLICY=public kn publish psvc 8888
ngrok by @inconshreveable

Session Status                online
Account                       Michael Hausenblas (Plan: Pro)
Version                       2.2.8
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://0cf727cf.ngrok.io -> localhost:9898
Forwarding                    https://0cf727cf.ngrok.io -> localhost:9898

Connections                   ttl     opn     rt1     rt5     p50     p90
                              1       0       0.01    0.00    0.30    0.30

HTTP Requests
-------------

GET /ping                      200 OK

## in a second terminal session, check if we can get to the service:
$ curl localhost:9898/ping
pong

$ curl http://0cf727cf.ngrok.io/ping
pong

## now we can get rid of the environment:
$ kn down psvc
The environment [psvc] has been destroyed, all data is gone the way of the dodo
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].