use of io.fabric8.kubernetes.api.model.Namespace in project camel by apache.
the class KubernetesPodsProducer method doGetPod.
protected void doGetPod(Exchange exchange, String operation) throws Exception {
Pod pod = null;
String podName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_POD_NAME, String.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (ObjectHelper.isEmpty(podName)) {
LOG.error("Get a specific pod require specify a pod name");
throw new IllegalArgumentException("Get a specific pod require specify a pod name");
}
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Get a specific pod require specify a namespace name");
throw new IllegalArgumentException("Get a specific pod require specify a namespace name");
}
pod = getEndpoint().getKubernetesClient().pods().inNamespace(namespaceName).withName(podName).get();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(pod);
}
use of io.fabric8.kubernetes.api.model.Namespace in project camel by apache.
the class KubernetesReplicationControllersProducer method doScaleReplicationController.
protected void doScaleReplicationController(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);
Integer replicasNumber = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLER_REPLICAS, Integer.class);
if (ObjectHelper.isEmpty(rcName)) {
LOG.error("Scale a specific replication controller require specify a replication controller name");
throw new IllegalArgumentException("Scale a specific replication controller require specify a replication controller name");
}
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Scale a specific replication controller require specify a namespace name");
throw new IllegalArgumentException("Scale a specific replication controller require specify a namespace name");
}
if (ObjectHelper.isEmpty(replicasNumber)) {
LOG.error("Scale a specific replication controller require specify a replicas number");
throw new IllegalArgumentException("Scale a specific replication controller require specify a replicas number");
}
ReplicationController rcScaled = getEndpoint().getKubernetesClient().replicationControllers().inNamespace(namespaceName).withName(rcName).scale(replicasNumber, true);
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(rcScaled.getStatus().getReplicas());
}
use of io.fabric8.kubernetes.api.model.Namespace in project camel by apache.
the class KubernetesResourcesQuotaProducer method doGetResourceQuota.
protected void doGetResourceQuota(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);
if (ObjectHelper.isEmpty(rqName)) {
LOG.error("Get a specific Resource Quota require specify a Resource Quota name");
throw new IllegalArgumentException("Get a specific Resource Quota require specify a Resource Quota name");
}
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Get a specific Resource Quota require specify a namespace name");
throw new IllegalArgumentException("Get a specific Resource Quota require specify a namespace name");
}
rq = getEndpoint().getKubernetesClient().resourceQuotas().inNamespace(namespaceName).withName(rqName).get();
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 KubernetesSecretsProducer method doCreateSecret.
protected void doCreateSecret(Exchange exchange, String operation) throws Exception {
Secret secret = null;
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
Secret secretToCreate = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_SECRET, Secret.class);
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Create a specific secret require specify a namespace name");
throw new IllegalArgumentException("Create a specific secret require specify a namespace name");
}
if (ObjectHelper.isEmpty(secretToCreate)) {
LOG.error("Create a specific secret require specify a secret bean");
throw new IllegalArgumentException("Create a specific secret require specify a secret bean");
}
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_SECRETS_LABELS, Map.class);
secret = getEndpoint().getKubernetesClient().secrets().inNamespace(namespaceName).create(secretToCreate);
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(secret);
}
use of io.fabric8.kubernetes.api.model.Namespace in project camel by apache.
the class KubernetesSecretsProducer method doGetSecret.
protected void doGetSecret(Exchange exchange, String operation) throws Exception {
Secret secret = null;
String secretName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_SECRET_NAME, String.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (ObjectHelper.isEmpty(secretName)) {
LOG.error("Get a specific Secret require specify a Secret name");
throw new IllegalArgumentException("Get a specific Secret require specify a Secret name");
}
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Get a specific Secret require specify a namespace name");
throw new IllegalArgumentException("Get a specific Secret require specify a namespace name");
}
secret = getEndpoint().getKubernetesClient().secrets().inNamespace(namespaceName).withName(secretName).get();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(secret);
}
Aggregations