public Future<ReconcileResult<Pod>> deletePod(String namespace, String name) { Labels labels = Labels.fromMap(null).withName(name); String podName = podOperations.list(namespace, labels).get(0).getMetadata().getName(); return podOperations.reconcile(namespace, podName, null); }
@Test public void testStrimziLabels() { Map sourceMap = new HashMap<String, String>(5); sourceMap.put(Labels.STRIMZI_CLUSTER_LABEL, "my-cluster"); sourceMap.put("key1", "value1"); sourceMap.put(Labels.STRIMZI_KIND_LABEL, "Kafka"); sourceMap.put("key2", "value2"); sourceMap.put(Labels.STRIMZI_NAME_LABEL, "my-cluster-kafka"); Labels labels = Labels.fromMap(sourceMap); Map expected = new HashMap<String, String>(2); expected.put(Labels.STRIMZI_CLUSTER_LABEL, "my-cluster"); expected.put(Labels.STRIMZI_KIND_LABEL, "Kafka"); expected.put(Labels.STRIMZI_NAME_LABEL, "my-cluster-kafka"); assertEquals(expected, labels.strimziLabels().toMap()); }
@Test public void testParseValidLabels() { String validLabels = "key1=value1,key2=value2"; Map sourceMap = new HashMap<String, String>(2); sourceMap.put("key1", "value1"); sourceMap.put("key2", "value2"); Labels expected = Labels.fromMap(sourceMap); Assert.assertEquals(expected, Labels.fromString(validLabels)); }
@Test public void testParseNullLabelsInFromMap() { assertEquals(Labels.EMPTY, Labels.fromMap(null)); }
/** * Generates service for pod. This service is used for exposing it externally. * * @param pod Number of the pod for which this service should be generated * @return The generated Service */ public Service generateExternalService(int pod) { if (isExposed()) { String perPodServiceName = externalServiceName(cluster, pod); List<ServicePort> ports = new ArrayList<>(1); ports.add(createServicePort(EXTERNAL_PORT_NAME, EXTERNAL_PORT, EXTERNAL_PORT, "TCP")); Labels selector = Labels.fromMap(getSelectorLabels()).withStatefulSetPod(kafkaPodName(cluster, pod)); return createService(perPodServiceName, getExternalServiceType(), ports, getLabelsWithName(perPodServiceName, templatePerPodServiceLabels), selector.toMap(), mergeAnnotations(Collections.EMPTY_MAP, templatePerPodServiceAnnotations)); } return null; }