Giter Club home page Giter Club logo

Comments (3)

q2w avatar q2w commented on August 15, 2024

I did it using kubernetes java-client itself.

from fabric8.

ArundathiGV avatar ArundathiGV commented on August 15, 2024

@q2w
Hi,
I am using io.fabric8:kubernetes-client:3.2.0. I am facing the same issue of null pointer exception. The below yaml, i am deploying.

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: cluster-admin-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:

  • kind: ServiceAccount
    name: test
    namespace: test

Can you please explain how you did it using kubernetes java-client?

Thanks,

from fabric8.

q2w avatar q2w commented on August 15, 2024

@ArundathiGV
Sure.
First you need to create an object V1beta1ClusterRoleBinding (present in kubernetes java-client) and then submit to kubernetes master.

Like for this case....

    V1beta1ClusterRoleBinding v1beta1ClusterRoleBinding = new V1beta1ClusterRoleBinding();
    v1beta1ClusterRoleBinding.setApiVersion("rbac.authorization.k8s.io/v1beta1");
    v1beta1ClusterRoleBinding.setKind("ClusterRoleBinding");
    V1ObjectMeta v1ObjectMeta = new V1ObjectMeta();
    v1ObjectMeta.setName("cluster-admin-binding");
    v1beta1ClusterRoleBinding.setMetadata(v1ObjectMeta);
    V1beta1RoleRef v1beta1RoleRef = new V1beta1RoleRef();
    v1beta1RoleRef.setApiGroup("rbac.authorization.k8s.io");
    v1beta1RoleRef.setKind("ClusterRole");
    v1beta1RoleRef.setName("cluster-admin");
    v1beta1ClusterRoleBinding.setRoleRef(v1beta1RoleRef);
    V1beta1Subject v1beta1Subject = new V1beta1Subject();
    v1beta1Subject.setName("test");
    v1beta1Subject.setKind("ServiceAccount");
    v1beta1Subject.setNamespace("test");
    List<V1beta1Subject> list = new ArrayList<>();
    list.add(v1beta1Subject);
    v1beta1ClusterRoleBinding.setSubjects(list);

try {
rbacAuthorizationV1beta1Api.createClusterRoleBinding(v1beta1ClusterRoleBinding,
"true");
} catch (ApiException e) {
e.printStackTrace();
}

from fabric8.

Related Issues (20)

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.