Pod createdPod = doneablePod.done(); String containerName = createdPod.getMetadata() == null ? containerIdPrefix : createdPod.getMetadata().getName(); return new ContainerCreationStatus(true, containerName, containerName, nodePort);
public static DoneablePod createDoneablePodDefaultImpl(PodConfiguration config) { DoneablePod doneablePod = config.getClient().pods() .createNew() .withNewMetadata() .withGenerateName(config.getContainerIdPrefix()) .addToLabels(config.getLabels()) .endMetadata() .withNewSpec() .withNodeSelector(config.getNodeSelector()) .withTolerations(config.getTolerations()) .editSpec() .addNewVolumeLike(entry.getValue()) .and() .editSpec() .addNewHostAliasLike(hostAlias) .endHostAlias()
.withNewMetadata() .withName("testpod") .addToLabels("server", "nginx") .endMetadata() .withNewSpec() .addNewContainer().withName("nginx").withImage("nginx") .addNewPort().withContainerPort(80).endPort() .endContainer() .endSpec().done(); log("Created testPod:", createdPod); .editMetadata() .addToLabels("server2", "nginx2") .and().done(); log("Replaced testPod:", updatedPod);
@Override Pod applyResource(Pod original, Pod current) { return client .pods() .inNamespace(getNamespace()) .withName(current.getMetadata().getName()) .edit() .withMetadata(current.getMetadata()) .withSpec(current.getSpec()) .done(); }
pods().inNamespace(namespace).withName(pod.getMetadata().getName()) .edit() .editMetadata().addToLabels(DEPLOYMENT_KEY, oldDeploymentHash) .and().done(); } catch (KubernetesClientException e) { LOG.warn("Unable to add deployment key to pod: {}", e.getMessage());
private void launchPod(String appId, PodSpec podSpec, Map<String, String> labelMap, Map<String, String> idMap, Map<String, String> annotations) { client.pods() .createNew() .withNewMetadata() .withName(appId) .withLabels(labelMap) .withAnnotations(annotations) .addToLabels(idMap) .endMetadata() .withSpec(podSpec) .done(); }
.withNewMetadata() .withName(podTemplate.getName()) .addToLabels(labels) .addToLabels("image", containers.get(0).getName()) .endMetadata() .withNewSpec() .withNodeSelector(node != null ? node.getMetadata().getLabels() : new HashMap<String, String>()) .withVolumes(volumes) .withServiceAccount(podTemplate.getServiceAccount()) .endSpec() .done(); return p;
private static EntityPatcher<Pod> podPatcher() { return (KubernetesClient client, String namespace, Pod newObj, Pod oldObj) -> { if (UserConfigurationCompare.configEqual(newObj, oldObj)) { return oldObj; } DoneablePod entity = client.pods() .inNamespace(namespace) .withName(oldObj.getMetadata().getName()) .edit(); if (!UserConfigurationCompare.configEqual(newObj.getMetadata(), oldObj.getMetadata())) { entity.withMetadata(newObj.getMetadata()); } if(!UserConfigurationCompare.configEqual(newObj.getSpec(), oldObj.getSpec())) { entity.withSpec(newObj.getSpec()); } return entity.done(); }; }
pods().inNamespace(namespace).withName(pod.getMetadata().getName()) .edit() .editMetadata().addToLabels(DEPLOYMENT_KEY, oldDeploymentHash) .and().done(); } catch (KubernetesClientException e) { LOG.warn("Unable to add deployment key to pod: {}", e.getMessage());