public IstioResource registerCustomResource(final IstioResource resource) { return (IstioResource)resource(resource).createOrReplace(); }
public Boolean unregisterCustomResource(final IstioResource istioResource) { return resource(istioResource).delete(); } }
/*** * Wait until pod ready * @param pod * @throws Exception */ public void waitUntilPodIsReady(Pod pod) throws InterruptedException { log.info("Waiting until pod: {} is ready", pod.getMetadata().getName()); client.resource(pod).inNamespace(globalNamespace).waitUntilReady(5, TimeUnit.MINUTES); }
private static void cleanupItem(KubernetesClient client, Session session, HasMetadata item, List<Throwable> errors) { String sessionNamespace = session.getNamespace(); KubernetesHelper.getOrCreateMetadata(item).setNamespace(sessionNamespace); client.resource(item).inNamespace(sessionNamespace).cascading(true).delete(); }
public IstioResource registerOrUpdateCustomResource(final IstioResource resource) { return (IstioResource)resource(resource).createOrReplace(); }
public static void deleteEntities(KubernetesClient kubernetes, String namespace, Set<HasMetadata> entities, String s2iBuildNameSuffix, Logger log) { List<HasMetadata> list = new ArrayList<>(entities); // For OpenShift cluster, also delete s2i buildconfig OpenShiftClient openshiftClient = OpenshiftHelper.asOpenShiftClient(kubernetes); if (openshiftClient != null) { for (HasMetadata entity : list) { if ("ImageStream".equals(KubernetesHelper.getKind(entity))) { ImageName imageName = new ImageName(entity.getMetadata().getName()); String buildName = getS2IBuildName(imageName, s2iBuildNameSuffix); log.info("Deleting resource BuildConfig " + namespace + "/" + buildName); openshiftClient.buildConfigs().inNamespace(namespace).withName(buildName).delete(); } } } // lets delete in reverse order Collections.reverse(list); for (HasMetadata entity : list) { log.info("Deleting resource " + KubernetesHelper.getKind(entity) + " " + namespace + "/" + KubernetesHelper.getName(entity)); kubernetes.resource(entity).inNamespace(namespace).cascading(true).delete(); } }
public Boolean unregisterCustomResource(final IstioResource istioResource) { return resource(istioResource).delete(); } }
public IstioResource registerCustomResource(final IstioResource resource) { return (IstioResource)resource(resource).createOrReplace(); }
public void applyImageStream(ImageStream entity, String sourceName) { OpenShiftClient openShiftClient = getOpenShiftClient(); if (openShiftClient != null) { String kind = getKind(entity); String name = getName(entity); String namespace = getNamespace(); try { Resource<ImageStream, DoneableImageStream> resource = openShiftClient.imageStreams().inNamespace(namespace).withName(name); ImageStream old = resource.get(); if (old == null) { log.info("Creating " + kind + " " + name + " from " + sourceName); resource.create(entity); } else { log.info("Updating " + kind + " " + name + " from " + sourceName); copyAllImageStreamTags(entity, old); patchService.compareAndPatchEntity(namespace, entity, old); } openShiftClient.resource(entity).inNamespace(namespace).createOrReplace(); } catch (Exception e) { onApplyError("Failed to create " + kind + " from " + sourceName + ". " + e, e); } } }
log("Created replica sets:", client.apps().replicaSets().inNamespace("thisisatest").list().getItems()); System.err.println("Deleting:" + deployment.getMetadata().getName()); client.resource(deployment).delete();
public IstioResource registerOrUpdateCustomResource(final IstioResource resource) { return (IstioResource)resource(resource).createOrReplace(); }
try { log.info("Applying " + getKind(entity) + " " + getName(entity) + " from " + sourceName); kubernetesClient.resource(entity).inNamespace(getNamespace()).createOrReplace(); } catch (Exception e) { onApplyError("Failed to create " + getKind(entity) + " from " + sourceName + ". " + e, e);
@Override public void apply(KubernetesList resources, boolean patchPersistentVolumeClaims) { for (HasMetadata resource : resources.getItems()) { try { if (resource instanceof ConfigMap) { client.configMaps().withName(resource.getMetadata().getName()).patch((ConfigMap) resource); } else if (resource instanceof Secret) { client.secrets().withName(resource.getMetadata().getName()).patch((Secret) resource); } else if (resource instanceof Deployment) { client.apps().deployments().withName(resource.getMetadata().getName()).patch((Deployment) resource); } else if (resource instanceof StatefulSet) { client.apps().statefulSets().withName(resource.getMetadata().getName()).cascading(false).patch((StatefulSet) resource); } else if (resource instanceof Service) { client.services().withName(resource.getMetadata().getName()).patch((Service) resource); } else if (resource instanceof ServiceAccount) { client.serviceAccounts().withName(resource.getMetadata().getName()).patch((ServiceAccount) resource); } else if (resource instanceof PersistentVolumeClaim && patchPersistentVolumeClaims) { client.persistentVolumeClaims().withName(resource.getMetadata().getName()).patch((PersistentVolumeClaim) resource); } } catch (KubernetesClientException e) { if (e.getCode() == 404) { // Create it if it does not exist client.resource(resource).createOrReplace(); } else { throw e; } } } }
if (e.getCode() == 404) { client.resource(resource).createOrReplace(); } else { throw e;