# Can create Kongingress by k8s CRD api

**URL:** <https://discuss.konghq.com/t/can-create-kongingress-by-k8s-crd-api/7365>\
**Category:** Questions\
**Tags:** kubernetes\
**Created:** [October 28, 2020, 9:24am UTC](https://discuss.konghq.com/t/can-create-kongingress-by-k8s-crd-api/7365 "2020-10-28T09:24:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![qing369](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/qing369/32/2328_2.png) [@qing369](https://discuss.konghq.com/u/qing369)\
**Post date:** [October 28, 2020, 9:24am UTC](https://discuss.konghq.com/t/can-create-kongingress-by-k8s-crd-api/7365/1 "2020-10-28T09:24:22Z")

</div>

In my case ,i want use java api to create kongingress ,find a lot of things , i got k8s provide crd module to get&create crd.  
I use CustomObjectsApi.listClusterCustomObject get kongingress config ,but when i use CustomObjectsApi.createClusterCustomObject api, k8s return 404 not found ;  
Is my code wrong or is need setting some config

* * *

get kongingress code :  
CustomObjectsApi apiInstance = new CustomObjectsApi();  
String group = “[configuration.konghq.com](http://configuration.konghq.com)”;  
String version = “v1”;  
String plural = “kongingresses”;  
String pretty = “ture”;  
String fieldSelector = “metadata.namespace=” + buId;  
try {  
Object result = apiInstance.listClusterCustomObject(group, version, plural, null,  
null, fieldSelector, null, null,  
null, null, null);  
String listCluster = JSONObject.toJSONString(result);  
log.error(listCluster);  
JSONObject jsonObject = JSONObject.parseObject(listCluster);  
if (null == jsonObject.getJSONArray(“items”) || jsonObject.getJSONArray(“items”).isEmpty()) {  
return false;  
} else {  
return true;  
}  
} catch (Exception e) {  
log.error(“Get KongIngress error,” + buId, e);  
throw new RuntimeException(“Get KongIngress error,” + buId, e);  
}

return message：  
{“apiVersion”:“[configuration.konghq.com/v1",“items”:[],“kind”:“KongIngressList”,“metadata”:{“continue”:“”,“resourceVersion”:“694409337”,“selfLink”:"/apis/configuration.konghq.com/v1/kongingresses](http://configuration.konghq.com/v1%22,%22items%22:%5B%5D,%22kind%22:%22KongIngressList%22,%22metadata%22:%7B%22continue%22:%22%22,%22resourceVersion%22:%22694409337%22,%22selfLink%22:%22/apis/configuration.konghq.com/v1/kongingresses)”}}

* * *

create kongingress code :  
CustomObjectsApi apiInstance = new CustomObjectsApi();  
String group = “[configuration.konghq.com](http://configuration.konghq.com)”;  
String version = “v1”;  
String plural = “kongingresses”;  
Object createRs = apiInstance.createClusterCustomObject(group, version, plural, ingressYaml, null, null,  
null);

ingressYaml like：  
apiVersion: [configuration.konghq.com/v1](http://configuration.konghq.com/v1)  
kind: KongIngress  
metadata:  
name: https-only  
namespace: testbu001  
route:  
protocols:

- https  
https\_redirect\_status\_code: 302

error message：  
io.kubernetes.client.openapi.ApiException: Not Found  
at io.kubernetes.client.openapi.ApiClient.handleResponse(ApiClient.java:971)  
at io.kubernetes.client.openapi.ApiClient.execute(ApiClient.java:883)  
at io.kubernetes.client.openapi.apis.CustomObjectsApi.createClusterCustomObjectWithHttpInfo(CustomObjectsApi.java:263)  
at io.kubernetes.client.openapi.apis.CustomObjectsApi.createClusterCustomObject(CustomObjectsApi.java:218)

---

<div class="post-metadata">

**Author:** ![traines](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/traines/32/158_2.png) [@traines](https://discuss.konghq.com/u/traines)\
**Post date:** [October 30, 2020, 12:46am UTC](https://discuss.konghq.com/t/can-create-kongingress-by-k8s-crd-api/7365/2 "2020-10-30T00:46:31Z")

</div>

We unfortunately aren’t able to help you write a Java application to do this or assist with using the Kubernetes client libraries, but in general, yes, this should be possible: if you’ve installed our CRDs into your cluster, a Kubernetes API client issuing a well-formed request to the API server should be able to create a KongIngress resource.

That “Not Found” error likely indicates that you either haven’t actually installed the KongIngress CRD (and the API server doesn’t recognize attempts to create those resources) or that the client’s API server location setting isn’t correct (it’s sending an HTTP request to some other HTTP server, which doesn’t recognize the Kubernetes API routes and returns a 404).
