Kubernetes runs container images, scales containers up or down, and replaces broken ones. For a Spring Boot application headed to a Kubernetes environment, build a container image rather than a traditional server-oriented WAR file. You need a Kubernetes cluster, whether hosted or local, before deploying it. section 18.1 section 18.3.1
apiVersion: apps/v1
kind: Deployment
metadata:
name: taco-cloud-deploy
labels:
app: taco-cloud
spec:
replicas: 3
selector:
matchLabels:
app: taco-cloud
template:
metadata:
labels:
app: taco-cloud
spec:
containers:
- name: taco-cloud-container
image: tacocloud/tacocloud:latest
A deployment manifest is a YAML file describing what to run. This example names the deployment, selects the taco-cloud image, and requests three replicas. Save it as deploy.yaml; then run kubectl apply -f deploy.yaml to submit it to the cluster. section 18.3.1
Check the result with kubectl get all. In the example output, three pods are Running and the deployment reports 3/3 available. For a quick local connection to one pod, kubectl port-forward pod/taco-cloud-deploy-555bd8fdb4-dln45 8080:8080. section 18.3.1
A running application may still be unable to serve requests. Kubernetes uses separate probes for these cases: liveness asks whether to restart a pod; readiness asks whether to send it traffic. During initialization, an application can remain alive but report that it is not ready. section 18.3.3
management:
health:
probes:
enabled: true
Enable Spring Boot Actuator’s liveness and readiness health groups with this application.yml setting. section 18.3.3
apiVersion: apps/v1
kind: Deployment
metadata:
name: taco-cloud-deploy
labels:
app: taco-cloud
spec:
replicas: 3
selector:
matchLabels:
app: taco-cloud
template:
metadata:
labels:
app: taco-cloud
spec:
containers:
- name: taco-cloud-container
image: tacocloud/tacocloud:latest
livenessProbe:
initialDelaySeconds: 2
periodSeconds: 5
httpGet:
path: /actuator/health/liveness
port: 8080
readinessProbe:
initialDelaySeconds: 2
periodSeconds: 5
httpGet:
path: /actuator/health/readiness
port: 8080
Add these HTTP probes to the deployment manifest so Kubernetes checks /actuator/health/liveness and /actuator/health/readiness on port 8080. Both checks start after two seconds and repeat every five seconds. section 18.3.3





















