Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource Not Found error when trying to create a clusterrolebinding #476

Closed
empath-75 opened this issue Mar 26, 2021 · 2 comments
Closed
Labels
api Api abstraction related question Direction unclear; possibly a bug, possibly could be improved.

Comments

@empath-75
Copy link

empath-75 commented Mar 26, 2021

let crbs: Api<ClusterRoleBinding> = Api::namespaced(client, namespace);
let crb = serde_json::from_value(serde_json::json!({
        "apiVersion": "rbac.authorization.k8s.io/v1",
        "kind": "ClusterRoleBinding",
        "metadata": {           
            "name": "foo",

        },
        "roleRef": {
            "apiGroup": "rbac.authorization.k8s.io",
            "kind": "ClusterRole",
            "name": "system:auth-delegator"
        },
        "subjects": [
            {
                "kind": "ServiceAccount",
                "name": "bar",
                "namespace": "default"
            }
        ]
    }))?;
let crb = crbs.create(&PostParams::default(), &crb).await?;

I have the correct client version (1.18) set in features. I've tried with both k8s_openapi::api::rbac::v1::{ClusterRoleBinding};
and v1beta1.

I've been able to create other resources (secrets and service accounts). I've also been able to create the same clusterrolebinding from the command line.

I'd like to be able to have it output exactly what the post request is so I can troubleshoot further, but I don't see any way to do that.

@empath-75
Copy link
Author

I needed to change let crbs: Api<ClusterRoleBinding> = Api::namespaced(client, namespace);
to let crbs: Api<ClusterRoleBinding> = Api::all(client);

@clux
Copy link
Member

clux commented Mar 26, 2021

Ah, yeah, that's a Cluster scoped resource. Unfortunately you just have to pick the right Api constructor since there's no way for us to know what type of scope the resource has atm #194.

In the future, you can turn up kube's logging to debug and you'll see api calls logged:

GET https://0.0.0.0:6443/api/v1/services? Body(Empty) 

@clux clux added api Api abstraction related question Direction unclear; possibly a bug, possibly could be improved. labels Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Api abstraction related question Direction unclear; possibly a bug, possibly could be improved.
Projects
None yet
Development

No branches or pull requests

2 participants