Refine search
log("Created namespace", client.namespaces().create(ns)); ReplicationController gotRc = client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").get(); log("Get RC by name in namespace", gotRc); client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").cascading(false).edit().editMetadata().addToLabels("new", "label").endMetadata().done(); client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").scale(8); client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").edit().editSpec().editTemplate().withNewSpec() .addNewContainer().withName("nginx").withImage("httpd") .addNewPort().withContainerPort(80).endPort() client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").rolling().updateImage("nginx"); client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller") .rolling().edit().editMetadata().addToLabels("testing", "rolling-update").endMetadata().done(); client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").edit() .editMetadata() .addToLabels("another", "label") client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").delete(); client.replicationControllers().inNamespace("thisisatest").withName("nginx2-controller").delete(); log("Deleted RCs"); client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").delete(); log("Deleted RC");
pods().inNamespace(namespace).withName(pod.getMetadata().getName()) .edit() .editMetadata().addToLabels(DEPLOYMENT_KEY, oldDeploymentHash) D editable = resources().inNamespace(namespace).withName(oldName).cascading(false).edit(); updateDeploymentKey(editable, oldDeploymentHash); oldObj = editable.done(); T createdObj = resources().inNamespace(namespace).create(clonedObj); while (getReplicas(createdObj) < getReplicas(newObj)) { int newReplicas = getReplicas(createdObj) + 1; resources().inNamespace(namespace).withName(createdObj.getMetadata().getName()).scale(newReplicas, true); waitUntilPodsAreReady(createdObj, namespace, newReplicas); createdObj = setReplicas(createdObj, newReplicas); resources().inNamespace(namespace).withName(oldName).scale(--oldReplicas, true); waitUntilPodsAreReady(oldObj, namespace, oldReplicas); resources().inNamespace(namespace).withName(oldName).delete(); resources().inNamespace(namespace).withName(newName).cascading(false).delete(); createdObj = resources().inNamespace(namespace).create(createdObj); editable = resources().inNamespace(namespace).withName(createdObj.getMetadata().getName()).cascading(false).edit(); removeDeploymentKey(editable); createdObj = editable.done();
if (client.services().inNamespace(namespace).withName(serviceName).get() != null) { if (recreate) { client.services().inNamespace(namespace).withName(serviceName).delete(); } else { create = false; client.services().inNamespace(namespace).create(serviceBuilder.build()); if (client.extensions().replicaSets().inNamespace(namespace).withName(replicaSetName).get() != null) { if (recreate) { client.extensions().replicaSets().inNamespace(namespace).withName(replicaSetName).delete();
protected ReplicationController requireReplicationController(String replicationControllerName, String namespace) { ReplicationController answer = kubernetes.replicationControllers().inNamespace(namespace).withName(replicationControllerName).get(); Objects.requireNonNull(answer, "No ReplicationController found for namespace: " + namespace + " name: " + replicationControllerName); return answer; }
Service service = client.services().inNamespace(session.getNamespace()).withName(serviceName).get(); if (service != null) { return jolokiaClients.clientForService(service); Pod pod = client.pods().inNamespace(session.getNamespace()).withName(serviceName).get(); if (pod != null) { return jolokiaClients.clientForPod(pod); ReplicationController replicationController = client.replicationControllers().inNamespace(session.getNamespace()).withName(replicationControllerName).get(); if (replicationController != null) { return jolokiaClients.clientForReplicationController(replicationController);
return; ReplicationController old = kubernetesClient.replicationControllers().inNamespace(namespace).withName(id).get(); if (isRunning(old)) { if (UserConfigurationCompare.configEqual(replicationController, old)) { kubernetesClient.replicationControllers().inNamespace(namespace).withName(id).rolling().replace(replicationController); } else if (isRecreateMode()) { log.info("Deleting ReplicationController: " + id); kubernetesClient.replicationControllers().inNamespace(namespace).withName(id).delete(); doCreateReplicationController(replicationController, namespace, sourceName); } else {
if (spec != null) { if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) { kubernetes.extensions().deployments().inNamespace(namespace).withName(name).replace(resource); if (spec != null) { if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) { kubernetes.extensions().replicaSets().inNamespace(namespace).withName(name).replace(resource); if (spec != null) { if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) { kubernetes.replicationControllers().inNamespace(namespace).withName(name).replace(resource);
static void resize(AccountDeploymentDetails<KubernetesAccount> details, String namespace, String replicaSetName, int targetSize) { KubernetesClient client = getClient(details); client.extensions().replicaSets().inNamespace(namespace).withName(replicaSetName).scale(targetSize); }
static void deleteReplicaSet(AccountDeploymentDetails<KubernetesAccount> details, String namespace, String name) { getClient(details).extensions().replicaSets().inNamespace(namespace).withName(name).delete(); }
@Override ReplicationController applyResource(ReplicationController original, ReplicationController current) { return client .replicationControllers() .inNamespace(getNamespace()) .withName(current.getMetadata().getName()) .edit() .withMetadata(current.getMetadata()) .withSpec(current.getSpec()) .done(); }
@Override ReplicaSet getCurrentResource() { return client .extensions() .replicaSets() .inNamespace(getNamespace()) .withName(getName()) .get(); }
.replicationControllers().inNamespace(namespaceName) .withName(rcName).scale(replicasNumber, false);
protected void doDeleteReplicationController(Exchange exchange, String operation) throws Exception { String rcName = exchange.getIn().getHeader( KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_NAME, String.class); String namespaceName = exchange.getIn().getHeader( KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class); if (ObjectHelper.isEmpty(rcName)) { LOG.error("Delete a specific replication controller require specify a replication controller name"); throw new IllegalArgumentException( "Delete a specific replication controller require specify a replication controller name"); } if (ObjectHelper.isEmpty(namespaceName)) { LOG.error("Delete a specific replication controller require specify a namespace name"); throw new IllegalArgumentException( "Delete a specific replication controller require specify a namespace name"); } boolean rcDeleted = getEndpoint().getKubernetesClient() .replicationControllers().inNamespace(namespaceName) .withName(rcName).delete(); MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true); exchange.getOut().setBody(rcDeleted); }
public void setStatefulSetReplicas(String name, int numReplicas) { client.apps().statefulSets().inNamespace(globalNamespace).withName(name).scale(numReplicas, true); }
@Override ReplicaSet applyResource(ReplicaSet original, ReplicaSet current) { return client .extensions() .replicaSets() .inNamespace(getNamespace()) .withName(current.getMetadata().getName()) .edit() .withMetadata(current.getMetadata()) .withSpec(current.getSpec()) .done(); }
/** * Returns a client for the first working pod for the given replication controller */ public J4pClient clientForReplicationController(String replicationControllerName) { ReplicationController replicationController = kubernetes.replicationControllers().withName(replicationControllerName).get(); Objects.requireNonNull(replicationController, "No ReplicationController found for name: " + replicationControllerName); return clientForReplicationController(replicationController); }
@Override public void apply(KubernetesList resources, boolean patchPersistentVolumeClaims) { for (HasMetadata resource : resources.getItems()) { try { if (resource instanceof ConfigMap) { client.configMaps().withName(resource.getMetadata().getName()).patch((ConfigMap) resource); } else if (resource instanceof Secret) { client.secrets().withName(resource.getMetadata().getName()).patch((Secret) resource); } else if (resource instanceof Deployment) { client.apps().deployments().withName(resource.getMetadata().getName()).patch((Deployment) resource); } else if (resource instanceof StatefulSet) { client.apps().statefulSets().withName(resource.getMetadata().getName()).cascading(false).patch((StatefulSet) resource); } else if (resource instanceof Service) { client.services().withName(resource.getMetadata().getName()).patch((Service) resource); } else if (resource instanceof ServiceAccount) { client.serviceAccounts().withName(resource.getMetadata().getName()).patch((ServiceAccount) resource); } else if (resource instanceof PersistentVolumeClaim && patchPersistentVolumeClaims) { client.persistentVolumeClaims().withName(resource.getMetadata().getName()).patch((PersistentVolumeClaim) resource); } } catch (KubernetesClientException e) { if (e.getCode() == 404) { // Create it if it does not exist client.resource(resource).createOrReplace(); } else { throw e; } } } }
@Override public RouterCluster getRouterCluster() throws IOException { StatefulSet s = client.apps().statefulSets().withName("qdrouterd-" + infraUuid).get(); StandardInfraConfig infraConfig = null; if (s.getMetadata().getAnnotations() != null && s.getMetadata().getAnnotations().get(AnnotationKeys.APPLIED_INFRA_CONFIG) != null) { infraConfig = mapper.readValue(s.getMetadata().getAnnotations().get(AnnotationKeys.APPLIED_INFRA_CONFIG), StandardInfraConfig.class); } return new RouterCluster(s.getMetadata().getName(), s.getSpec().getReplicas(), infraConfig); }