use of com.bakdata.quick.manager.k8s.ImageConfig 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);
}
use of com.bakdata.quick.manager.k8s.ImageConfig in project quick by bakdata.
the class MirrorResourceLoader method forCreation.
/**
* Creates resources that can be deployed.
*
* <p>
* This function creates all the Kubernetes resources that a mirror needs for its deployment. Deployment and Service
* templates are filled with the data passed.
*/
@Override
public MirrorResources forCreation(final MirrorCreationData mirrorCreationData, final ResourcePrefix prefix) {
final String mirrorName = mirrorCreationData.getName();
final String deploymentName = prefix.getPrefix() + mirrorName;
final String imageTag = Objects.requireNonNullElse(mirrorCreationData.getTag(), this.deploymentConfig.getDefaultImageTag());
final int imageReplicas = Objects.requireNonNullElse(mirrorCreationData.getReplicas(), this.deploymentConfig.getDefaultReplicas());
final ImageConfig config = ImageConfig.of(this.deploymentConfig.getDockerRegistry(), MIRROR_IMAGE, imageReplicas, imageTag);
final boolean hasFixedTag = mirrorCreationData.getTag() != null;
final List<String> arguments = CliArgHandler.convertArgs(createArgs(mirrorCreationData.getTopicName(), mirrorCreationData.getRetentionTime()));
final MirrorDeployment deployment = new MirrorDeployment(this.createMirrorDeployment(deploymentName, arguments, config, this.resourceConfig, hasFixedTag));
final MirrorService service = new MirrorService(this.createMirrorService(deploymentName));
return new MirrorResources(mirrorName, deployment, service);
}
Aggregations