There's a way to manage all your Kubernetes infrastructure with real Java code, typed, testable, and Git-versionable. Most Spring Boot teams still don't know the Pulumi Java SDK enables this. No 400-line YAML files. No "works on my machine." Real infrastructure as code.
Published three days ago, Pulumi's 2026 roadmap makes it clear: the YAML era is ending. In this article I'll show how a Java developer can replace Kubernetes YAML files with compiled Java code, with a full Spring Boot deployment example.
The Problem YAML Created in Kubernetes (That Nobody Talks About)
Have you ever opened your team's repository and found a k8s/ folder with 23 YAML files? Deployment, Service, Ingress, ConfigMap, Secret, HorizontalPodAutoscaler — each one with its own YAML. Multiply that by 5 microservices and you have over 100 files that nobody can guarantee are consistent with each other.
The problem is not YAML itself. The problem is that YAML is a configuration language, not a programming language. And when you use configuration to describe complex infrastructure, the limitations show up fast:
- No type safety: a wrong indentation destroys the file without warning. YAML accepts anything, compiles anything, and only breaks at runtime on the cluster
- No real reuse: need a shared variable between two YAML files? Good luck without Helm. And Helm is another language to learn
- No tests: there is no "run the unit test" for a YAML file before applying it to the cluster. You find the bug in production
- No IDE autocomplete: IntelliJ cannot tell the difference between a valid field and a non-existent field in the Kubernetes API
- Silent drift: someone ran
kubectl edit deployment/my-appdirectly on the cluster and nobody knows. The YAML in Git has been wrong for weeks
As a Tech Leader, I have seen entire teams spend hours debugging problems that a Java compiler would have caught in seconds. The broken YAML that went to production had no syntax errors. It was semantically wrong. And there was no way to detect it before applying.
There is a better way.
What Is Pulumi and Why Java Developers Should Pay Attention
Pulumi is an IaC (Infrastructure as Code) tool that lets you describe infrastructure using real programming languages: Python, TypeScript, Go, and, since 2021, Java. With official support for the Kubernetes Provider, the Pulumi Java SDK lets you write all your K8s infrastructure in Java, using the same tools you already use with Spring Boot.
Let me quickly compare it with the alternatives:
- Terraform/OpenTofu: uses HCL, another domain-specific language to learn. Robust state management, but still configuration, not programming
- AWS CDK: supports Java, but focused on AWS. Limited portability
- Helm: YAML templates with Go templating. Solves reuse but adds complexity through another abstraction layer
- Pulumi Java SDK: pure Java. Your IDE works. Your compiler works. Your JUnit tests work. Infrastructure is code like any other code in your team
The Pulumi Java SDK keeps the same state model as Terraform: it tracks what was created, what changed, and what needs to be destroyed. The difference lies in how you describe what you want to create.
In Practice: Setting Up Pulumi Java in Your Project
Before the code, the dependencies. In your pom.xml:
<dependencies>
<!-- Pulumi core SDK -->
<dependency>
<groupId>com.pulumi</groupId>
<artifactId>pulumi</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Pulumi Kubernetes Provider -->
<dependency>
<groupId>com.pulumi</groupId>
<artifactId>kubernetes</artifactId>
<version>4.18.0</version>
</dependency>
</dependencies>
And in Pulumi.yaml at the root of your infra project:
name: my-spring-infra
runtime: java
description: MeuApp Spring Boot infrastructure on Kubernetes
That is it. From here on, everything is Java.
The Complete Spring Boot Deployment With Pulumi Java
Let me show what a real deployment looks like. The equivalent of the YAML you know, written in Java:
import com.pulumi.Pulumi;
import com.pulumi.kubernetes.apps.v1.Deployment;
import com.pulumi.kubernetes.apps.v1.DeploymentArgs;
import com.pulumi.kubernetes.core.v1.Service;
import com.pulumi.kubernetes.core.v1.ServiceArgs;
import com.pulumi.kubernetes.meta.v1.inputs.ObjectMetaArgs;
import java.util.Map;
public class InfraApp {
public static void main(String[] args) {
Pulumi.run(ctx -> {
var appLabels = Map.of("app", "my-spring-app");
// Deployment with 3 replicas for high availability
var deployment = new Deployment("spring-boot-deployment",
DeploymentArgs.builder()
.metadata(ObjectMetaArgs.builder()
.name("my-spring-app")
.labels(appLabels)
.build())
.spec(DeploymentSpecArgs.builder()
.replicas(3)
.selector(LabelSelectorArgs.builder()
.matchLabels(appLabels)
.build())
.template(PodTemplateSpecArgs.builder()
.metadata(ObjectMetaArgs.builder()
.labels(appLabels)
.build())
.spec(PodSpecArgs.builder()
.containers(ContainerArgs.builder()
.name("spring-app")
.image("my-company/my-spring-app:latest")
.ports(ContainerPortArgs.builder()
.containerPort(8080)
.build())
.env(
EnvVarArgs.builder()
.name("SPRING_PROFILES_ACTIVE")
.value("prod")
.build(),
EnvVarArgs.builder()
.name("DB_HOST")
.value("postgres-svc:5432")
.build()
)
.resources(ResourceRequirementsArgs.builder()
.requests(Map.of(
"cpu", "250m",
"memory", "512Mi"
))
.limits(Map.of(
"cpu", "500m",
"memory", "1Gi"
))
.build())
.build())
.build())
.build())
.build())
.build()
);
// LoadBalancer Service to expose on port 80
var service = new Service("spring-boot-svc",
ServiceArgs.builder()
.metadata(ObjectMetaArgs.builder()
.name("my-spring-app-svc")
.build())
.spec(ServiceSpecArgs.builder()
.selector(appLabels)
.type("LoadBalancer")
.ports(ServicePortArgs.builder()
.port(80)
.targetPort(8080)
.build())
.build())
.build()
);
// Export IP for smoke tests in CI pipeline
ctx.export("serviceEndpoint",
service.status().applyValue(s ->
s.get().loadBalancer().get()
.ingress().get(0).ip().get()
)
);
});
}
}
Here is what happens when you run pulumi up:
Updating (prod):
Type Name Status
+ pulumi:pulumi:Stack my-spring-infra-prod created
+ ├─ kubernetes:apps/v1:Deployment spring-boot-deployment created
+ └─ kubernetes:core/v1:Service spring-boot-svc created
Outputs:
serviceEndpoint: "34.95.112.43"
Resources:
+ 3 created
Duration: 28s
The LoadBalancer IP comes out directly as output. You can grab that value in your CI/CD to run smoke tests right after the deploy. No need for a shell script doing kubectl get svc -o jsonpath. Clean, right?
Testing Infrastructure Like Production Code
This is where things get interesting. With YAML, there is no way to test before applying. With Pulumi Java, you test with JUnit like any other code:
import org.junit.jupiter.api.Test;
import com.pulumi.test.Mocks;
import com.pulumi.test.TestOptions;
import static org.assertj.core.api.Assertions.*;
class InfraTest {
@Test
void deploymentShouldHaveThreeReplicas() throws Exception {
var resources = Mocks.withMocks(
new TestOptions().setIsPreview(false),
() -> {
InfraApp.main(new String[]{});
return List.of();
}
);
var deployment = resources.stream()
.filter(r -> r instanceof Deployment)
.map(r -> (Deployment) r)
.findFirst().orElseThrow();
// Ensure replicas never accidentally drop to 1
deployment.spec().applyValue(spec -> {
assertThat(spec.get().replicas().get()).isEqualTo(3);
return null;
});
}
@Test
void serviceMustExposePort80AndRedirectTo8080() throws Exception {
var resources = Mocks.withMocks(
new TestOptions().setIsPreview(false),
() -> {
InfraApp.main(new String[]{});
return List.of();
}
);
var svc = resources.stream()
.filter(r -> r instanceof Service)
.map(r -> (Service) r)
.findFirst().orElseThrow();
svc.spec().applyValue(spec -> {
var port = spec.get().ports().get().get(0);
assertThat(port.port()).isEqualTo(80);
return null;
});
}
}
This runs with mvn test without needing a Kubernetes cluster or kubectl installed. Pulumi spins up internal mocks that simulate the cloud provider state.
Think of the analogy: it is like having a contract test for your infrastructure. The same way you test whether a REST endpoint returns 200, you now test whether the deployment has 3 replicas and whether the Service is on the right port. Before any pulumi up.
In a company where I worked as Tech Leader, the biggest source of production incidents was not code bugs. It was configuration drift: someone had edited the Deployment directly on the cluster and Git was out of date. With Pulumi, pulumi refresh itself detects that drift and the CI test fails before you push something inconsistent.
Spring Boot Integration: Configuring via ConfigMap
A common question: how do you inject application.properties settings from Spring Boot via Pulumi? You use a ConfigMap:
import com.pulumi.kubernetes.core.v1.ConfigMap;
import com.pulumi.kubernetes.core.v1.ConfigMapArgs;
// Inside Pulumi.run():
var appConfig = new ConfigMap("spring-config",
ConfigMapArgs.builder()
.metadata(ObjectMetaArgs.builder()
.name("spring-app-config")
.build())
.data(Map.of(
"SPRING_DATASOURCE_URL", "jdbc:postgresql://postgres-svc:5432/mydb",
"SPRING_JPA_HIBERNATE_DDL_AUTO", "validate",
"LOGGING_LEVEL_ROOT", "INFO",
"MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE", "health,metrics,prometheus"
))
.build()
);
// Reference the ConfigMap in container env vars
EnvVarArgs.builder()
.name("SPRING_DATASOURCE_URL")
.valueFrom(EnvVarSourceArgs.builder()
.configMapKeyRef(ConfigMapKeySelectorArgs.builder()
.name(appConfig.metadata().applyValue(m -> m.get().name().get()))
.key("SPRING_DATASOURCE_URL")
.build())
.build())
.build()
The benefit here is that name(appConfig.metadata()...) creates a typed reference between the ConfigMap and the Deployment. If you rename the ConfigMap, the compiler breaks before you ever reach the cluster. With YAML, that kind of refactoring silently creates an invalid config that only explodes at runtime.
For more on configuring Spring Boot with environment variables in production, see the article on ConfigMaps and Secrets in Spring Boot with Kubernetes. And if you want to understand how observability fits into this stack, see Spring Boot Actuator with OpenTelemetry in Production.
What Changes in the Team's Day-to-Day
After migrating the infrastructure of a Spring Boot microservice from pure YAML to Pulumi Java in a real project, these were the practical gains:
- Onboarding new devs: went from "3 days to understand the 23 YAMLs" to "open the Maven project in IntelliJ, follow the code." The IDE helps. The familiar Java documentation helps
- Infra refactoring: changing a label name across 15 YAMLs became an IntelliJ Rename. Everything updates together, the compiler confirms
- PR review: Java code diff shows intent. YAML diff shows indentation
- Drift detection:
pulumi refreshin the pipeline detects any manual change to the cluster
To learn how to connect pulumi up to your CI/CD, check out the article on Kubernetes Deploy with Azure DevOps and Pulumi Java.
When Pulumi is the right choice:
- Java teams that need IaC but do not want to learn HCL or Go
- Projects with complex conditional logic in infrastructure (e.g., creating different infra per environment)
- Teams that already have a test pipeline and want to cover infrastructure too
When sticking with pure YAML may make sense:
- Very simple infra (1 deployment, 1 service) that rarely changes
- Teams without a programming background that maintain infrastructure separately from the development team
- Projects that need to be portable to teams that do not have Java installed
Frequently Asked Questions
Do I need to know Kubernetes to use Pulumi Java?
You need to understand the basic concepts: Deployment, Service, Pod, ConfigMap. Pulumi does not abstract Kubernetes, it only changes the language you use to describe those resources. If you already understand what a Deployment does, you will be fine with the Pulumi Java SDK. The official docs help a lot with that initial transition.
Does Pulumi work with AWS and Azure, not just K8s?
Yes. Pulumi has providers for AWS, Azure, GCP, Cloudflare, and dozens of others. The Java SDK works with all of them. You can create an S3 bucket, configure an ECS service, and deploy to Kubernetes all in the same Java program. That is a major advantage over K8s-only tools.
Can I migrate my existing YAML infra to Pulumi without starting from scratch?
There is pulumi convert --from kubernetes that attempts to convert existing YAMLs into Pulumi code. The result is not perfect but it serves as a starting point. For larger infra setups, the safest path is to import existing resources with pulumi import and let Pulumi take over management gradually, service by service.
Is Pulumi open source or paid?
The Pulumi core is open source (Apache 2.0). Pulumi Cloud (managed state backend) has a free plan for individual use and small teams. You can use an alternative backend such as S3 or Azure Blob Storage if you do not want Pulumi Cloud. For most small teams, the free plan is enough to get started.
Key Takeaways
- YAML sprawl is a real problem that grows with the team and the number of services. Without type safety, without tests, without IDE support, infrastructure becomes a black box
- Pulumi Java SDK lets you describe all K8s infrastructure in compiled Java, testable with JUnit and refactorable with IntelliJ
- The learning curve is low for those who already know Spring Boot and K8s. You use what you already know
Are you already using IaC in your Spring Boot project? Are you on pure YAML, Helm, or have you already migrated to Pulumi? Share in the comments how it is going in practice. I want to hear about the biggest infrastructure challenges your team faces.
Next week I will show how to set up Pulumi with GitOps: triggering pulumi up automatically via ArgoCD when a PR is merged. Infrastructure becomes a first-class citizen in your deploy workflow.