Why does my Kubernetes pod enter a CrashLoopBackOff state when using Liveness and Readiness Probes together?

I’m new to Kubernetes (K8S) and trying to learn how to achieve zero downtime during deployments. I have two services: currency-exchange and currency-conversion, where currency-conversion depends on currency-exchange.

When I deploy a new version of currency-exchange, the old pod stops immediately, causing an internal server error since the new pod isn’t ready yet. To prevent this, I added Readiness and Liveness probes to the deployment YAML so that Kubernetes checks the pod’s health before terminating the old one. My understanding is that this should help maintain zero downtime.

The Issue: When I add both the Liveness and Readiness probes, the new pod fails to start correctly and enters a CrashLoopBackOff state after multiple restarts.

this is my deployment.yaml

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
labels:
app: currency-exchange
name: currency-exchange
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: currency-exchange
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: currency-exchange
spec:
containers:
- image: username_24/currency-exchange-service:0.0.11-SNAPSHOT
imagePullPolicy: IfNotPresent
name: mmv2-currency-exchange-service
readinessProbe:
httpGet:
port: 8000
path: /actuator/health/readiness
livenessProbe:
httpGet:
port: 8000
path: /actuator/health/liveness
resources:
limits:
cpu: 500m
ephemeral-storage: 1Gi
memory: 2Gi
requests:
cpu: 500m
ephemeral-storage: 1Gi
memory: 2Gi
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
labels:
app: currency-exchange
name: currency-exchange
namespace: default
spec:
ports:
- port: 8000
protocol: TCP
targetPort: 8000
selector:
app: currency-exchange
sessionAffinity: None
type: LoadBalancer
</code>
<code>apiVersion: apps/v1 kind: Deployment metadata: annotations: deployment.kubernetes.io/revision: "1" labels: app: currency-exchange name: currency-exchange namespace: default spec: replicas: 1 selector: matchLabels: app: currency-exchange strategy: rollingUpdate: maxSurge: 25% maxUnavailable: 25% type: RollingUpdate template: metadata: labels: app: currency-exchange spec: containers: - image: username_24/currency-exchange-service:0.0.11-SNAPSHOT imagePullPolicy: IfNotPresent name: mmv2-currency-exchange-service readinessProbe: httpGet: port: 8000 path: /actuator/health/readiness livenessProbe: httpGet: port: 8000 path: /actuator/health/liveness resources: limits: cpu: 500m ephemeral-storage: 1Gi memory: 2Gi requests: cpu: 500m ephemeral-storage: 1Gi memory: 2Gi restartPolicy: Always --- apiVersion: v1 kind: Service metadata: labels: app: currency-exchange name: currency-exchange namespace: default spec: ports: - port: 8000 protocol: TCP targetPort: 8000 selector: app: currency-exchange sessionAffinity: None type: LoadBalancer </code>
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  labels:
    app: currency-exchange
  name: currency-exchange
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app: currency-exchange
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: currency-exchange
    spec:
      containers:
        - image: username_24/currency-exchange-service:0.0.11-SNAPSHOT
          imagePullPolicy: IfNotPresent
          name: mmv2-currency-exchange-service
          readinessProbe:
            httpGet:
              port: 8000
              path: /actuator/health/readiness
          livenessProbe:
            httpGet:
              port: 8000
              path: /actuator/health/liveness
          resources:
            limits:
              cpu: 500m
              ephemeral-storage: 1Gi
              memory: 2Gi
            requests:
              cpu: 500m
              ephemeral-storage: 1Gi
              memory: 2Gi
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: currency-exchange
  name: currency-exchange
  namespace: default
spec:
  ports:
    - port: 8000
      protocol: TCP
      targetPort: 8000
  selector:
    app: currency-exchange
  sessionAffinity: None
  type: LoadBalancer

this is the related props in the application.properties

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>## Activate the health probes (liveness and readiness) to avoid downtime
management.endpoint.health.probes.enabled=true
management.health.livenessState.enabled=true
management.health.readinessState.enabled=true
</code>
<code>## Activate the health probes (liveness and readiness) to avoid downtime management.endpoint.health.probes.enabled=true management.health.livenessState.enabled=true management.health.readinessState.enabled=true </code>
## Activate the health probes (liveness and readiness) to avoid downtime
management.endpoint.health.probes.enabled=true
management.health.livenessState.enabled=true
management.health.readinessState.enabled=true

What I’ve Tried: I tried removing the Liveness probe and using only the Readiness probe. This seems to work fine, and there is no downtime during deployment. However, I need to understand why the pod fails and enters CrashLoopBackOff when the Liveness probe is enabled.

Any insights into what might be going wrong or how to properly configure these probes to avoid downtime would be greatly appreciated!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật