Search in sources :

Example 36 with Namespace

use of io.fabric8.kubernetes.api.model.Namespace 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)

Example 37 with Namespace

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

the class KubernetesResourcesQuotaProducer method doCreateResourceQuota.

protected void doCreateResourceQuota(Exchange exchange, String operation) throws Exception {
    ResourceQuota rq = null;
    String rqName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_NAME, String.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    ResourceQuotaSpec rqSpec = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_RESOURCE_QUOTA_SPEC, ResourceQuotaSpec.class);
    if (ObjectHelper.isEmpty(rqName)) {
        LOG.error("Create a specific resource quota require specify a resource quota name");
        throw new IllegalArgumentException("Create a specific resource quota require specify a resource quota name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Create a specific resource quota require specify a namespace name");
        throw new IllegalArgumentException("Create a specific resource quota require specify a namespace name");
    }
    if (ObjectHelper.isEmpty(rqSpec)) {
        LOG.error("Create a specific resource quota require specify a resource quota spec bean");
        throw new IllegalArgumentException("Create a specific resource quota require specify a resource quota spec bean");
    }
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_LABELS, Map.class);
    ResourceQuota rqCreating = new ResourceQuotaBuilder().withNewMetadata().withName(rqName).withLabels(labels).endMetadata().withSpec(rqSpec).build();
    rq = getEndpoint().getKubernetesClient().resourceQuotas().inNamespace(namespaceName).create(rqCreating);
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(rq);
}
Also used : DoneableResourceQuota(io.fabric8.kubernetes.api.model.DoneableResourceQuota) ResourceQuota(io.fabric8.kubernetes.api.model.ResourceQuota) ResourceQuotaSpec(io.fabric8.kubernetes.api.model.ResourceQuotaSpec) ResourceQuotaBuilder(io.fabric8.kubernetes.api.model.ResourceQuotaBuilder)

Example 38 with Namespace

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

the class KubernetesNamespacesProducer method doGetNamespace.

protected void doGetNamespace(Exchange exchange, String operation) {
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Get a specific namespace require specify a namespace name");
        throw new IllegalArgumentException("Get a specific namespace require specify a namespace name");
    }
    Namespace namespace = getEndpoint().getKubernetesClient().namespaces().withName(namespaceName).get();
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(namespace);
}
Also used : DoneableNamespace(io.fabric8.kubernetes.api.model.DoneableNamespace) Namespace(io.fabric8.kubernetes.api.model.Namespace)

Example 39 with Namespace

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

the class KubernetesPersistentVolumesClaimsProducer method doGetPersistentVolumeClaim.

protected void doGetPersistentVolumeClaim(Exchange exchange, String operation) throws Exception {
    PersistentVolumeClaim pvc = null;
    String pvcName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME, String.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (ObjectHelper.isEmpty(pvcName)) {
        LOG.error("Get a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
        throw new IllegalArgumentException("Get a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Get a specific Persistent Volume Claim require specify a namespace name");
        throw new IllegalArgumentException("Get a specific Persistent Volume Claim require specify a namespace name");
    }
    pvc = getEndpoint().getKubernetesClient().persistentVolumeClaims().inNamespace(namespaceName).withName(pvcName).get();
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(pvc);
}
Also used : DoneablePersistentVolumeClaim(io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim)

Example 40 with Namespace

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

the class KubernetesPersistentVolumesClaimsProducer method doCreatePersistentVolumeClaim.

protected void doCreatePersistentVolumeClaim(Exchange exchange, String operation) throws Exception {
    PersistentVolumeClaim pvc = null;
    String pvcName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME, String.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    PersistentVolumeClaimSpec pvcSpec = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_SPEC, PersistentVolumeClaimSpec.class);
    if (ObjectHelper.isEmpty(pvcName)) {
        LOG.error("Create a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
        throw new IllegalArgumentException("Create a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
        LOG.error("Create a specific Persistent Volume Claim require specify a namespace name");
        throw new IllegalArgumentException("Create a specific Persistent Volume Claim require specify a namespace name");
    }
    if (ObjectHelper.isEmpty(pvcSpec)) {
        LOG.error("Create a specific Persistent Volume Claim require specify a Persistent Volume Claim spec bean");
        throw new IllegalArgumentException("Create a specific Persistent Volume Claim require specify a Persistent Volume Claim spec bean");
    }
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS, Map.class);
    PersistentVolumeClaim pvcCreating = new PersistentVolumeClaimBuilder().withNewMetadata().withName(pvcName).withLabels(labels).endMetadata().withSpec(pvcSpec).build();
    pvc = getEndpoint().getKubernetesClient().persistentVolumeClaims().inNamespace(namespaceName).create(pvcCreating);
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(pvc);
}
Also used : PersistentVolumeClaimSpec(io.fabric8.kubernetes.api.model.PersistentVolumeClaimSpec) PersistentVolumeClaimBuilder(io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder) DoneablePersistentVolumeClaim(io.fabric8.kubernetes.api.model.DoneablePersistentVolumeClaim) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim)

Aggregations

Service (io.fabric8.kubernetes.api.model.Service)12 Test (org.junit.Test)11 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)10 Namespace (io.fabric8.kubernetes.api.model.Namespace)8 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)7 NonNamespaceOperation (io.fabric8.kubernetes.client.dsl.NonNamespaceOperation)7 ContainerBasedGatewayException (org.wso2.carbon.apimgt.core.exception.ContainerBasedGatewayException)6 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)6 BaseOperation (io.fabric8.kubernetes.client.dsl.base.BaseOperation)5 ArrayList (java.util.ArrayList)5 API (org.wso2.carbon.apimgt.core.models.API)5 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)4 Map (java.util.Map)4 Exchange (org.apache.camel.Exchange)4 Processor (org.apache.camel.Processor)4 DoneableNamespace (io.fabric8.kubernetes.api.model.DoneableNamespace)3 DoneableReplicationController (io.fabric8.kubernetes.api.model.DoneableReplicationController)3 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)3 Ingress (io.fabric8.kubernetes.api.model.extensions.Ingress)3 ScalableResource (io.fabric8.kubernetes.client.dsl.ScalableResource)3