@Override int getDesiredReplicas(ReplicationController item) { return item.getSpec().getReplicas(); }
@Override protected int getReplicas(ReplicationController obj) { return obj.getSpec().getReplicas(); }
public static boolean isReplicationControllerReady(ReplicationController r) { Utils.checkNotNull(r, "ReplicationController can't be null."); ReplicationControllerSpec spec = r.getSpec(); ReplicationControllerStatus status = r.getStatus(); if (status == null || status.getReadyReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReadyReplicas(); }
@Override protected PodList listSelectedPods(ReplicationController obj) { return pods().inNamespace(namespace).withLabels(obj.getSpec().getSelector()).list(); }
@Override public ReplicationController updateImage(String image) { ReplicationController oldRC = get(); if (oldRC == null) { throw new KubernetesClientException("Existing replication controller 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(); ReplicationControllerBuilder newRCBuilder = new ReplicationControllerBuilder(oldRC); newRCBuilder.editMetadata().withResourceVersion(null).endMetadata() .editSpec().editTemplate().editSpec().withContainers(Collections.singletonList(updatedContainer)) .endSpec().endTemplate().endSpec(); return new ReplicationControllerRollingUpdater(client, config, namespace).rollUpdate(oldRC, newRCBuilder.build()); }
public static PodSpec getPodTemplatePodSpec(ReplicationController replicationController) { if (replicationController != null) { return getPodTemplatePodSpec(replicationController.getSpec()); } return null; }
@Override protected int getReplicas(ReplicationController obj) { return obj.getSpec().getReplicas(); }
public static PodTemplateSpec getPodTemplateSpec(ReplicationController replicationController) { if (replicationController != null) { return getPodTemplateSpec(replicationController.getSpec()); } return null; }
public static boolean isReplicationControllerReady(ReplicationController r) { Utils.checkNotNull(r, "ReplicationController can't be null."); ReplicationControllerSpec spec = r.getSpec(); ReplicationControllerStatus status = r.getStatus(); if (status == null || status.getReadyReplicas() == null) { return false; } //Can be true in testing, so handle it to make test writing easier. if (spec == null || spec.getReplicas() == null) { return false; } return spec.getReplicas().intValue() == status.getReadyReplicas(); }
@Override protected PodList listSelectedPods(ReplicationController obj) { return pods().inNamespace(namespace).withLabels(obj.getSpec().getSelector()).list(); }
private static EntityPatcher<ReplicationController> rcPatcher() { return (KubernetesClient client, String namespace, ReplicationController newObj, ReplicationController oldObj) -> { if (UserConfigurationCompare.configEqual(newObj, oldObj)) { return oldObj; } DoneableReplicationController entity = client.replicationControllers() .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(); }; }
@Override public ReplicationController updateImage(String image) { ReplicationController oldRC = get(); if (oldRC == null) { throw new KubernetesClientException("Existing replication controller 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(); ReplicationControllerBuilder newRCBuilder = new ReplicationControllerBuilder(oldRC); newRCBuilder.editMetadata().withResourceVersion(null).endMetadata() .editSpec().editTemplate().editSpec().withContainers(Collections.singletonList(updatedContainer)) .endSpec().endTemplate().endSpec(); return new ReplicationControllerRollingUpdater(client, config, namespace).rollUpdate(oldRC, newRCBuilder.build()); }
public ReplicationControllerBuilder(ReplicationControllerFluent<?> fluent,ReplicationController instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); this.validationEnabled = validationEnabled; } public ReplicationControllerBuilder(ReplicationController instance){
public ReplicationControllerBuilder(ReplicationController instance,Boolean validationEnabled){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); this.validationEnabled = validationEnabled; }
public ReplicationControllerFluentImpl(ReplicationController instance){ this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
public ReplicationControllerBuilder( ReplicationControllerFluent<?> fluent , ReplicationController instance ){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); } public ReplicationControllerBuilder( ReplicationController instance ){
public ReplicationControllerBuilder( ReplicationControllerFluent<?> fluent , ReplicationController instance ){ this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); } public ReplicationControllerBuilder( ReplicationController instance ){
public ReplicationControllerBuilder( ReplicationController instance ){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
public ReplicationControllerBuilder( ReplicationController instance ){ this.fluent = this; this.withApiVersion(instance.getApiVersion()); this.withKind(instance.getKind()); this.withMetadata(instance.getMetadata()); this.withSpec(instance.getSpec()); this.withStatus(instance.getStatus()); }
@Override ReplicationController applyResource(ReplicationController original, ReplicationController current) { return client .replicationControllers() .inNamespace(getNamespace()) .withName(current.getMetadata().getName()) .edit() .withMetadata(current.getMetadata()) .withSpec(current.getSpec()) .done(); }