use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesSecretsProducerTest method listByLabelsTest.
@Test
public void listByLabelsTest() throws Exception {
if (authToken == null) {
return;
}
Exchange ex = template.request("direct:listByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
Map<String, String> labels = new HashMap<String, String>();
labels.put("component", "elasticsearch");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_SECRETS_LABELS, labels);
}
});
List<Secret> result = ex.getOut().getBody(List.class);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesConfigMapsProducerTest method listByLabelsTest.
@Test
public void listByLabelsTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:listConfigMapsByLabels", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
Map<String, String> labels = new HashMap<String, String>();
labels.put("component", "elasticsearch");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAPS_LABELS, labels);
}
});
List<ConfigMap> result = ex.getOut().getBody(List.class);
boolean configMapExists = false;
Iterator<ConfigMap> it = result.iterator();
while (it.hasNext()) {
ConfigMap cfMap = it.next();
if (cfMap.getMetadata().getLabels().containsValue("elasticsearch")) {
configMapExists = true;
}
}
assertFalse(configMapExists);
}
use of io.fabric8.insight.metrics.model.Result in project camel by apache.
the class KubernetesConfigMapsProducerTest method getConfigMapTest.
@Test
public void getConfigMapTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
Exchange ex = template.request("direct:getConfigMap", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, "default");
exchange.getIn().setHeader(KubernetesConstants.KUBERNETES_CONFIGMAP_NAME, "elasticsearch-7015o");
}
});
ConfigMap result = ex.getOut().getBody(ConfigMap.class);
assertNull(result);
}
use of io.fabric8.insight.metrics.model.Result in project carbon-apimgt by wso2.
the class KubernetesGatewayImpl method createDeploymentResource.
/**
* Create a deployment in cms
*
* @param deploymentTemplate Deployment template as a String
* @param deploymentName Name of the deployment
* @throws ContainerBasedGatewayException if failed to create a deployment
*/
private void createDeploymentResource(String deploymentTemplate, String deploymentName) throws ContainerBasedGatewayException {
HasMetadata resource = getResourcesFromTemplate(deploymentTemplate);
try {
if (resource instanceof Deployment) {
// check whether there are existing service already
if (client.extensions().deployments().inNamespace(namespace).withName(deploymentName).get() == null) {
log.debug("Deploying in CMS type: {} and the Deployment resource definition: {} ", cmsType, deploymentTemplate);
Deployment deployment = (Deployment) resource;
Deployment result = client.extensions().deployments().inNamespace(namespace).create(deployment);
log.info("Created Deployment : " + result.getMetadata().getName() + " in Namespace : " + result.getMetadata().getNamespace() + " in " + cmsType);
} else {
log.info("There exist a deployment with the same name in " + cmsType + ". Deployment name : " + deploymentName);
}
} else {
throw new ContainerBasedGatewayException("Loaded Resource is not a Deployment in " + cmsType + "! " + resource, ExceptionCodes.LOADED_RESOURCE_DEFINITION_IS_NOT_VALID);
}
} catch (KubernetesClientException e) {
throw new ContainerBasedGatewayException("Error while creating container based gateway deployment in " + cmsType + "!", e, ExceptionCodes.DEDICATED_CONTAINER_GATEWAY_CREATION_FAILED);
}
}
use of io.fabric8.insight.metrics.model.Result in project carbon-apimgt by wso2.
the class KubernetesGatewayImpl method createIngressResource.
/**
* Create an Ingress resource in cms
*
* @param ingressTemplate Ingress template as a String
* @param ingressName Name of the ingress
* @throws ContainerBasedGatewayException if failed to create a service
*/
private void createIngressResource(String ingressTemplate, String ingressName) throws ContainerBasedGatewayException {
HasMetadata resource = getResourcesFromTemplate(ingressTemplate);
try {
if (resource instanceof Ingress) {
// check whether there are existing service already
if (client.extensions().ingresses().inNamespace(namespace).withName(ingressName).get() == null) {
log.debug("Deploying in CMS type: {} and the Ingress resource definition: {} ", cmsType, ingressTemplate);
Ingress ingress = (Ingress) resource;
Ingress result = client.extensions().ingresses().inNamespace(namespace).create(ingress);
log.info("Created Ingress : " + result.getMetadata().getName() + " in Namespace : " + result.getMetadata().getNamespace() + " in " + cmsType);
} else {
log.info("There exist an ingress with the same name in " + cmsType + ". Ingress name : " + ingressName);
}
} else {
throw new ContainerBasedGatewayException("Loaded Resource is not a Service in " + cmsType + "! " + resource, ExceptionCodes.LOADED_RESOURCE_DEFINITION_IS_NOT_VALID);
}
} catch (KubernetesClientException e) {
throw new ContainerBasedGatewayException("Error while creating container based gateway ingress in " + cmsType + "!", e, ExceptionCodes.DEDICATED_CONTAINER_GATEWAY_CREATION_FAILED);
}
}
Aggregations