Search in sources :

Example 1 with MIRROR_IMAGE

use of com.bakdata.quick.manager.mirror.resources.MirrorResources.MIRROR_IMAGE in project quick by bakdata.

the class KubernetesMirrorService method deleteMirror.

@Override
public Completable deleteMirror(final String name) {
    final String deploymentName = MirrorResourceLoader.getDeploymentName(name);
    final ImageConfig imageConfig = ImageConfig.of(this.deploymentConfig.getDockerRegistry(), MIRROR_IMAGE, 1, this.deploymentConfig.getDefaultImageTag());
    // first extract info about mirror deployment
    // we need this to properly delete all kafka related resources like the internal state store topic
    final Single<Deployment> deployment = this.kubeClient.readDeployment(deploymentName);
    // as well as all kafka related resources
    final Completable kafkaCleanUp = deployment.map(d -> d.getSpec().getTemplate().getSpec().getContainers().get(0).getArgs()).map(list -> this.resources.createDeletionJob(deploymentName, imageConfig.asImageString(), list)).flatMapCompletable(this.kubeClient::deploy);
    final Completable resourceDeletion = Single.fromCallable(() -> this.loader.forDeletion(deploymentName)).flatMapCompletable(this.kubeClient::delete);
    return kafkaCleanUp.andThen(resourceDeletion);
}
Also used : ImageConfig(com.bakdata.quick.manager.k8s.ImageConfig) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) Environment(io.micronaut.context.env.Environment) ResourcePrefix(com.bakdata.quick.manager.k8s.resource.QuickResources.ResourcePrefix) KubernetesManagerClient(com.bakdata.quick.manager.k8s.KubernetesManagerClient) Completable(io.reactivex.Completable) KubernetesResources(com.bakdata.quick.manager.k8s.KubernetesResources) Singleton(javax.inject.Singleton) Single(io.reactivex.Single) MIRROR_IMAGE(com.bakdata.quick.manager.mirror.resources.MirrorResources.MIRROR_IMAGE) DeploymentConfig(com.bakdata.quick.manager.config.DeploymentConfig) Requires(io.micronaut.context.annotation.Requires) MirrorResourceLoader(com.bakdata.quick.manager.mirror.resources.MirrorResourceLoader) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ImageConfig(com.bakdata.quick.manager.k8s.ImageConfig) Completable(io.reactivex.Completable) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment)

Aggregations

MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)1 DeploymentConfig (com.bakdata.quick.manager.config.DeploymentConfig)1 ImageConfig (com.bakdata.quick.manager.k8s.ImageConfig)1 KubernetesManagerClient (com.bakdata.quick.manager.k8s.KubernetesManagerClient)1 KubernetesResources (com.bakdata.quick.manager.k8s.KubernetesResources)1 ResourcePrefix (com.bakdata.quick.manager.k8s.resource.QuickResources.ResourcePrefix)1 MirrorResourceLoader (com.bakdata.quick.manager.mirror.resources.MirrorResourceLoader)1 MIRROR_IMAGE (com.bakdata.quick.manager.mirror.resources.MirrorResources.MIRROR_IMAGE)1 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)1 Requires (io.micronaut.context.annotation.Requires)1 Environment (io.micronaut.context.env.Environment)1 Completable (io.reactivex.Completable)1 Single (io.reactivex.Single)1 Singleton (javax.inject.Singleton)1