<p>I am working on Kubernetes operator that automatically creates namespaces, labels, annotations... based on CRD.</p>
<p>I am stuck with specific openshift object <strong>ClusterResourceQuota</strong> (quota.openshift.io/v1) which is not exposed by fabric8io-kubernetes-client.</p>
<p>Is there any alternative to create such objects even if loaded from file... ?</p>

Kolo
<p>I'm from Fabric8 team. Fabric8 Kubernetes Client supports creating Custom objects in two ways:</p>
<ul>
<li>Typed API(requires Custom Resource Model(POJOs) to be provided)</li>
<li>Typeless API (handles Custom Resource as plain HashMaps)</li>
</ul>
<h1>Typed API:</h1>
<p>Assuming that you already have POJOs for <code>ClusterResourceQuota</code> and<code>ClusterResourceQuotaList</code>. You can create an instance of kubernetes client for that specific Custom resource like this and use it for your Custom Resource operations:</p>
<pre class="lang-java prettyprint-override"><code>try (KubernetesClient client = new DefaultKubernetesClient()) {
    // Create ClusterResourceQuota object
    ClusterResourceQuota clusterResourceQuota = getClusterResourceQuota();

    // ClusterResourceQuota Client
    MixedOperation&lt;ClusterResourceQuota, ClusterResourceQuotaList, DoneableClusterResourceQuota, Resource&lt;ClusterResourceQuota, DoneableClusterResourceQuota&gt;&gt; clusterResourceQuotaClient = null;
    CustomResourceDefinitionContext context = new CustomResourceDefinitionContext
            .Builder()
            .withGroup(&quot;quota.openshift.io&quot;)
            .withKind(&quot;ClusterResourceQuota&quot;)
            .withName(&quot;clusterresourcequota-crd&quot;)
            .withPlural(&quot;clusterresourcequotas&quot;)
            .withScope(&quot;Namespaced&quot;)
            .withVersion(&quot;v1&quot;)
            .build();

    // Initializing ClusterResourceQuota Client, POJOs to be provided
    clusterResourceQuotaClient = client.customResources(context, ClusterResourceQuota.class, ClusterResourceQuotaList.class, DoneableClusterResourceQuota.class);
    // Using ClusterResourceQuota Client to create ClusterResourceQuota resource
    clusterResourceQuotaClient.inNamespace(&quot;default&quot;).createOrReplace(clusterResourceQuota);
}
</code></pre>
<h1>Typeless API</h1>
<p>If you don't have POJOs, you can make use of Fabric8 Kubernetes Client's Raw API for dealing with Custom Resources. Here is how you would do it:</p>
<pre class="lang-java prettyprint-override"><code>try (KubernetesClient client = new DefaultKubernetesClient()) {
    // Create Custom Resource Context
    CustomResourceDefinitionContext context = new CustomResourceDefinitionContext
            .Builder()
            .withGroup(&quot;quota.openshift.io&quot;)
            .withKind(&quot;ClusterResourceQuota&quot;)
            .withName(&quot;clusterresourcequota-crd&quot;)
            .withPlural(&quot;clusterresourcequotas&quot;)
            .withScope(&quot;Namespaced&quot;)
            .withVersion(&quot;v1&quot;)
            .build();

    // Load from Yaml
    Map&lt;String, Object&gt; clusterResourceQuota = client.customResource(context)
            .load(CustomResourceCreateDemoTypeless.class.getResourceAsStream(&quot;/clusterquota-cr.yml&quot;));
    // Create Custom Resource
    client.customResource(context).create(&quot;default&quot;, clusterResourceQuota);
} catch (IOException e) {
    e.printStackTrace();
}
</code></pre>
<p>You can also have a look at these blogs for <a href="https://medium.com/@rohaan/handling-kubernetes-custom-resources-in-java-using-fabric8-kubernetes-client-part-2-typed-cc0560d9af0d" rel="nofollow noreferrer">typed</a> and <a href="https://medium.com/@rohaan/handling-kubernetes-custom-resources-in-java-using-fabric8-kubernetes-client-249c4fe01d27" rel="nofollow noreferrer">typeless</a> approaches in detail.</p>
