GithubHelp home page GithubHelp logo

opencredo / kubefuse Goto Github PK

View Code? Open in Web Editor NEW
265.0 15.0 16.0 83 KB

Kubernetes as a FUSE Filesystem

Home Page: https://opencredo.com/blogs/introducing-kubefuse-file-system-kubernetes/

License: Apache License 2.0

Python 95.75% Makefile 1.03% Shell 3.22%
blog-article

kubefuse's Introduction

KubeFuse

KubeFuse

Kubernetes as a Filesystem Build Status

Why?

Because kubectl is great, but sometimes a bit slow to navigate.

Enter KubeFuse.

Beta quality software for quick Kubernetes browsing and editing. What's not to love.

Features

  • Browse Kubernetes resources in your file system...
  • ...with (some of) your favourite tools: ls, find, cat, vim, ...
  • List all your favourite resources such as: services, replication controllers, pods and namespaces. All entity types up to v1.3 are supported.
  • Access resource descriptions as files (eg. cat ~/kubernetes/default/pod/postgres-aazm1/describe)
  • Quickly read resources as YAML or JSON (eg. cat ~/kubernetes/default/pod/postgres-aazm1/json)
  • Edit resources with your editor of choice and have Kubernetes update on writes (vim ~/kubernetes/default/rc/postgres/json ๐Ÿ™‹)
  • Works with Python 2 and 3

A more detailed introductory post can be found on this beautiful blog.

Requirements

KubeFuse runs on both Linux and Mac, but does require additional libraries to be installed (eg. OSXFUSE).

KubeFuse also uses the kubectl binary under the hood so this needs to be on the path.

Setup and Usage

Getting the latest release

You should be able to:

pip install kubefuse

After which the kubefuse command will be installed into a bin/ directory that is hopefully already on your path (if not look for the line starting with Installing kubefuse script to .... and add that directory to your PATH and restart your shell).

You should then be able to run:

kubefuse [MOUNTPOINT]

From Source

When "building" from source:

pip install -r requirements.txt

Will install all the dependencies (on fresh systems you may need to easy_install pip first). After which you can run KubeFuse with:

python kubefuse/kubefuse.py [MOUNTPOINT] 

Tests

KubeFuse is extensively tested using a tool called Myna. It also uses the nose framework to discover and orchestrate the tests. To run the tests install Myna and then:

make test

Examples

Create the mount:

python kubefuse.py ~/kubernetes

List all pods in the default namespace:

ls ~/kubernetes/default/pod/

List all known objects in the default namespace:

find ~/kubernetes/default -type d -mindepth 2

Describe the postgres pod:

cat ~/kubernetes/default/pod/postgres-aazm1/describe

Get logs from a graphite pod:

cat ~/kubernetes/default/pod/graphite-i3bb2/logs

Export the postgres replication controller to YAML:

cat ~/kubernetes/default/rc/postgres/yaml

Export the postgres replication controller to JSON:

cat ~/kubernetes/default/rc/postgres/json

Export all service definitions in the default namespace:

find ~/kubernetes/default/svc -name yaml | while read line ; do cat $line ; echo "----" ; echo ; done

We can edit replication controllers and other resources in our editor. Saving the file will replace the resource in kubernetes:

vim ~/kubernetes/default/rc/postgres/json

License

Apache License version 2.0 See LICENSE for details.

(c) OpenCredo 2016.

kubefuse's People

Contributors

benmathews avatar bspaans avatar mboersma avatar pnovotnak avatar

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  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  avatar  avatar  avatar  avatar  avatar

kubefuse's Issues

Cached YAML returned after successful edit of JSON

Steps to reproduce:

  • mount a kubefuse filesystem
  • look at the YAML version of an object in kubefuse: cat ~/k8s/default/rc/my-controller.yaml
  • edit an object, e.g.: vi ~/k8s/default/rc/my-controller/json, and save a trivial change such as an annotation
  • verify that the change was made in Kubernetes: kubectl get rc my-controller -o json and inspect the output
  • verify that kubefuse shows the change: cat ~/k8s/default/rc/my-controller.json
  • note that the YAML version of the same object is stale: cat ~/k8s/default/rc/my-controller.yaml

Caching doesn't seem to be that long-lived, so soon the YAML version will update. But maybe kubefuse should invalidate all the caching at that level after a successful kubectl edit?

Install fails with missing dependency on fusepy

$ pip install kubefuse
Collecting kubefuse
  Downloading kubefuse-0.5.1.tar.gz
Building wheels for collected packages: kubefuse
  Running setup.py bdist_wheel for kubefuse ... done
  Stored in directory: /home/ben_mathews/.cache/pip/wheels/fd/52/d0/f23760eacb117fe75c496580e699f661df80e229c67ebfb2ad
Successfully built kubefuse
Installing collected packages: kubefuse
Successfully installed kubefuse-0.5.1
$ kubefuse ~/k8s
Traceback (most recent call last):
  File "/home/ben_mathews/workspace/Platform/MY_ENV/bin/kubefuse", line 7, in <module>
    from kubefuse.kubefuse import main
  File "/home/ben_mathews/workspace/Platform/MY_ENV/local/lib/python2.7/site-packages/kubefuse/kubefuse.py", line 7, in <module>
    from fuse import FUSE, FuseOSError, Operations, LoggingMixIn
ImportError: No module named fuse

Works after pip install fusepy.

Execution fails on mac

  • macOS Sierra 10.12.6
  • Python 3.6.4

install looks ok

$ pip3 install kubefuse
Collecting kubefuse
  Downloading kubefuse-0.7.3.tar.gz
Requirement already satisfied: fusepy>=2.0.4 in /usr/local/lib/python3.6/site-packages (from kubefuse)
Collecting python-myna==1.2.0 (from kubefuse)
  Downloading python-myna-1.2.0.tar.gz
Requirement already satisfied: PyYAML>=3 in /usr/local/lib/python3.6/site-packages (from kubefuse)
Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.6/site-packages (from kubefuse)
Building wheels for collected packages: kubefuse, python-myna
  Running setup.py bdist_wheel for kubefuse ... done
  Stored in directory: /Users/my-user/Library/Caches/pip/wheels/92/18/07/49c7dbbc561c8ac4e366befec2af409f53765662ae4d4081bc
  Running setup.py bdist_wheel for python-myna ... done
  Stored in directory: /Users/my-user/Library/Caches/pip/wheels/d3/f5/6f/fd9f2b7ffc199ec6363b413a4a14e7dca1d4766ea42565b8a3
Successfully built kubefuse python-myna
Installing collected packages: python-myna, kubefuse
Successfully installed kubefuse-0.7.3 python-myna-1.2.0

running it not so

$ kubefuse
Traceback (most recent call last):
  File "/usr/local/bin/kubefuse", line 7, in <module>
    from kubefuse.kubefuse import main
  File "/usr/local/lib/python3.6/site-packages/kubefuse/kubefuse.py", line 13
    print "It looks like the Fuse system library is missing."
                                                            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(int "It looks like the Fuse system library is missing.")?

Requirements are not installed & missing pyyaml

When installing with pip, fusepy etc do not get installed. After manually installing them I was still missing pyyaml.
I'm on os x, just did a clean install of python 2.7 from homebrew. Also update to the latest pip version.

Enhance list of entities

The list of entities has expanded in 1.3, would be good to add the missing entities to path.py
Some of these don't support 'describe', it throws tracebacks when kubectl returns "no describe implemented" errors.

   * componentstatuses (aka 'cs')
   * configmaps
   * daemonsets (aka 'ds')
   * deployments
   * events (aka 'ev')
   * endpoints (aka 'ep')
   * horizontalpodautoscalers (aka 'hpa')
   * ingress (aka 'ing')
   * jobs
   * limitranges (aka 'limits')
   * nodes (aka 'no')
   * namespaces (aka 'ns')
   * pods (aka 'po')
   * persistentvolumes (aka 'pv')
   * persistentvolumeclaims (aka 'pvc')
   * quota
   * resourcequotas (aka 'quota')
   * replicasets (aka 'rs')
   * replicationcontrollers (aka 'rc')
   * secrets
   * serviceaccounts (aka 'sa')
   * services (aka 'svc')

installation requirments

On Ubuntu 16.04 I tried pip install --user kubefuse and running it fails with:

~> kubefuse kubefuse
Traceback (most recent call last):
  File "/home/salvus/.local/bin/kubefuse", line 7, in <module>
    from kubefuse.kubefuse import main
  File "/home/salvus/.local/lib/python2.7/site-packages/kubefuse/kubefuse.py", line 7, in <module>
    from fuse import FUSE, FuseOSError, Operations, LoggingMixIn
ImportError: cannot import name FUSE

due to the built in system-wide fuse module being older (?).

I then did pip install --user fusepy and got past the above, then hit a problem with missing yaml. I then did pip install --user yaml, at which point everything worked fine.

(... and this project really awesome!)

Support for Python 3

Installed kubefuse-0.7.3 in a python 3 virtualenv. It threw:

print "It looks like the Fuse system library is missing."

Looks like it's using python 2 style prints.

Show correct file sizes

At the moment all files are listed with a size of 50000 bytes. This is a dirty hack and should be resolved. 0 size files broke a lot of tools on my mac unfortunately and I haven't found a way around that so the only thing I can think of at this point is to actually go and fetch the resources to calculate the size correctly.

This is a bit expensive because it has to run the kubectl behind the scenes for each file, but we can cache the results for a little while to alleviate this.

Make sed work

Modifying a file with sed doesn't work. Either in place or using redirection:

sed -e 's/  replicas: 1/  replicas: 2/g' testmount/default/rc/postgres/yaml > testmount/default/rc/postgres/yaml

I have a feeling that instead of truncating the file and overwriting it sed tries to create a new file and move it in its place. Haven't looked into this though, but it would be nice to get this working.

Note that Python 3 is not supported

I tried to run kubefuse with Python 3, but ran into "print without parentheses" errors right away. Python 2 works great. The README should mention this requirement.

Implement unlink

By popular request. This whole project is useless if we can't rm -rf the whole thing.

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.