All Projects → ernoaapa → Kubectl Warp

ernoaapa / Kubectl Warp

Licence: apache-2.0
Kubernetes CLI plugin for syncing and executing local files in Pod on Kubernetes

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Kubectl Warp

Kubectl Debug
Debug your pod by a new container with every troubleshooting tools pre-installed
Stars: ✭ 2,091 (+753.47%)
Mutual labels:  kubectl
Rsnapshot
a tool for backing up your data using rsync (if you want to get help, use https://lists.sourceforge.net/lists/listinfo/rsnapshot-discuss)
Stars: ✭ 2,335 (+853.06%)
Mutual labels:  rsync
Routinator
An RPKI Validator written in Rust
Stars: ✭ 215 (-12.24%)
Mutual labels:  rsync
Rsync Incremental Backup
Configurable bash script to send incremental backups of your data to a local or remote target
Stars: ✭ 150 (-38.78%)
Mutual labels:  rsync
System Tar And Restore
Backup and Restore your system using tar or Transfer it with rsync
Stars: ✭ 170 (-30.61%)
Mutual labels:  rsync
Tubekit
🧪 kubectl alternative with quick context switching, kubectl on steroids
Stars: ✭ 194 (-20.82%)
Mutual labels:  kubectl
Kubectl Aliases
Programmatically generated handy kubectl aliases.
Stars: ✭ 2,152 (+778.37%)
Mutual labels:  kubectl
Helm Kubectl
Docker Hub image with helm and kubectl on top of alpine linux with bash
Stars: ✭ 233 (-4.9%)
Mutual labels:  kubectl
K8s In 30mins
Learn how to set up the Kubernetes cluster in 30 mins and deploy the application inside the cluster.
Stars: ✭ 172 (-29.8%)
Mutual labels:  kubectl
Rsync Time Backup
Time Machine style backup with rsync.
Stars: ✭ 2,572 (+949.8%)
Mutual labels:  rsync
Kube Shell
Kubernetes shell: An integrated shell for working with the Kubernetes
Stars: ✭ 2,012 (+721.22%)
Mutual labels:  kubectl
Primehub
A toil-free multi-tenancy machine learning platform in your Kubernetes cluster
Stars: ✭ 160 (-34.69%)
Mutual labels:  kubectl
Kubefwd
Bulk port forwarding Kubernetes services for local development.
Stars: ✭ 2,713 (+1007.35%)
Mutual labels:  kubectl
Kube Fzf
Shell commands using kubectl and fzf for command-line fuzzy searching of Kubernetes Pods.
Stars: ✭ 153 (-37.55%)
Mutual labels:  kubectl
Sftpgo
Fully featured and highly configurable SFTP server with optional HTTP, FTP/S and WebDAV support - S3, Google Cloud Storage, Azure Blob
Stars: ✭ 3,534 (+1342.45%)
Mutual labels:  rsync
Maratona Kubernetes
Repositório de código de demonstrações da Maratona Kubernetes 🇧🇷
Stars: ✭ 152 (-37.96%)
Mutual labels:  kubectl
Kube Ps1
Kubernetes prompt info for bash and zsh
Stars: ✭ 2,499 (+920%)
Mutual labels:  kubectl
Ketall
Like `kubectl get all`, but get really all resources
Stars: ✭ 233 (-4.9%)
Mutual labels:  kubectl
Go Fastdfs
go-fastdfs 是一个简单的分布式文件系统(私有云存储),具有无中心、高性能,高可靠,免维护等优点,支持断点续传,分块上传,小文件合并,自动同步,自动修复。Go-fastdfs is a simple distributed file system (private cloud storage), with no center, high performance, high reliability, maintenance free and other advantages, support breakpoint continuation, block upload, small file merge, automatic synchronization, automatic r…
Stars: ✭ 2,923 (+1093.06%)
Mutual labels:  rsync
Blackbelt Aks Hackfest
Microsoft Intelligent Cloud Blackbelt Team :: Hackfest Repo
Stars: ✭ 209 (-14.69%)
Mutual labels:  kubectl


kubectl (Kubernetes CLI) plugin which is like kubectl run with rsync.

It creates temporary Pod and synchronises your local files to the desired container and executes any command.

Why

Sometimes you need to develop/execute your code in Kubernetes, because access to database, insufficient resources locally, need access to some specific device, use specific architecture, etc. The full build image, push, deploy cycle is way too slow for real development.

Use cases

This can be used for example to build and run your local project in Kubernetes where's more resources, required architecture, etc. while using your prefed editor locally.

Alternatives

  • kubectl cp - Does full file copying, which is slow if a lot of files
  • NFS - requires a lot of extra installation and configuration

Other similar

How it works

kubectl warp is basically just combination of, simplified and modified version of kubectl run, sshd-rsync container and kubectl port-forward to access the container.

1. Start the Pod

First the warp generates temporary SSH key pair and and starts a temporary Pod with desired image and sshd-rsync container with the temporary public SSH public key as authorized key.

The sshd-rsync is just container with sshd daemon running in port 22 and rsync binary installed so the local rsync can sync the files to the shared volume over the SSH. The Pod have the sshd-rsync container defined twice, as init-container to make the initial sync before the actual container to start, and as a sidecar for the actual container to keep the files in-sync. The init-container waits one rsync execution and completes after succesfully so the actual containers can start.

2. Open tunnel

To sync the files with rsync over the SSH, warp opens port forwarding from random local port to the Pod port 22, what the sshd-rsync init- and sidecar-container listen.

3. Initial sync

At first, the Pod is in init state, and only the sshd-rsync is running and waiting for single sync execution. When the initial sync is done, the container completes succesfully so the Pod starts the actual containers.

The initial sync is needed so that we can start the actual container with any command. E.g. if we have shell script test.sh and when the container start with ./test.sh as the command, the file must be there available before the execution.

4. Continuous syncing

When the initial sync is done, the actual container start with sshd-rsync as a sidecar. The warp command continuously run rsync command locally to update the files in the Pod.

Install

With Krew (Kubernetes plugin manager)

Install Krew, then run the following commands:

krew update
krew install warp

MacOS with Brew

brew install rsync ernoaapa/kubectl-plugins/warp

Linux / MacOS without Brew

  1. Install rsync with your preferred package manager
  2. Download kubectl-warp binary from releases
  3. Add it to your PATH

Usage

When the plugin binary is found from PATH you can just execute it through kubectl CLI

kubectl warp --help

Basics

# Start bash in ubuntu image. Files in current directory will be synced to the container
kubectl warp -i -t --image ubuntu testing -- /bin/bash

# Start nodejs project in node container
cd examples/nodejs
kubectl warp -i -t --image node testing-node -- npm run watch

Exclude / Include

Sometimes some directories are too unnecessary to sync so you can speed up the initial sync with --exclude and --include flags, those gets passed to the rsync command, for more info see rsync manual

# Do not sync local node_modules, because we fetch dependencies in the container as first command
cd examples/nodejs
kubectl warp -i -t --image node testing-node --exclude="node_modules/***" -- npm install && npm run watch

Examples

There's some examples with different languages in examples directory

Development

Prerequisites

Build and run locally

go run ./main.go --image alpine -- ls -la

# Syncs your local files to Kubernetes and list the files

Build and install locally

go install .

# Now you can use `kubectl`
kubectl warp --help
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].