CodexBloom - Programming Q&A Platform

Kubernetes Pod in CrashLoopBackOff due to missing configuration for Spring Boot application

👀 Views: 20 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-01
Kubernetes Spring Boot ConfigMap yaml

I'm a bit lost with I've searched everywhere and can't find a clear answer. I'm working on a personal project and I'm attempting to set up I'm working with an scenario where my Spring Boot application running in a Kubernetes pod is exploring in a CrashLoopBackOff state. The logs show the following behavior message: ``` behavior: Unable to start the application. Missing configuration for 'database.url'. ``` I've confirmed that the application works perfectly when run locally. To deploy it, I created a Kubernetes deployment with the following manifest: ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: my-spring-app spec: replicas: 2 selector: matchLabels: app: my-spring-app template: metadata: labels: app: my-spring-app spec: containers: - name: spring-app image: myregistry/my-spring-app:v1.0 ports: - containerPort: 8080 env: - name: SPRING_PROFILES_ACTIVE value: "prod" - name: DATABASE_URL valueFrom: configMapKeyRef: name: app-config key: database.url ``` I created the ConfigMap with: ```yaml apiVersion: v1 kind: ConfigMap metadata: name: app-config data: database.url: jdbc:mysql://mysql-service:3306/mydb ``` I've verified that the ConfigMap is in place by running `kubectl get configmaps` and it shows up correctly. However, when I describe the pod using `kubectl describe pod <pod-name>`, it indicates that the environment variable DATABASE_URL is not set, which is leading to the application crash. I've tried restarting the deployment and even deleted the pod to let it recreate, but the scenario continues. Is there something I'm missing in the ConfigMap or deployment configuration? How can I ensure that the environment variable is loaded correctly into my Spring Boot application? This is part of a larger application I'm building. Has anyone else encountered this? The stack includes Yaml and several other technologies. Has anyone else encountered this? This issue appeared after updating to Yaml 3.11. Any ideas what could be causing this? I'm working on a application that needs to handle this.