Git Product home page Git Product logo

kubernetes-rust's Introduction

Github linkedin speakerdeck twitter

github-stats

kubernetes-rust's People

Contributors

atul9 avatar clux avatar svend avatar ynqa 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

kubernetes-rust's Issues

dealing with CRDs?

The API for CRDs is generated by kube as soon as the CRD is posted. Thus these structs are not normally available in the openapi bindings or something else (the crd might not even have a schema in older versions of kube). This is usually not a problem, because if you're using rust, you might have a more precise struct for this anyway, but it would be nice to have an API wrapper for this call somehow maybe?

The go toolchain does some awkward codegeneration that they force people to do more-or-less manually, but that shouldn't be necessary when you have serde and rust on your side. Still, not sure what's the best way to tackle this.

Currently, am just calling the api the easy way:
https://github.com/Babylonpartners/shipcat/blob/8e1fd9c1e0bfef1a9f642f9d7d64b1b938f00ae2/raftcat/src/kube.rs#L13-L19
(and thus avoiding the openapi bindings entirely because that's all i need atm)
but wondered if you/someone had thoughts on this.

The certificate was not trusted.

Running the example code:

#[test]
fn test_general() {
    let kubeconfig = config::load_kube_config().expect("failed to load kubeconfig");
    let kubeclient = APIClient::new(kubeconfig);
    let (req, _) = api::Pod::list_namespaced_pod("kube-system", Default::default())
        .expect("failed to create a request");
    let list_pod = kubeclient
        .request::<api::PodList>(req)
        .expect("failed to list up pods");
    println!("{:?}", list_pod);
}
---- test::test_general stdout ----
thread 'test::test_general' panicked at 'failed to list up pods: Error(Hyper(Error(Connect, Custom { kind: Other, error: Error { code: -67843, message: "The certificate was not trusted." } })), "https://<uuid>.k8s.ondigitalocean.com/api/v1/namespaces/kube-system/pods?")', src/main.rs:76:24


failures:
    test::test_general

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

reading chunked values from watch requests

Watch API returns non-json as json:

GET /api/v1/namespaces/test/pods?watch=1&resourceVersion=10245
---
200 OK
Transfer-Encoding: chunked
Content-Type: application/json
{
  "type": "ADDED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "10596", ...}, ...}
}
{
  "type": "MODIFIED",
  "object": {"kind": "Pod", "apiVersion": "v1", "metadata": {"resourceVersion": "11020", ...}, ...}
}

Maybe it's possible to parse each chunk as json? Maybe this needs a custom deserializer?
Just making a note of this. Not sure how to parse this yet.

error handling when kube returns an error struct missing

One thing I noticed is that data returned from the kube api is assumed to be parseable into the struct you give it:

req.send()?.json().map_err(Error::from)

however, we have no real information on what went wrong if kube returns an error struct. We simply get a json parsing failed (usually "unexpected EOF" via serde) because the string is attempted to be coerced into a different struct to the one that contains the error.

This happens if you query for information about your own custom resources and you've failed to add the necessary rbac rules for it, but i'm sure there are many other cases.

There's currently got a fork to help me deal with this issue in my account (and to get some debug back when it's failed for now). I might be looking to submit a pr back if I stumble across a good solution to it. In the mean time, just thought this ought to be raised.

At any rate, thanks for this crate! It's allowed me to write a kube app with rust with only minor tweaks!

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.