Java build and deploy interview questions
Maven versus Gradle, a Spring Boot Dockerfile, and Kubernetes Pods, Services and Deployments, from official Maven, Spring Boot and Kubernetes docs.
- 01Build and container3 questions
- 02CI and delivery4 questions
- 03Kubernetes and cloud-native5 questions
Build and container
1.1 What is the difference between Maven and Gradle? Easy 1 min
Both build and test a Java project and resolve dependencies. Maven uses a declarative pom.xml with a fixed lifecycle such as compile, test and package. Gradle uses a Gradle build script, is incremental by default, and often faster on repeat builds. The output is still a jar or a Spring Boot executable jar. I can explain a pom or a build.gradle if that is what the team uses.
Read the full answer1.2 How do you containerize a Spring Boot app with Docker? Medium 2 min
I build an executable jar, then a Docker image whose runtime is a JRE and a process that runs that jar. A multi-stage Dockerfile compiles in a JDK image and copies only the jar into a slimmer runtime image. Spring Boot also documents layered jars and Buildpacks, which can produce the image without a hand-written Dockerfile.
Read the full answer1.3 What are Kubernetes Pods, Services and Deployments, and how do you configure a Spring Boot app? Medium 4 min
A Pod is the smallest deployable unit, usually one container. A Deployment keeps a stated number of Pod replicas and rolls them out. A Service gives those Pods a stable DNS name and load-balances to them. Config and secrets come from ConfigMaps and Secrets, mounted as env vars or files, not baked into the image. Liveness and readiness probes should hit Actuator health endpoints.
Read the full answer
CI and delivery
2.1 How do you implement database migrations with Flyway or Liquibase? Medium 2 min
I keep schema changes as versioned files in the repo and let Flyway or Liquibase apply the ones that have not yet run, on startup or in CI, against a history table. Each script has a unique version, I never edit a migration that has already been applied in any environment, and I write backwards-compatible changes so a rolling deploy does not break old app instances. Spring Boot auto-configures both when the dependency and locations are present.
Read the full answer2.2 How do you create a Jenkins pipeline for a Java application? Medium 2 min
I put a Jenkinsfile in the repo and use a Pipeline that checks out the code, sets up the JDK, runs the Maven or Gradle build and tests, publishes the artifact, and only then builds and pushes a container image. Stages are explicit, test failures fail the pipeline, and I keep credentials in Jenkins credentials, not in the Jenkinsfile. A Declarative Pipeline is the form I would write first because it is easier to read and to review.
Read the full answer2.3 What is infrastructure as code, and what are Terraform basics? Medium 2 min
Infrastructure as code means the network, clusters and managed services are declared in files, reviewed and applied, instead of clicked in a console. Terraform is a common tool for that: I write .tf files, terraform plan shows the diff against state, and terraform apply makes the change. State records what Terraform already created, so it must be stored remotely and locked. I keep secrets out of state when I can, and I split stacks so a typo in one file does not recreate the database.
Read the full answer2.4 What is the difference between continuous integration and continuous deployment? Medium 2 min
Continuous integration means every change is merged into a shared branch frequently and automatically built and tested, so integration problems show up in minutes. Continuous delivery means that passing build is always in a releasable state. Continuous deployment goes one step further and automatically puts every passing change into production. I would not turn on continuous deployment without tests, observability and a fast rollback; many teams practise CI and continuous delivery with a manual production approve.
Read the full answer
Kubernetes and cloud-native
3.1 What is a sidecar container, and when do you use one? Medium 2 min
A sidecar is a helper container in the same Kubernetes Pod as the application container. It shares the network namespace (and often volumes) with the app, so it can proxy traffic, ship logs, or rotate certificates without the application embedding that code. I use one when the helper must be scheduled and scaled with the app process; I do not use one for a service that should scale independently.
Read the full answer3.2 What is a service mesh, and what are Istio basics? Hard 2 min
A service mesh is an infrastructure layer that takes over service-to-service traffic: typically a proxy sidecar next to each instance, plus a control plane that pushes policy. Istio's data plane is Envoy; the control plane issues certificates, routes and authorization policy. I use it when I need fleet-wide mTLS, consistent retries and timeouts, or L7 traffic shifting, without putting that logic in every application. It is not a substitute for application authorization or a good API design.
Read the full answer3.3 How do you implement autoscaling in Kubernetes? Medium 2 min
The usual mechanism is the HorizontalPodAutoscaler: I set a minimum and maximum replica count and a target such as CPU utilisation or a custom metric, and the HPA controller adds or removes Pods in the Deployment. I also size requests and limits honestly, because the HPA compares usage to requests. Vertical scaling and cluster autoscaling are different knobs: they change Pod resources or Node count, not the replica count of my app.
Read the full answer3.4 What is an Ingress controller? Medium 2 min
Ingress is a Kubernetes API that describes HTTP (and HTTPS) routing from outside the cluster to Services: host, path, and TLS. An Ingress controller is the software that reads those objects and actually programmes a load balancer or reverse proxy (NGINX, Envoy, a cloud LB). The Ingress object does nothing on its own if no controller is running. Gateway API is the newer, more expressive successor, but Ingress is still what many interviews and clusters use.
Read the full answer3.5 What is Helm, and how do charts work? Medium 2 min
Helm is a package manager for Kubernetes: a chart is a set of templates plus a values file that render into ordinary YAML manifests. helm install (or upgrade) applies the release, records revision history, and can roll back. I use a chart when I need the same Deployment, Service and config in several environments, with only values changing. I still have to understand the rendered YAML; Helm does not remove that responsibility.
Read the full answer