The 30 second answer
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.
A Pod runs one or more containers that share a network namespace. You rarely create Pods by hand. A Deployment declares a replica count and a pod template, and it performs rolling updates. A Service selects those pods and gives them a stable virtual IP and DNS name. A ConfigMap holds non-secret settings; a Secret holds credentials.
apiVersion: apps/v1
kind: Deployment
metadata:
name: orders
spec:
replicas: 2
selector:
matchLabels:
app: orders
template:
metadata:
labels:
app: orders
spec:
containers:
- name: orders
image: example/orders:1.0.0
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: orders-config
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
---
apiVersion: v1
kind: Service
metadata:
name: orders
spec:
selector:
app: orders
ports:
- port: 80
targetPort: 8080Readiness controls whether the Service sends traffic. Liveness controls whether Kubernetes restarts the container. They should not be the same check if startup is slow; Spring Boot Actuator has separate readiness and liveness groups for this.
Alternate interview scenarios
"How do you handle secrets management (Vault, K8s secrets)?"
I do not bake secrets into the image. In Kubernetes, a ConfigMap holds non-secret settings and a Secret holds credentials; both can be mounted as environment variables or files. A dedicated tool such as Vault is a way to issue short-lived credentials, and I still mount the result as a Secret or a file.
spec:
containers:
- envFrom:
- configMapRef: { name: orders-config }
- secretRef: { name: orders-db }I keep the Secret out of git, and I do not log it. ConfigMaps are fine for a feature flag; a database password is not.
"How do you deploy Spring Boot apps on Kubernetes?"
I build a container image, then run it as a Deployment (replicas, rolling update) and expose it with a Service. Configuration comes from ConfigMaps and Secrets. Probes should hit Actuator's readiness and liveness endpoints so Kubernetes does not send traffic to a pod that is still starting.
apiVersion: apps/v1
kind: Deployment
metadata: { name: orders }
spec:
replicas: 2
selector: { matchLabels: { app: orders } }
template:
metadata: { labels: { app: orders } }
spec:
containers:
- name: orders
image: example/orders:1.0.0
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }A Service selects app: orders and gives the pods a stable DNS name. That is the usual "deploy Spring Boot on Kubernetes" answer; Helm or an operator can wrap the same objects.
"How do you handle configuration in K8s (ConfigMaps, Secrets)?"
A ConfigMap is for non-secret configuration; a Secret is for credentials. I inject them as environment variables (envFrom) or as files, and I read them in Spring as ordinary properties (SPRING_DATASOURCE_PASSWORD, or a mounted application.properties).
apiVersion: v1
kind: ConfigMap
metadata: { name: orders-config }
data:
SPRING_PROFILES_ACTIVE: "prod"
---
apiVersion: v1
kind: Secret
metadata: { name: orders-db }
type: Opaque
stringData:
SPRING_DATASOURCE_PASSWORD: "set-from-the-platform"The password value here is a placeholder, not a real credential. I do not commit a live Secret. Spring Boot relaxed binding will map SPRING_DATASOURCE_PASSWORD to spring.datasource.password.
"How do you implement health checks in K8s?"
In Kubernetes, readiness controls whether the Service sends traffic, and liveness controls whether the kubelet restarts the container. For Spring Boot I point them at Actuator's /actuator/health/readiness and /actuator/health/liveness, not at the same generic /actuator/health if startup is slow.
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }
livenessProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
initialDelaySeconds: 30A failing readiness probe takes the pod out of the Service. A failing liveness probe restarts it. I do not put a dependency check on liveness if I only want to stop receiving traffic when the database is down.
Sources (4)
- Kubernetes: Podskubernetes.io
- Kubernetes: Deploymentskubernetes.io
- Kubernetes: Serviceskubernetes.io
- Spring Boot: Kubernetes probesdocs.spring.io