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);
}
Aggregations