Code Monkey home page Code Monkey logo

skbn's Introduction

Release Travis branch Docker Pulls Go Report Card license

Skbn

Skbn is a tool for copying files and directories between Kubernetes and cloud storage providers. It is named after the 1981 video game Sokoban. Skbn uses an in-memory buffer for the copy process, to avoid excessive memory consumption. Skbn currently supports the following providers:

  • AWS S3
  • Minio S3
  • Azure Blob Storage

Install

Prerequisites

  1. git
  2. dep

From a release

Download the latest release from the Releases page or use it with a Docker image

From source

mkdir -p $GOPATH/src/github.com/nuvo && cd $_
git clone https://github.com/nuvo/skbn.git && cd skbn
make

Usage

Copy files from Kubernetes to S3

skbn cp \
    --src k8s://<namespace>/<podName>/<containerName>/<path> \
    --dst s3://<bucket>/<path>

Copy files from S3 to Kubernetes

skbn cp \
    --src s3://<bucket>/<path> \
    --dst k8s://<namespace>/<podName>/<containerName>/<path>

Copy files from Kubernetes to Azure Blob Storage

skbn cp \
    --src k8s://<namespace>/<podName>/<containerName>/<path> \
    --dst abs://<account>/<container>/<path>

Copy files from Azure Blob Storage to Kubernetes

skbn cp \
    --src abs://<account>/<container>/<path> \
    --dst k8s://<namespace>/<podName>/<containerName>/<path>

Advanced usage

Copy files from source to destination in parallel

skbn cp \
    --src ... \
    --dst ... \
    --parallel <n>
  • n is the number of files to be copied in parallel (for full parallelism use 0)

Set in-memory buffer size

Skbn copies files using an in-memory buffer. To control the buffer size:

skbn cp \
    --src ... \
    --dst ... \
    --buffer-size <f>
  • f is the in-memory buffer size (in MB) to use for files copy. This flag should be used with caution when used in conjunction with --parallel
  • The default value for buffer-size is 6.75 MB, and was decided based on benchmark

Minio S3 support

Skbn supports file copy from and to a Minio S3 endpoint. To let skbn know how your minio is configured, you can set the following environment variables:

AWS_ACCESS_KEY_ID=<your username>
AWS_SECRET_ACCESS_KEY=<your password>
AWS_S3_ENDPOINT=http(s)://<host>:<port>
AWS_S3_NO_SSL=true # disables SSL
AWS_S3_FORCE_PATH_STYLE=true # enforce path style bucket access

Added bonus section

Copy files from S3 to Azure Blob Storage

skbn cp \
    --src s3://<bucket>/<path> \
    --dst abs://<account>/<container>/<path>

Copy files from Azure Blob Storage to S3

skbn cp \
    --src abs://<account>/<container>/<path> \
    --dst s3://<bucket>/<path>

Copy files from Kubernetes to Kubernetes

skbn cp \
    --src k8s://<namespace>/<podName>/<containerName>/<path> \
    --dst k8s://<namespace>/<podName>/<containerName>/<path>

Copy files from S3 to S3

skbn cp \
    --src s3://<bucket>/<path> \
    --dst s3://<bucket>/<path>

Copy files from Azure Blob Storage to Azure Blob Storage

skbn cp \
    --src abs://<account>/<container>/<path> \
    --dst abs://<account>/<container>/<path>

Credentials

Kubernetes

Skbn tries to get credentials in the following order:

  1. if KUBECONFIG environment variable is set - skbn will use the current context from that config file
  2. if ~/.kube/config exists - skbn will use the current context from that config file with an out-of-cluster client configuration
  3. if ~/.kube/config does not exist - skbn will assume it is working from inside a pod and will use an in-cluster client configuration

AWS

Skbn uses the default AWS credentials chain. In addition, the AWS_REGION environment variable should be set (default is eu-central-1).

Azure Blob Storage

Skbn uses AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables for authentication.

Examples

  1. In-cluster example
  2. Code example

skbn's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skbn's Issues

Compiling issue

I have forked the project under alexbarta/sbkn.
After installing dep prerequisites:

mkdir -p $GOPATH/src/github.com/alexbarta && cd $_
git clone https://github.com/alexbarta/skbn.git && cd skbn
make

But I get the following compilation fail:

# make
dep ensure
go fmt ./pkg/... ./cmd/...
go vet ./pkg/... ./cmd/...
# github.com/alexbarta/skbn/cmd [github.com/alexbarta/skbn/cmd.test]
cmd/skbn.go:55:23: too many arguments in call to skbn.Copy
        have (string, string, int, float64)
        want (string, string, int)

Instead compiling the original project nuvo/skbn works fine, no issue.

go modules

Could skbn please update to modern go mod to track the dependencies? This integrates better with newer Go projects.

Enable support for FIPS endpoints

I have a requirement to use FIPS endpoints for accessing S3 buckets as described here https://aws.amazon.com/compliance/fips/#FIPS_Endpoints_by_Service. However based on docs, I can either a) not see a way to enable this endpoint usage, or b) verify that the parameter AWS_S3_ENDPOINT has any effect on the endpoint used, and overall not verify that a FIPS endpoint is being used. I was wondering if this functionality already existed, and/or if it could be built in. Thanks in advance.

Replace make with mage

Can we please implement the build system with mage? mage provides stronger cross-platform guarantees, by parsing the build steps as pure Go code rather than sh/bat interpreted code.

https://magefile.org/

skbn installation failed in GKE

Hi All ,

I am trying to install skbn on Google GKE cluster and I am facing the below error. Can you please advise to move further. Please let me know if you need any further details. thanks.

$ make
dep ensure
/home/ganesan_mg/gopath:/google/gopath/src/github.com/nuvo/skbn is not within a known GOPATH/src
Makefile:46: recipe for target 'bootstrap' failed
make: *** [bootstrap] Error 1

$git rev-parse HEAD
f3f8aee

Backblaze B2

Hi, is there any interest in adding support for Backblaze B2 to skbn? I could probably tackle this in the next week or two if no one else wants to.

Avoid transfer of files through local memory

Currently skbn will download a file in its whole to memory, and upload it from memory.
This poses a problem when dealing with large files (larger than the memory resource limit).

Need to investigate if there is another way to go about transferring files without using local memory (or using a pre-determined memory).
Maybe we can stream it from source to destination in some way.

Help with permissions

I am trying to restore files from S3 to a Jenkins Helm instillation.

I have skbn installed locally and get the following error. I have tried running as an admin and the Jenkins service account we have in AWS.

error in Stream: Unauthorized dst: file: default/[pod-id]/jenkins-master/var/jenkins_home/jobs/admin/config.xml

I also setup the in-cluster from the examples and get the same error.

The path in Jenkins is owned by root

If I do not add the AWS secret and just use ~/.kube/config I get the following error:

2019/09/19 10:17:15 AccessDenied: Access Denied
	status code: 403, request id: 926596AA106D4016, host id: QgFAcBC8IHi2KgMjnYvz2uL7Ozx0[...]

What could I be missing in any of the solutions I have tried?

copy from s3 to k8s pod doesn't exit after completion

We have an issue whereby copying from an s3 bucket to a k8s pod the command never exits after copy is complete. Copy from k8s pod to s3 bucket works fine and the command exits after the files are copied.

Kubernetes 1.14
maorfr/skbn latest 26748c0240f8 7 months ago 50.2MB

command: ["skbn"]
       args:
       - cp
       - --src
       - s3://redacted/src/
       - --dst
       - k8s://redacted/dest/

Sadly there is no useful log output we could add to this ticket.

OMMkiller terminated backup process

I'm trying use cron job to copy files from kubernetes to S3 and in kubernetes and got pod error OMMKilled
Looks like it slowly increase virtual memory and reaching pod limits.

Container limits set to: cpu 3. Memory: 5Gb
amount of copy files: 3401311
changing buffer memory didn't help
Am i doing something wrong?
or its memory leak issue?

Looking for s3 sync functionality

Hello,

This tool is very good, but when i schedule it to take a backup of a certain pod, it recopies all the data and thats what is most time consuming, ideally if the data is same only the latest and the greatest should be copied like s3 sync. Can we have that capability, I am also open to contribute.

Let me know.

Local file support

Please make sure to support local files as sources and targets.

Unfortunately, Kubernetes file transfer can be quite slow. So copying files first from S3 to local disk, then local disk to Kubernetes, would often be more reliable. You can restart the file transfer without having to keep requesting the same data over and over from S3, which reduces overhead for every single file transferred.

If you must have a URI scheme, then use file://, e.g. file:///Users/andrew/Downloads/coolbeans.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.