Search in sources :

Example 1 with ReplicationControllerBuilder

use of io.fabric8.kubernetes.api.model.ReplicationControllerBuilder in project camel by apache.

the class KubernetesReplicationControllersProducer method doCreateReplicationController.

protected void doCreateReplicationController(Exchange exchange, String operation) throws Exception {
    ReplicationController rc = null;
    String rcName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_NAME, String.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    ReplicationControllerSpec rcSpec = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_SPEC, ReplicationControllerSpec.class);
    if (ObjectHelper.isEmpty(rcName)) {
        LOG.error("Create a specific replication controller require specify a replication controller name");
        throw new IllegalArgumentException("Create a specific replication controller require specify a replication controller name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Create a specific replication controller require specify a namespace name");
        throw new IllegalArgumentException("Create a specific replication controller require specify a namespace name");
    }
    if (ObjectHelper.isEmpty(rcSpec)) {
        LOG.error("Create a specific replication controller require specify a replication controller spec bean");
        throw new IllegalArgumentException("Create a specific replication controller require specify a replication controller spec bean");
    }
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLERS_LABELS, Map.class);
    ReplicationController rcCreating = new ReplicationControllerBuilder().withNewMetadata().withName(rcName).withLabels(labels).endMetadata().withSpec(rcSpec).build();
    rc = getEndpoint().getKubernetesClient().replicationControllers().inNamespace(namespaceName).create(rcCreating);
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(rc);
}
Also used : ReplicationControllerBuilder(io.fabric8.kubernetes.api.model.ReplicationControllerBuilder) DoneableReplicationController(io.fabric8.kubernetes.api.model.DoneableReplicationController) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) ReplicationControllerSpec(io.fabric8.kubernetes.api.model.ReplicationControllerSpec)

Aggregations

DoneableReplicationController (io.fabric8.kubernetes.api.model.DoneableReplicationController)1 ReplicationController (io.fabric8.kubernetes.api.model.ReplicationController)1 ReplicationControllerBuilder (io.fabric8.kubernetes.api.model.ReplicationControllerBuilder)1 ReplicationControllerSpec (io.fabric8.kubernetes.api.model.ReplicationControllerSpec)1