Refine search
secret = client.secrets().withName(name).get(); secret = client.secrets().inNamespace(namespace).withName(name).get(); client.secrets().withLabels(config.getLabels()).list().getItems() .forEach(s -> putAll(s, result)); client.secrets().inNamespace(namespace) .withLabels(config.getLabels()).list().getItems() .forEach(s -> putAll(s, result));
public static void main(String[] args) { String master = "https://localhost:8443/"; if (args.length == 1) { master = args[0]; } Config config = new ConfigBuilder().withMasterUrl(master).build(); KubernetesClient client = new DefaultKubernetesClient(config); try { log("Create namespace:", client.namespaces().create(new NamespaceBuilder().withNewMetadata().withName("thisisatest").endMetadata().build())); log("Deleted namespace:", client.namespaces().withName("test").delete()); log("Deleted testPod:", client.pods().inNamespace("thisisatest").withName("testpod").delete()); log("Deleted pod by label:", client.pods().withLabel("this", "works").delete()); } catch (KubernetesClientException e) { logger.error(e.getMessage(), e); } finally { client.namespaces().withName("thisisatest").delete(); client.close(); } }
public List<Service> listServices(Map<String, String> labels) { return client.services().inNamespace(globalNamespace).withLabels(labels).list().getItems(); }
lb.setExists(client.services().inNamespace(namespace).withName(name).get() != null); res.setLoadBalancer(lb); List<Pod> pods = client.pods().inNamespace(namespace).withLabel("load-balancer-" + name, "true").list().getItems(); pods.addAll(client.pods().inNamespace(namespace).withLabel("load-balancer-" + name, "false").list().getItems());
log("Created namespace", client.namespaces().create(ns)); log("Get namespace by name", client.namespaces().withName("thisisatest").get()); log("Get namespace by label", client.namespaces().withLabel("this", "rocks").list()); log("Get RC by label", client.replicationControllers().withLabel("server", "nginx").list()); log("Get RC without label", client.replicationControllers().withoutLabel("server", "apache").list()); log("Get RC with label in", client.replicationControllers().withLabelIn("server", "nginx").list()); log("Get RC with label not in", client.replicationControllers().withLabelNotIn("server", "apache").list()); log("Get RC by label in namespace", client.replicationControllers().inNamespace("thisisatest").withLabel("server", "nginx").list()); log("Created RC", client.replicationControllers().inNamespace("thisisatest").create(rc)); client.replicationControllers().inAnyNamespace().withLabel("server", "nginx").delete(); log("Deleted RC by label"); log("Created RC", client.replicationControllers().inNamespace("thisisatest").create(rc)); client.replicationControllers().inNamespace("thisisatest").withField("metadata.name", "nginx-controller").delete(); log("Deleted RC by field"); .done()); log("Updated service", client.services().inNamespace("thisisatest").withName("testservice").edit().editMetadata().addToLabels("test", "label").endMetadata().done()); client.replicationControllers().inNamespace("thisisatest").withField("metadata.name", "testservice").delete(); log("Deleted service by field");
client.namespaces().list() ); client.namespaces().withLabel("this", "works").list() ); client.pods().withLabel("this", "works").list() ); client.pods().inNamespace("test").withLabel("this", "works").list() ); client.pods().inNamespace("test").withName("testing").get() );
@Override public ConfigMapList list(ListOptions listOptions) { return client.configMaps() .inNamespace(client.getNamespace()) .withLabel(LabelKeys.TYPE, "address-space") .list(); }
@Override public void listMaps(Handler<AsyncResult<List<KafkaTopic>>> handler) { vertx.executeBlocking(future -> { try { future.complete(operation().inNamespace(namespace).withLabels(resourcePredicate.labels()).list().getItems()); } catch (Exception e) { future.fail(e); } }, handler); }
public PodList getPods() { return labelValue != null && !labelValue.isEmpty() ? client.pods().inNamespace(namespace).withLabel(labelName, labelValue).list() : client.pods().inNamespace(namespace).withLabel(labelName).list(); }
private String waitForRunningPodWithEnvVar(final KubernetesClient kubernetes, final String namespace, LabelSelector selector, final Map<String, String> envVars) throws MojoExecutionException { FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> pods = withSelector(kubernetes.pods().inNamespace(namespace), selector, log); log.info("Waiting for debug pod with selector " + selector + " and environment variables " + envVars); podWaitLog = createExternalProcessLogger("[[Y]][W][[Y]] "); PodList list = pods.list(); if (list != null) { Pod latestPod = KubernetesResourceUtil.getNewestPod(list.getItems()); podWatcher = pods.watch(new Watcher<Pod>() { @Override public void eventReceived(Watcher.Action action, Pod pod) {
PodList list = client.pods().withLabels(createdByZaleniumMap).list();
return; ReplicationController old = kubernetesClient.replicationControllers().inNamespace(namespace).withName(id).get(); if (isRunning(old)) { if (UserConfigurationCompare.configEqual(replicationController, old)) { kubernetesClient.replicationControllers().inNamespace(namespace).withName(id).rolling().replace(replicationController); } else if (isRecreateMode()) { log.info("Deleting ReplicationController: " + id); kubernetesClient.replicationControllers().inNamespace(namespace).withName(id).delete(); doCreateReplicationController(replicationController, namespace, sourceName); } else { kubernetesClient.pods().inNamespace(namespace).withLabels(newSpec.getSelector()).delete(); log.info("Deleting any pods for the replication controller to ensure they use the new configuration"); } else {
Config config = new ConfigBuilder().withMasterUrl(master).build(); try(final KubernetesClient client = new DefaultKubernetesClient(config)) { final String namespace = client.getNamespace(); cronJob1 = client.batch().cronjobs().inNamespace(namespace).create(cronJob1); log("Successfully created cronjob with name ", cronJob1.getMetadata().getName()); try (Watch watch = client.pods().inNamespace(namespace).withLabel("job-name").watch(new Watcher<Pod>() { @Override public void eventReceived(Action action, Pod aPod) {
public List<Deployment> listDeployments(Map<String, String> labels) { return client.apps().deployments().inNamespace(globalNamespace).withLabels(labels).list().getItems(); }
Service service = delegate.services().inNamespace(prjName).withName(svcName).get(); if (service != null) { appName = service.getMetadata().getLabels().get(APP_LABEL); delegate.deploymentConfigs().inNamespace(prjName).withName(svcName).cascading(true).delete(); if (appName != null) { delegate.services().inNamespace(prjName).withLabel(APP_LABEL, appName).delete(); delegate.routes().inNamespace(prjName).withLabel(APP_LABEL, appName).delete(); } else { delegate.services().inNamespace(prjName).delete();
public List<Secret> listSecrets(Map<String, String> labels) { return client.secrets().inNamespace(globalNamespace).withLabels(labels).list().getItems(); }
public List<ConfigMap> listConfigMaps(Map<String, String> labels) { return client.configMaps().inNamespace(globalNamespace).withLabels(labels).list().getItems(); }
private Pod getNewestPod(LabelSelector selector) { FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> pods = KubernetesClientUtil.withSelector(kubernetes.pods(), selector, log); PodList list = pods.list(); if (list != null) { List<Pod> items = list.getItems(); return getNewestPod(items); } return null; }