4 releases (breaking)

0.4.0 Sep 30, 2024
0.3.0 Sep 29, 2024
0.2.0 Jul 17, 2024
0.1.0 Jul 16, 2024

#1937 in Network programming

Download history 51/week @ 2024-07-25 21/week @ 2024-08-01 29/week @ 2024-08-08 33/week @ 2024-08-15 40/week @ 2024-08-22 86/week @ 2024-08-29 16/week @ 2024-09-05 38/week @ 2024-09-12 39/week @ 2024-09-19 440/week @ 2024-09-26 309/week @ 2024-10-03 178/week @ 2024-10-10 145/week @ 2024-10-17 67/week @ 2024-10-24 30/week @ 2024-10-31 49/week @ 2024-11-07

316 downloads per month
Used in termscp

MIT license

140KB
3K SLoC

remotefs-kube

Documentation

~ Remotefs kube client ~

Developed by @veeso

Current version: 0.4.0 (29/09/2024)

License-MIT Repo stars Downloads counter Latest version Ko-fi


About remotefs-kube ☁️

remotefs client implementation for Kube.

Get started

First of all you need to add remotefs and the client to your project dependencies:

remotefs = "^0.3"
remotefs-kube = "^0.4"

these features are supported:

  • find: enable find() method for RemoteFs. (enabled by default)
  • no-log: disable logging. By default, this library will log via the log crate.

The library provides two different clients:

  • KubeMultiPodFs client
  • KubeContainerFs client

Kube multi pod client

The MultiPod client gives access to all the pods with their own containers in a namespace.

This client creates an abstract file system with the following structure

  • / (root)
    • pod-a
      • container-a
        • / (container-a root)
          • /bin
          • /home
          • ...
      • container-b
        • / (container-b root)
          • ...
    • pod-b
      • container-c
        • / (container-c root)
          • ...

So paths have the following structure: /pod-name/container-name/path/to/file.


// import remotefs trait and client
use remotefs::RemoteFs;
use remotefs_kube::KubeMultiPodFs;
use std::path::Path;

let rt = Arc::new(
    tokio::runtime::Builder::new_current_thread()
    .enable_all()
    .build()
    .unwrap(),
);
let mut client: KubeMultiPodFs = KubeMultiPodFs::new(&rt);

// connect
assert!(client.connect().is_ok());
// get working directory
println!("Wrkdir: {}", client.pwd().ok().unwrap().display());
// change working directory
assert!(client.change_dir(Path::new("/my-pod/alpine/tmp")).is_ok());
// disconnect
assert!(client.disconnect().is_ok());

Kube container client

Here is a basic usage example, with the KubeContainerFs client, which is used to connect and interact with a single container on a certain pod. This client gives the entire access to the container file system.


// import remotefs trait and client
use remotefs::RemoteFs;
use remotefs_kube::KubeContainerFs;
use std::path::Path;

let rt = Arc::new(
    tokio::runtime::Builder::new_current_thread()
    .enable_all()
    .build()
    .unwrap(),
);
let mut client: KubeContainerFs = KubeContainerFs::new("my-pod", "container-name", &rt);

// connect
assert!(client.connect().is_ok());
// get working directory
println!("Wrkdir: {}", client.pwd().ok().unwrap().display());
// change working directory
assert!(client.change_dir(Path::new("/tmp")).is_ok());
// disconnect
assert!(client.disconnect().is_ok());

Client compatibility table ✔️

The following table states the compatibility for the client client and the remote file system trait method.

Note: connect(), disconnect() and is_connected() MUST always be supported, and are so omitted in the table.

Client/Method Kube
append_file No
append No
change_dir Yes
copy Yes
create_dir Yes
create_file Yes
create No
exec Yes
exists Yes
list_dir Yes
mov Yes
open_file Yes
open No
pwd Yes
remove_dir_all Yes
remove_dir Yes
remove_file Yes
setstat Yes
stat Yes
symlink Yes


Changelog ⏳

View remotefs-kube's changelog HERE


License 📃

remotefs-kube is licensed under the MIT license.

You can read the entire license HERE

Dependencies

~60MB
~1M SLoC