@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 ReplicationControllerSpecBuilder( ReplicationControllerSpecFluent<?> fluent , ReplicationControllerSpec instance ){ this.fluent = fluent; fluent.withReplicas(instance.getReplicas()); fluent.withSelector(instance.getSelector()); fluent.withTemplate(instance.getTemplate()); fluent.withTemplateRef(instance.getTemplateRef()); } public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){
public static PodTemplateSpec getPodTemplateSpec(ReplicationControllerSpec replicationControllerSpec) { PodTemplateSpec podTemplate = null; if (replicationControllerSpec != null) { podTemplate = replicationControllerSpec.getTemplate(); } return podTemplate; }
public ReplicationControllerSpecBuilder( ReplicationControllerSpecFluent<?> fluent , ReplicationControllerSpec instance ){ this.fluent = fluent; fluent.withReplicas(instance.getReplicas()); fluent.withSelector(instance.getSelector()); fluent.withTemplate(instance.getTemplate()); fluent.withTemplateRef(instance.getTemplateRef()); } public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){
public static PodSpec getPodTemplatePodSpec(ReplicationControllerSpec replicationControllerSpec) { PodTemplateSpec podTemplate; PodSpec podTemplatePodStatus = null; if (replicationControllerSpec != null) { podTemplate = replicationControllerSpec.getTemplate(); if (podTemplate != null) { podTemplatePodStatus = podTemplate.getSpec(); } } return podTemplatePodStatus; }
public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){ this.fluent = this; this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); this.withTemplateRef(instance.getTemplateRef()); }
public ReplicationControllerSpecBuilder(ReplicationControllerSpec instance,Boolean validationEnabled){ this.fluent = this; this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; }
public ReplicationControllerSpecBuilder( ReplicationControllerSpec instance ){ this.fluent = this; this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); this.withTemplateRef(instance.getTemplateRef()); }
public ReplicationControllerSpecBuilder(ReplicationControllerSpecFluent<?> fluent,ReplicationControllerSpec instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withReplicas(instance.getReplicas()); fluent.withSelector(instance.getSelector()); fluent.withTemplate(instance.getTemplate()); this.validationEnabled = validationEnabled; } public ReplicationControllerSpecBuilder(ReplicationControllerSpec instance){
public ReplicationControllerSpecFluentImpl(ReplicationControllerSpec instance){ this.withReplicas(instance.getReplicas()); this.withSelector(instance.getSelector()); this.withTemplate(instance.getTemplate()); }
@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()); }
PodTemplateSpec podTemplate = replicationControllerSpec.getTemplate(); if (podTemplate != null) { getOrCreateMetadata(pod).setLabels(KubernetesHelper.getLabels(podTemplate.getMetadata()));
private boolean enableDebug(HasMetadata entity) { if (entity instanceof Deployment) { Deployment resource = (Deployment) entity; DeploymentSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicaSet) { ReplicaSet resource = (ReplicaSet) entity; ReplicaSetSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicationController) { ReplicationController resource = (ReplicationController) entity; ReplicationControllerSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof DeploymentConfig) { DeploymentConfig resource = (DeploymentConfig) entity; DeploymentConfigSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } return false; }
private boolean enableDebug(HasMetadata entity) { if (entity instanceof Deployment) { Deployment resource = (Deployment) entity; DeploymentSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicaSet) { ReplicaSet resource = (ReplicaSet) entity; ReplicaSetSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicationController) { ReplicationController resource = (ReplicationController) entity; ReplicationControllerSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof DeploymentConfig) { DeploymentConfig resource = (DeploymentConfig) entity; DeploymentConfigSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } return false; }
private boolean enableDebug(HasMetadata entity) { if (entity instanceof Deployment) { Deployment resource = (Deployment) entity; DeploymentSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicaSet) { ReplicaSet resource = (ReplicaSet) entity; ReplicaSetSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof ReplicationController) { ReplicationController resource = (ReplicationController) entity; ReplicationControllerSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } else if (entity instanceof DeploymentConfig) { DeploymentConfig resource = (DeploymentConfig) entity; DeploymentConfigSpec spec = resource.getSpec(); if (spec != null) { return enableDebugging(entity, spec.getTemplate()); } } return false; }
ReplicationControllerSpec spec = resource.getSpec(); if (spec != null) { if (enableDebugging(entity, spec.getTemplate())) { kubernetes.replicationControllers().inNamespace(namespace).withName(name).replace(resource);
public void addRegistryToImageNameIfNotPresent(Iterable<HasMetadata> items, String registry) throws Exception { if (items != null) { for (HasMetadata item : items) { if (item instanceof KubernetesList) { KubernetesList list = (KubernetesList) item; addRegistryToImageNameIfNotPresent(list.getItems(), registry); } else if (item instanceof Template) { Template template = (Template) item; addRegistryToImageNameIfNotPresent(template.getObjects(), registry); } else if (item instanceof Pod) { List<Container> containers = ((Pod) item).getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof ReplicationController) { List<Container> containers = ((ReplicationController) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof ReplicaSet) { List<Container> containers = ((ReplicaSet) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof DeploymentConfig) { List<Container> containers = ((DeploymentConfig) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof Deployment) { List<Container> containers = ((Deployment) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } } } }
public void addRegistryToImageNameIfNotPresent(Iterable<HasMetadata> items, String registry) { if (items != null) { for (HasMetadata item : items) { if (item instanceof KubernetesList) { KubernetesList list = (KubernetesList) item; addRegistryToImageNameIfNotPresent(list.getItems(), registry); } else if (item instanceof Template) { Template template = (Template) item; addRegistryToImageNameIfNotPresent(template.getObjects(), registry); } else if (item instanceof Pod) { List<Container> containers = ((Pod) item).getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof ReplicationController) { List<Container> containers = ((ReplicationController) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof ReplicaSet) { List<Container> containers = ((ReplicaSet) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof DeploymentConfig) { List<Container> containers = ((DeploymentConfig) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof Deployment) { List<Container> containers = ((Deployment) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } } } }
public void addRegistryToImageNameIfNotPresent(Iterable<HasMetadata> items, String registry) { if (items != null) { for (HasMetadata item : items) { if (item instanceof KubernetesList) { KubernetesList list = (KubernetesList) item; addRegistryToImageNameIfNotPresent(list.getItems(), registry); } else if (item instanceof Template) { Template template = (Template) item; addRegistryToImageNameIfNotPresent(template.getObjects(), registry); } else if (item instanceof Pod) { List<Container> containers = ((Pod) item).getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof ReplicationController) { List<Container> containers = ((ReplicationController) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof ReplicaSet) { List<Container> containers = ((ReplicaSet) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof DeploymentConfig) { List<Container> containers = ((DeploymentConfig) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } else if (item instanceof Deployment) { List<Container> containers = ((Deployment) item).getSpec().getTemplate().getSpec().getContainers(); prefixRegistryIfNotPresent(containers, registry); } } } }
ReplicationControllerSpec spec = resource.getSpec(); if (spec != null) { if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) { kubernetes.replicationControllers().inNamespace(namespace).withName(name).replace(resource);