private ReplicationController createReplicationController(String name, String apiVersion, Map<String, String> labels, int replicas, Map<String, String> selector, PodTemplateSpec podTemplate) throws Exception { ReplicationController rc = new ReplicationController(); rc.setApiVersion(apiVersion); ObjectMeta objectMeta = new ObjectMeta(); rc.setMetadata(objectMeta); objectMeta.setName(name); objectMeta.setLabels(labels); ReplicationControllerSpec spec = new ReplicationControllerSpec(); rc.setSpec(spec); spec.setReplicas(replicas); spec.setSelector(selector); spec.setTemplate(podTemplate); return rc; }
return client.pods() .inNamespace(resource.getMetadata().getNamespace()) .withLabels(((ReplicationController) resource).getSpec().getSelector()) .list(); } else if (resource instanceof ReplicaSet) {
return client.pods() .inNamespace(resource.getMetadata().getNamespace()) .withLabels(((ReplicationController) resource).getSpec().getSelector()) .list(); } else if (resource instanceof ReplicaSet) {
public <T extends HasMetadata> PodList podsOf(T resource) { if (resource instanceof Pod) { return new PodListBuilder().withItems((Pod) resource).build(); } else if (resource instanceof Endpoints) { return podsOf(client.services() .inNamespace(resource.getMetadata().getNamespace()) .withName(resource.getMetadata().getName()) .get()); } else if (resource instanceof Service) { return client.pods() .inNamespace(resource.getMetadata().getNamespace()) .withLabels(((Service) resource).getSpec().getSelector()) .list(); } else if (resource instanceof ReplicationController) { return client.pods() .inNamespace(resource.getMetadata().getNamespace()) .withLabels(((ReplicationController) resource).getSpec().getSelector()) .list(); } else if (resource instanceof ReplicaSet) { return findMatching((ReplicaSet) resource); } else if (resource instanceof Deployment) { return findMatching((Deployment) resource); } else if (resource instanceof DeploymentConfig) { return client.pods().inNamespace(resource.getMetadata().getName()).withLabel("deploymentconfig", resource.getMetadata().getName()).list(); } else { return new PodListBuilder().build(); } }