@Override public StatefulSet updateImage(String image) { StatefulSet oldRC = get(); if (oldRC == null) { throw new KubernetesClientException("Existing StatefulSet doesn't exist"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().size() > 1) { throw new KubernetesClientException("Image update is not supported for multicontainer pods"); } if (oldRC.getSpec().getTemplate().getSpec().getContainers().size() == 0) { throw new KubernetesClientException("Pod has no containers!"); } Container updatedContainer = new ContainerBuilder(oldRC.getSpec().getTemplate().getSpec().getContainers().iterator().next()).withImage(image).build(); StatefulSetBuilder newRCBuilder = new StatefulSetBuilder(oldRC); newRCBuilder.editMetadata().withResourceVersion(null).endMetadata() .editSpec().editTemplate().editSpec().withContainers(Collections.singletonList(updatedContainer)) .endSpec().endTemplate().endSpec(); return new StatefulSetRollingUpdater(client, config, namespace).rollUpdate(oldRC, newRCBuilder.build()); }
.withAnnotations(annotations) .endMetadata() .editSpec() .editTemplate()
.withAnnotations(annotations) .endMetadata() .editSpec() .editTemplate()
.withAnnotations(annotations) .endMetadata() .editSpec() .editTemplate()
.withAnnotations(annotations) .endMetadata() .editSpec() .editTemplate()
.withName(name) .withLabels(getLabelsWithName(templateStatefulSetLabels)) .withNamespace(namespace) .withAnnotations(mergeAnnotations(annotations, templateStatefulSetAnnotations)) .withOwnerReferences(createOwnerReference()) .endMetadata() .withNewSpec() .withPodManagementPolicy("Parallel")
.endTemplate().build(); StatefulSet statefulSet = new StatefulSetBuilder().withNewMetadata().withName(appId).withLabels(idMap) .addToLabels(SPRING_MARKER_KEY, SPRING_MARKER_VALUE).endMetadata().withSpec(spec).build();
@Override protected ObjectMeta getOrCreateMetadata(StatefulSetBuilder item) { return item.hasMetadata() ? item.buildMetadata() : item.withNewMetadata().endMetadata().buildMetadata(); } }
@Override protected StatefulSet createClone(StatefulSet obj, String newName, String newDeploymentHash) { return new StatefulSetBuilder(obj) .editMetadata() .withResourceVersion(null) .withName(newName) .endMetadata() .editSpec() .withReplicas(0) .editSelector().addToMatchLabels(DEPLOYMENT_KEY, newDeploymentHash).endSelector() .editTemplate().editMetadata().addToLabels(DEPLOYMENT_KEY, newDeploymentHash).endMetadata().endTemplate() .endSpec() .build(); }