Code review comment: Yeah, I agree. It may have some thread-safe problem. I will update this part.

Code under review:
public CompletableFuture<Void> createTaskManagerPod(KubernetesPod kubernetesPod) {
        if (masterDeployment == null) {
            masterDeployment =
                    this.internalClient
                            .apps()
                            .deployments()
                            .withName(KubernetesUtils.getDeploymentName(clusterId))
                            .get();
        }
        return CompletableFuture.runAsync(
                () -> {
                    if (masterDeployment == null) {
                        throw new RuntimeException(
                                "Failed to find Deployment named "
                                        + clusterId
                                        + " in namespace "
                                        + this.namespace);
                    }

                    
                    
                    setOwnerReference(
                            masterDeployment,
                            Collections.singletonList(kubernetesPod.getInternalResource()));

                    LOG.debug(
                            "Start to create pod with spec {}{}",
                            System.lineSeparator(),
                            KubernetesUtils.tryToGetPrettyPrintYaml(
                                    kubernetesPod.getInternalResource()));

                    this.internalClient.pods().create(kubernetesPod.getInternalResource());
                },
                kubeClientExecutorService);
    }

Line commented on: if (masterDeployment == null) {

Revised code:
public CompletableFuture<Void> createTaskManagerPod(KubernetesPod kubernetesPod) {
        return CompletableFuture.runAsync(
                () -> {
                    if (masterDeploymentRef.get() == null) {
                        final Deployment masterDeployment =
                                this.internalClient
                                        .apps()
                                        .deployments()
                                        .withName(KubernetesUtils.getDeploymentName(clusterId))
                                        .get();
                        if (masterDeployment == null) {
                            throw new RuntimeException(
                                    "Failed to find Deployment named "
                                            + clusterId
                                            + " in namespace "
                                            + this.namespace);
                        }
                        masterDeploymentRef.compareAndSet(null, masterDeployment);
                    }

                    
                    
                    setOwnerReference(
                            checkNotNull(masterDeploymentRef.get()),
                            Collections.singletonList(kubernetesPod.getInternalResource()));

                    LOG.debug(
                            "Start to create pod with spec {}{}",
                            System.lineSeparator(),
                            KubernetesUtils.tryToGetPrettyPrintYaml(
                                    kubernetesPod.getInternalResource()));

                    this.internalClient.pods().create(kubernetesPod.getInternalResource());
                },
                kubeClientExecutorService);
    }