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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations