use of io.fabric8.kubernetes.api.model.extensions.Deployment in project carbon-apimgt by wso2.
the class KubernetesGatewayImpl method removeContainerBasedGateway.
/**
* @see ContainerBasedGatewayGenerator#removeContainerBasedGateway(String, API) (String)
*/
@Override
public void removeContainerBasedGateway(String label, API api) throws ContainerBasedGatewayException {
try {
client.services().inNamespace(namespace).withLabel(ContainerBasedGatewayConstants.GATEWAY, label).delete();
client.extensions().deployments().inNamespace(namespace).withLabel(ContainerBasedGatewayConstants.GATEWAY, label).delete();
client.extensions().ingresses().inNamespace(namespace).withLabel(ContainerBasedGatewayConstants.GATEWAY, label).delete();
log.info(String.format("Completed deleting the container gateway related %s deployment, service and " + "ingress resources.", cmsType));
} catch (KubernetesClientException e) {
throw new ContainerBasedGatewayException("Error while removing container based gateway", e, ExceptionCodes.CONTAINER_GATEWAY_REMOVAL_FAILED);
}
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project carbon-apimgt by wso2.
the class KubernetesGatewayImplTestCase method testCreateContainerGateway.
@Test
public void testCreateContainerGateway() throws Exception {
OpenShiftClient openShiftClient = Mockito.mock(OpenShiftClient.class, Mockito.RETURNS_DEEP_STUBS);
KubernetesGatewayImpl kubernetesGateway = getKubernetesGatewayImpl(openShiftClient);
Mockito.when(openShiftClient.load(Mockito.any()).get()).thenReturn(getServiceResources(), getDeploymentResources(), getIngressResources());
NonNamespaceOperation nonNamespaceOperation = Mockito.mock(NonNamespaceOperation.class);
ScalableResource scalableResource = Mockito.mock(ScalableResource.class);
Mockito.when(scalableResource.get()).thenReturn(null);
Service service = createService(openShiftClient, nonNamespaceOperation);
Deployment deployment = createDeployment(openShiftClient, nonNamespaceOperation, scalableResource);
Ingress ingress = createIngress(openShiftClient, nonNamespaceOperation, scalableResource);
Mockito.when(nonNamespaceOperation.create(Mockito.any())).thenReturn(service, deployment, ingress);
API api = SampleTestObjectCreator.createDefaultAPI().build();
kubernetesGateway.createContainerGateway(ContainerBasedGatewayConstants.PRIVATE_JET_API_PREFIX + LABEL_SUFFIX, api);
Mockito.verify(openShiftClient, Mockito.times(4)).load(Mockito.any());
Mockito.verify(openShiftClient, Mockito.times(3)).services();
Mockito.verify(openShiftClient, Mockito.times(6)).extensions();
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project vertx-openshift-it by cescoffier.
the class ConfigurationIT method deployApp.
private static String deployApp(String name, String templatePath) throws IOException {
String appName;
List<? extends HasMetadata> entities = deploymentAssistant.deploy(name, new File(templatePath));
Optional<String> first = entities.stream().filter(hm -> hm instanceof DeploymentConfig).map(hm -> (DeploymentConfig) hm).map(dc -> dc.getMetadata().getName()).findFirst();
if (first.isPresent()) {
appName = first.get();
} else {
throw new IllegalStateException("Application deployment config not found");
}
Route route = deploymentAssistant.getRoute(appName);
assertThat(route).isNotNull();
return "http://" + route.getSpec().getHost();
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project vertx-openshift-it by cescoffier.
the class HealthCheckIT method getContainers.
private List<Container> getContainers() {
DeploymentConfig dc = client.deploymentConfigs().withName(deploymentAssistant.applicationName()).get();
ensureThat("the deployment config " + deploymentAssistant.applicationName() + " exists", () -> assertThat(dc).isNotNull());
return dc.getSpec().getTemplate().getSpec().getContainers();
}
use of io.fabric8.kubernetes.api.model.extensions.Deployment in project vertx-openshift-it by cescoffier.
the class CircuitBreakerIT method deployApp.
/**
* @param name
* @param templatePath
* @return the app route
* @throws IOException
*/
private static String deployApp(String name, String templatePath) throws IOException {
String appName = "";
List<? extends HasMetadata> entities = OPENSHIFT.deploy(name, new File(templatePath));
Optional<String> first = entities.stream().filter(hm -> hm instanceof DeploymentConfig).map(hm -> (DeploymentConfig) hm).map(dc -> dc.getMetadata().getName()).findFirst();
if (first.isPresent()) {
appName = first.get();
} else {
throw new IllegalStateException("Application deployment config not found");
}
Route route = OPENSHIFT.client().routes().inNamespace(OPENSHIFT.project()).withName(appName).get();
assertThat(route).isNotNull();
return "http://" + route.getSpec().getHost();
}
Aggregations