Expand description
§remotefs-kube
remotefs-kube is a client implementation for remotefs, providing support for the Kube API protocol.
§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
: enablefind()
method for RemoteFs. (enabled by default)no-log
: disable logging. By default, this library will log via thelog
crate.
§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-a root)
- container-b
- / (container-b root)
- …
- / (container-b root)
- container-a
- pod-b
- container-c
- / (container-c root)
- …
- / (container-c root)
- container-c
- pod-a
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());
Structs§
- Configuration object detailing things like cluster URL, default namespace, root certificates, and timeouts.
- Kube “filesystem” client to interact with a container in a pod
- Kube MultiPod FS