本文整理了Java中io.fabric8.kubernetes.client.KubernetesClient.replicationControllers()
方法的一些代码示例,展示了KubernetesClient.replicationControllers()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KubernetesClient.replicationControllers()
方法的具体详情如下:
包路径:io.fabric8.kubernetes.client.KubernetesClient
类名称:KubernetesClient
方法名:replicationControllers
暂无
代码示例来源:origin: fabric8io/kubernetes-client
@Override
public MixedOperation
return delegate.replicationControllers();
}
代码示例来源:origin: fabric8io/kubernetes-client
Config cOnfig= new ConfigBuilder().build();
try (final KubernetesClient client = new DefaultKubernetesClient(config)) {
try (Watch watch = client.replicationControllers().inNamespace("default").withName("test").watch(new Watcher
@Override
public void eventReceived(Action action, ReplicationController resource) {
代码示例来源:origin: org.domeos/kubernetes-client
@Override
public MixedOperation
return delegate.replicationControllers();
}
代码示例来源:origin: fabric8io/kubernetes-client
try (Watch watch = client.replicationControllers().inNamespace("thisisatest").withResourceVersion("0").watch(new Watcher
@Override
public void eventReceived(Action action, ReplicationController resource) {
log("Created RC", client.replicationControllers().inNamespace("thisisatest").create(rc));
client.replicationControllers().inNamespace("thisisatest").createNew()
.withNewMetadata().withName("nginx2-controller").addToLabels("server", "nginx").endMetadata()
.withNewSpec().withReplicas(0)
ReplicationController gotRc = client.replicationControllers().inNamespace("thisisatest").withName("nginx-controller").get();
log("Get RC by name in namespace", gotRc);
log("Get RC by label", client.replicationControllers().withLabel("server", "nginx").list());
log("Get RC without label", client.replicationControllers().withoutLabel("server", "apache").list());
log("Get RC with label in", client.replicationControllers().withLabelIn("server", "nginx").list());
log("Get RC with label not in", client.replicationControllers().withLabelNotIn("server", "apache").list());
log("Get RC by label in namespace", client.replicationControllers().inNamespace("thisisatest").withLabel("server", "nginx").list());
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")
代码示例来源:origin: stackoverflow.com
Config cOnfig= new ConfigBuilder().withMasterUrl(master).build();
try (final KubernetesClient client = new DefaultKubernetesClient(config)) {
client.replicationControllers().inNamespace("thisisatest").createNew()
.withNewMetadata().withName("nginx2-controller").addToLabels("server", "nginx").endMetadata()
.withNewSpec().withReplicas(0)
.withNewTemplate()
.withNewMetadata().addToLabels("server", "nginx2").endMetadata()
.withNewSpec()
.addNewContainer().withName("nginx").withImage("nginx")
.addNewPort().withContainerPort(80).endPort()
.endContainer()
.endSpec()
.endTemplate()
.endSpec().done();
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
代码示例来源:origin: io.fabric8/kubernetes-jolokia
/**
* 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);
}
代码示例来源:origin: io.fabric8/kubernetes-jolokia
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;
}
代码示例来源:origin: spring-cloud/spring-cloud-deployer-kubernetes
private void deleteReplicationController(Map
FilterWatchListDeletable
.withLabels(labels);
if (replicationControllersToDelete != null && replicationControllersToDelete.list().getItems() != null) {
boolean replicatiOnControllersDeleted= replicationControllersToDelete.delete();
logger.debug(String.format("ReplicationController deleted for: %s - %b", labels,
replicationControllersDeleted));
}
}
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
private ReplicationController getBrokerReplicationController() throws InterruptedException {
ReplicationController running;
do {
running = kubernetes.replicationControllers().inNamespace(namespace).withName(getReplicationControllerId()).get();
if (running == null) {
LOG.info("Waiting for ReplicationController " + getReplicationControllerId() + " to start");
Thread.sleep(5000);
}
} while (running == null);
return running;
}
代码示例来源:origin: jenkinsci/kubernetes-cd-plugin
@Override
ReplicationController createResource(ReplicationController current) {
return client
.replicationControllers()
.inNamespace(getNamespace())
.create(current);
}
代码示例来源:origin: org.apache.camel/camel-kubernetes
protected void doList(Exchange exchange, String operation) throws Exception {
ReplicationControllerList rcList = null;
String namespaceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
rcList = getEndpoint().getKubernetesClient()
.replicationControllers().inNamespace(namespaceName).list();
} else {
rcList = getEndpoint().getKubernetesClient()
.replicationControllers().inAnyNamespace().list();
}
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(rcList.getItems());
}
代码示例来源:origin: jenkinsci/kubernetes-ci-plugin
@Override
public void create(String kubeName, String namespace, ReplicationController replController)
throws RepositoryException {
if (LOGGER.isLoggable(Level.CONFIG) ) {
LOGGER.config("Creating Replication Controller: " + replController.getMetadata().getName() );
}
kubeRepository.getClient(kubeName).replicationControllers().inNamespace(namespace).create(replController);
}
代码示例来源:origin: jenkinsci/kubernetes-ci-plugin
@Override
public void delete(String kubeName, String namespace, ReplicationController replController)
throws RepositoryException {
String replCOntrollerName= replController.getMetadata().getName();
if (LOGGER.isLoggable(Level.CONFIG) ) {
LOGGER.config("Deleting Replication Controller and associated Pods: " + replControllerName);
}
final KubernetesClient client = kubeRepository.getClient(kubeName);
client.replicationControllers().inNamespace(namespace).withName(replControllerName).scale(0, true);
client.replicationControllers().inNamespace(namespace).delete(replController);
}
}
代码示例来源:origin: io.fabric8/fabric8-arquillian
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
KubernetesClient client = this.clientInstance.get();
Session session = sessionInstance.get();
Map
if( labels.isEmpty() ) {
return client.replicationControllers().inNamespace(session.getNamespace()).list();
} else {
return client.replicationControllers().inNamespace(session.getNamespace()).withLabels(labels).list();
}
}
}
代码示例来源:origin: fabric8io/fabric8-maven-plugin
protected void doCreateReplicationController(ReplicationController replicationController, String namespace, String sourceName) {
log.info("Creating a ReplicationController from " + sourceName + " namespace " + namespace + " name " + getName(replicationController));
try {
Object answer;
if (StringUtils.isNotBlank(namespace)) {
answer = kubernetesClient.replicationControllers().inNamespace(namespace).create(replicationController);
} else {
answer = kubernetesClient.replicationControllers().inNamespace(getNamespace()).create(replicationController);
}
logGeneratedEntity("Created ReplicationController: ", namespace, replicationController, answer);
} catch (Exception e) {
onApplyError("Failed to create ReplicationController from " + sourceName + ". " + e + ". " + replicationController, e);
}
}
代码示例来源:origin: jenkinsci/kubernetes-cd-plugin
@Override
ReplicationController getCurrentResource() {
return client
.replicationControllers()
.inNamespace(getNamespace())
.withName(getName())
.get();
}
代码示例来源:origin: io.fabric8/fabric8-arquillian
@Override
public Object lookup(ArquillianResource resource, Annotation... qualifiers) {
KubernetesClient client = this.clientInstance.get();
Session session = sessionInstance.get();
String name = getReplicationControllerName(qualifiers);
return client.replicationControllers().inNamespace(session.getNamespace()).withName(name).get();
}
}
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
public void createBroker() {
int desiredNumber = model.getBrokerCount() + 1;
if (scalingInProgress.startWork(desiredNumber)) {
try {
ReplicationController replicatiOnController= getBrokerReplicationController();
ReplicationControllerSpec spec = replicationController.getSpec();
int currentDesiredNumber = 0;
if (spec != null) {
currentDesiredNumber = spec.getReplicas();
} else {
spec = new ReplicationControllerSpec();
replicationController.setSpec(spec);
}
if (desiredNumber == (currentDesiredNumber + 1)) {
replicationController.getSpec().setReplicas(desiredNumber);
kubernetes.replicationControllers().inNamespace(namespace).withName(getReplicationControllerId()).replace(replicationController);
LOG.info("Updated Broker Replication Controller desired state from " + currentDesiredNumber + " to " + desiredNumber);
}
} catch (Throwable e) {
LOG.error("Failed to create a Broker", e);
}
}
}
代码示例来源:origin: jenkinsci/kubernetes-cd-plugin
@Override
ReplicationController applyResource(ReplicationController original, ReplicationController current) {
return client
.replicationControllers()
.inNamespace(getNamespace())
.withName(current.getMetadata().getName())
.edit()
.withMetadata(current.getMetadata())
.withSpec(current.getSpec())
.done();
}
代码示例来源:origin: fabric8io/fabric8-maven-plugin
private static EntityPatcher
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();
};
}