Java Code Examples for io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionList#getItems()
The following examples show how to use
io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionList#getItems() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IstioExecutor.java From istio-apim with Apache License 2.0 | 6 votes |
/** * Setting up custom resources */ public void setupCRDs() { CustomResourceDefinitionList crds = client.customResourceDefinitions().list(); List<CustomResourceDefinition> crdsItems = crds.getItems(); for (CustomResourceDefinition crd : crdsItems) { ObjectMeta metadata = crd.getMetadata(); if (metadata != null) { String name = metadata.getName(); if (RULE_CRD_NAME.equals(name)) { ruleCRD = crd; } else if (HTTPAPISpec_CRD_NAME.equals(name)) { httpAPISpecCRD = crd; } else if (HTTPAPISpecBinding_CRD_NAME.equals(name)) { httpAPISpecBindingCRD = crd; } } } }
Example 2
Source File: CustomResourceTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testListWithFields() { final CustomResourceDefinitionList customResourceDefinitionList = new CustomResourceDefinitionListBuilder() .addNewItem().and() .addNewItem().and() .build(); server.expect().get().withPath("/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions?fieldSelector=" + Utils .toUrlEncoded("key1=value1,key2=value2,key3!=value3,key3!=value4")).andReturn(HttpURLConnection.HTTP_CREATED, customResourceDefinitionList).once(); KubernetesClient client = server.getClient(); CustomResourceDefinitionList list = client.customResourceDefinitions() .withField("key1", "value1") .withField("key2","value2") .withoutField("key3","value3") .withoutField("key3", "value4") .list(); List<CustomResourceDefinition> items = list.getItems(); assertNotNull(items); assertEquals(2, items.size()); }
Example 3
Source File: ListCustomResourceDefinitions.java From kubernetes-client with Apache License 2.0 | 6 votes |
public static void main(String[] args) { try { KubernetesClient client = new DefaultKubernetesClient(); if (!client.supportsApiPath("/apis/apiextensions.k8s.io/v1beta1") && !client.supportsApiPath("/apis/apiextensions.k8s.io/v1")) { System.out.println("WARNING this cluster does not support the API Group apiextensions.k8s.io"); return; } CustomResourceDefinitionList list = client.customResourceDefinitions().list(); if (list == null) { System.out.println("ERROR no list returned!"); return; } List<CustomResourceDefinition> items = list.getItems(); for (CustomResourceDefinition item : items) { System.out.println("CustomResourceDefinition " + item.getMetadata().getName() + " has version: " + item.getApiVersion()); } } catch (KubernetesClientException e) { System.out.println("Failed: " + e); e.printStackTrace(); } }
Example 4
Source File: AppsOperator.java From jhipster-operator with Apache License 2.0 | 4 votes |
private boolean areRequiredCRDsPresent() { try { appService.registerCustomResourcesForRuntime(); CustomResourceDefinitionList crds = k8SCoreRuntime.getCustomResourceDefinitionList(); for (CustomResourceDefinition crd : crds.getItems()) { ObjectMeta metadata = crd.getMetadata(); if (metadata != null) { String name = metadata.getName(); if (AppCRDs.MICROSERVICE_CRD_NAME.equals(name)) { microServiceCRD = crd; } if (AppCRDs.GATEWAY_CRD_NAME.equals(name)) { gatewayCRD = crd; } if (AppCRDs.REGISTRY_CRD_NAME.equals(name)) { registryCRD = crd; } if (AppCRDs.APP_CRD_NAME.equals(name)) { applicationCRD = crd; } } } if (allCRDsFound()) { logger.info("\t > App CRD: " + applicationCRD.getMetadata().getName()); logger.info("\t > MicroService CRD: " + microServiceCRD.getMetadata().getName()); logger.info("\t > Registry CRD: " + registryCRD.getMetadata().getName()); logger.info("\t > Gateway CRD: " + gatewayCRD.getMetadata().getName()); return true; } else { logger.error("> Custom CRDs required to work not found please check your installation!"); logger.error("\t > App CRD: " + ((applicationCRD == null) ? " NOT FOUND " : applicationCRD.getMetadata().getName())); logger.error("\t > MicroService CRD: " + ((microServiceCRD == null) ? " NOT FOUND " : microServiceCRD.getMetadata().getName())); logger.error("\t > Registry CRD: " + ((registryCRD == null) ? " NOT FOUND " : registryCRD.getMetadata().getName())); logger.error("\t > Gateway CRD: " + ((gatewayCRD == null) ? " NOT FOUND " : gatewayCRD.getMetadata().getName())); return false; } } catch (Exception e) { e.printStackTrace(); logger.error("> Init sequence not done"); } return false; }
Example 5
Source File: K8sManager.java From carbon-apimgt with Apache License 2.0 | 4 votes |
/** * Deploys the API Custom resource kind in kubernetes * * @param client , Openshift client * @param configmapNames , Name of the configmap * @param replicas , number of replicas * @param apiIdentifier , APIIdentifier * @param override , Checks whether the API CR needs to be overrode or not */ private void applyAPICustomResourceDefinition(OpenShiftClient client, String[] configmapNames, int replicas, APIIdentifier apiIdentifier, Boolean override) { CustomResourceDefinitionList customResourceDefinitionList = client.customResourceDefinitions().list(); List<CustomResourceDefinition> customResourceDefinitionItems = customResourceDefinitionList.getItems(); CustomResourceDefinition apiCustomResourceDefinition = null; for (CustomResourceDefinition crd : customResourceDefinitionItems) { ObjectMeta metadata = crd.getMetadata(); if (metadata != null && metadata.getName().equals(API_CRD_NAME)) { apiCustomResourceDefinition = crd; } } if (apiCustomResourceDefinition != null) { log.info("Found [CRD] " + apiCustomResourceDefinition.getMetadata().getSelfLink()); } else { log.error("Custom resource definition apis.wso2.com was not found in the specified cluster"); return; } NonNamespaceOperation<APICustomResourceDefinition, APICustomResourceDefinitionList, DoneableAPICustomResourceDefinition, Resource<APICustomResourceDefinition, DoneableAPICustomResourceDefinition>> apiCrdClient = getCRDClient(client, apiCustomResourceDefinition); // assigning values and creating API cr Definition definition = new Definition(); Interceptors interceptors = new Interceptors(); interceptors.setBallerina(new String[]{}); interceptors.setJava(new String[]{}); definition.setType(SWAGGER); definition.setSwaggerConfigmapNames(configmapNames); definition.setInterceptors(interceptors); APICustomResourceDefinitionSpec apiCustomResourceDefinitionSpec = new APICustomResourceDefinitionSpec(); apiCustomResourceDefinitionSpec.setDefinition(definition); apiCustomResourceDefinitionSpec.setMode(MODE); apiCustomResourceDefinitionSpec.setReplicas(replicas); apiCustomResourceDefinitionSpec.setOverride(override); apiCustomResourceDefinitionSpec.setUpdateTimeStamp(""); Status status = new Status(); APICustomResourceDefinition apiCustomResourceDef = new APICustomResourceDefinition(); apiCustomResourceDef.setSpec(apiCustomResourceDefinitionSpec); apiCustomResourceDef.setStatus(status); apiCustomResourceDef.setApiVersion(API_VERSION); apiCustomResourceDef.setKind(CRD_KIND); ObjectMeta meta = new ObjectMeta(); meta.setName(apiIdentifier.getApiName().toLowerCase()); meta.setNamespace(client.getNamespace()); apiCustomResourceDef.setMetadata(meta); apiCrdClient.createOrReplace(apiCustomResourceDef); log.info("Created [API-CR] apis.wso2.com/" + apiCustomResourceDef.getMetadata().getName() + " for the " + "[API] " + apiIdentifier.getApiName()); }