Search in sources :

Example 91 with Deployment

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);
    }
}
Also used : ContainerBasedGatewayException(org.wso2.carbon.apimgt.core.exception.ContainerBasedGatewayException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Example 92 with Deployment

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();
}
Also used : ScalableResource(io.fabric8.kubernetes.client.dsl.ScalableResource) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Service(io.fabric8.kubernetes.api.model.Service) Deployment(io.fabric8.kubernetes.api.model.extensions.Deployment) Ingress(io.fabric8.kubernetes.api.model.extensions.Ingress) API(org.wso2.carbon.apimgt.core.models.API) NonNamespaceOperation(io.fabric8.kubernetes.client.dsl.NonNamespaceOperation) Test(org.junit.Test)

Example 93 with Deployment

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();
}
Also used : BeforeClass(org.junit.BeforeClass) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) URISyntaxException(java.net.URISyntaxException) OC(io.vertx.it.openshift.utils.OC) JsonPath(io.restassured.path.json.JsonPath) Route(io.fabric8.openshift.api.model.Route) AbstractTestClass(io.vertx.it.openshift.utils.AbstractTestClass) Map(java.util.Map) RestAssured.get(io.restassured.RestAssured.get) Awaitility.await(org.awaitility.Awaitility.await) AfterClass(org.junit.AfterClass) ImmutableMap(com.google.common.collect.ImmutableMap) Pod(io.fabric8.kubernetes.api.model.Pod) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Test(org.junit.Test) IOException(java.io.IOException) DoneableConfigMap(io.fabric8.kubernetes.api.model.DoneableConfigMap) Collectors(java.util.stream.Collectors) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) File(java.io.File) Ensure.ensureThat(io.vertx.it.openshift.utils.Ensure.ensureThat) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Optional(java.util.Optional) RestAssured(io.restassured.RestAssured) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) File(java.io.File) Route(io.fabric8.openshift.api.model.Route)

Example 94 with Deployment

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();
}
Also used : DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig)

Example 95 with Deployment

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();
}
Also used : CircuitBreakerState(io.vertx.circuitbreaker.CircuitBreakerState) Awaitility.await(org.awaitility.Awaitility.await) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) Pod(io.fabric8.kubernetes.api.model.Pod) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) File(java.io.File) OpenShiftTestAssistant(io.vertx.it.openshift.utils.OpenShiftTestAssistant) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Route(io.fabric8.openshift.api.model.Route) Response(io.restassured.response.Response) Optional(java.util.Optional) JsonObject(io.vertx.core.json.JsonObject) RestAssured.get(io.restassured.RestAssured.get) RestAssured(io.restassured.RestAssured) Before(org.junit.Before) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) File(java.io.File) Route(io.fabric8.openshift.api.model.Route)

Aggregations

Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)52 Test (org.junit.Test)28 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)27 InputStream (java.io.InputStream)26 Service (io.fabric8.kubernetes.api.model.Service)24 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)22 Deployment (org.jboss.arquillian.container.test.api.Deployment)21 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)21 Asset (org.jboss.shrinkwrap.api.asset.Asset)21 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)21 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 CommandSupport (io.fabric8.itests.support.CommandSupport)18 Logger (org.slf4j.Logger)18 Pod (io.fabric8.kubernetes.api.model.Pod)17 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)17 IOException (java.io.IOException)17 FabricService (io.fabric8.api.FabricService)16 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)16 ArrayList (java.util.ArrayList)16 StartLevelAware (org.jboss.arquillian.osgi.StartLevelAware)16