use of io.fabric8.kubernetes.client.dsl.NonNamespaceOperation in project camel by apache.
the class KubernetesServiceAccountsProducer method doListServiceAccountsByLabels.
protected void doListServiceAccountsByLabels(Exchange exchange, String operation) throws Exception {
ServiceAccountList saList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_SERVICE_ACCOUNTS_LABELS, Map.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
NonNamespaceOperation<ServiceAccount, ServiceAccountList, DoneableServiceAccount, Resource<ServiceAccount, DoneableServiceAccount>> serviceAccounts;
serviceAccounts = getEndpoint().getKubernetesClient().serviceAccounts().inNamespace(namespaceName);
for (Map.Entry<String, String> entry : labels.entrySet()) {
serviceAccounts.withLabel(entry.getKey(), entry.getValue());
}
saList = serviceAccounts.list();
} else {
MixedOperation<ServiceAccount, ServiceAccountList, DoneableServiceAccount, Resource<ServiceAccount, DoneableServiceAccount>> serviceAccounts;
serviceAccounts = getEndpoint().getKubernetesClient().serviceAccounts();
for (Map.Entry<String, String> entry : labels.entrySet()) {
serviceAccounts.withLabel(entry.getKey(), entry.getValue());
}
saList = serviceAccounts.list();
}
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(saList.getItems());
}
use of io.fabric8.kubernetes.client.dsl.NonNamespaceOperation in project camel by apache.
the class KubernetesNamespacesProducer method doListNamespaceByLabel.
protected void doListNamespaceByLabel(Exchange exchange, String operation) {
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_LABELS, Map.class);
if (ObjectHelper.isEmpty(labels)) {
LOG.error("Get a specific namespace by labels require specify a labels set");
throw new IllegalArgumentException("Get a specific namespace by labels require specify a labels set");
}
NonNamespaceOperation<Namespace, NamespaceList, DoneableNamespace, Resource<Namespace, DoneableNamespace>> namespaces = getEndpoint().getKubernetesClient().namespaces();
for (Map.Entry<String, String> entry : labels.entrySet()) {
namespaces.withLabel(entry.getKey(), entry.getValue());
}
NamespaceList namespace = namespaces.list();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(namespace.getItems());
}
use of io.fabric8.kubernetes.client.dsl.NonNamespaceOperation in project camel by apache.
the class KubernetesNodesProducer method doListNodesByLabels.
protected void doListNodesByLabels(Exchange exchange, String operation) throws Exception {
NodeList nodeList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NODES_LABELS, Map.class);
NonNamespaceOperation<Node, NodeList, DoneableNode, Resource<Node, DoneableNode>> nodes = getEndpoint().getKubernetesClient().nodes();
for (Map.Entry<String, String> entry : labels.entrySet()) {
nodes.withLabel(entry.getKey(), entry.getValue());
}
nodeList = nodes.list();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(nodeList.getItems());
}
use of io.fabric8.kubernetes.client.dsl.NonNamespaceOperation in project camel by apache.
the class KubernetesPersistentVolumesClaimsProducer method doListPersistentVolumesClaimsByLabels.
protected void doListPersistentVolumesClaimsByLabels(Exchange exchange, String operation) throws Exception {
PersistentVolumeClaimList pvcList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS, Map.class);
String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (!ObjectHelper.isEmpty(namespaceName)) {
NonNamespaceOperation<PersistentVolumeClaim, PersistentVolumeClaimList, DoneablePersistentVolumeClaim, Resource<PersistentVolumeClaim, DoneablePersistentVolumeClaim>> pvcs = getEndpoint().getKubernetesClient().persistentVolumeClaims().inNamespace(namespaceName);
for (Map.Entry<String, String> entry : labels.entrySet()) {
pvcs.withLabel(entry.getKey(), entry.getValue());
}
pvcList = pvcs.list();
} else {
MixedOperation<PersistentVolumeClaim, PersistentVolumeClaimList, DoneablePersistentVolumeClaim, Resource<PersistentVolumeClaim, DoneablePersistentVolumeClaim>> pvcs = getEndpoint().getKubernetesClient().persistentVolumeClaims();
for (Map.Entry<String, String> entry : labels.entrySet()) {
pvcs.withLabel(entry.getKey(), entry.getValue());
}
pvcList = pvcs.list();
}
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(pvcList.getItems());
}
use of io.fabric8.kubernetes.client.dsl.NonNamespaceOperation in project camel by apache.
the class KubernetesPersistentVolumesProducer method doListPersistentVolumesByLabels.
protected void doListPersistentVolumesByLabels(Exchange exchange, String operation) throws Exception {
PersistentVolumeList pvList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_LABELS, Map.class);
NonNamespaceOperation<PersistentVolume, PersistentVolumeList, DoneablePersistentVolume, Resource<PersistentVolume, DoneablePersistentVolume>> pvs;
pvs = getEndpoint().getKubernetesClient().persistentVolumes();
for (Map.Entry<String, String> entry : labels.entrySet()) {
pvs.withLabel(entry.getKey(), entry.getValue());
}
pvList = pvs.list();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(pvList.getItems());
}
Aggregations