【问题标题】:My Spring boot application Pod is stuck in kubernetes and not being up我的 Spring Boot 应用程序 Pod 卡在 kubernetes 中并且没有启动
【发布时间】:2021-11-17 17:02:34
【问题描述】:

Spring boot application pod 没有起床,也没有 failed ,只是卡住了。没有得到任何线索出了什么问题。附加的屏幕截图是它正在生成的日志 pod log

apiVersion: apps/v1
kind: Deployment
metadata:
  name: <deployement-name>
spec:
  selector:
    matchLabels:
      app: <app-name>
  replicas: 1
  template:
    metadata:
      labels:
        app: <app-name>
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "8090"
        prometheus.io/path: "/app/actuator/prometheus"
    spec:
      securityContext:
        runAsGroup: 3000
        runAsUser: 3000
      containers:
      - name: <app-name>
        image: <url>/REPLACE_ME
        imagePullPolicy: Always
        env:
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: <random>-db-secret
              key: db-user
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: <random>-db-secret
              key: db-pass
        - name: spring-profile
          valueFrom:
            configMapKeyRef:
              name: spring-profile-stage
              key: ENV
        - name: securityaudit.hostname
          valueFrom:
            configMapKeyRef:
              name: securityaudit-config
              key: securityaudit.hostname
        - name: securityaudit.ipaddress
          valueFrom:
            configMapKeyRef:
              name: securityaudit-config
              key: securityaudit.ipaddress
        - name: securityaudit.product
          valueFrom:
            configMapKeyRef:
              name: securityaudit-config
              key: securityaudit.product
        - name: splunkurl
          valueFrom:
            configMapKeyRef:
              name: splunk-config
              key: splunkurl
        - name: splunktoken
          valueFrom:
            secretKeyRef:
              name: hec-token-secret
              key: hec-token
        - name: splunkindex
          valueFrom:
            configMapKeyRef:
              name: splunk-config
              key: splunkindex
        - name: splunkCertValidDisable
          valueFrom:
            configMapKeyRef:
              name: splunk-config
              key: splunkDisableCertValidation
        - name: MY_POD_ID
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        resources:
          limits:
            memory: 4Gi
            cpu: 1
          requests:
            memory: 4Gi
            cpu: 1
        securityContext:
          privileged: false
        ports:
        - containerPort: 8090
        livenessProbe:
           httpGet:
             path: /<app-name>/actuator/health/liveness
             port: 8090
           initialDelaySeconds: 180
        readinessProbe:
           httpGet:
             path: /<app-name>/actuator/health/readiness
             port: 8090
           initialDelaySeconds: 180
           periodSeconds: 10
        volumeMounts:
        - name: <app-name>-heapdump
          mountPath: /<app-name>heapdump
      volumes:
      - name: <app-name>-heapdump
        persistentVolumeClaim:
          claimName: <app-name>heap-dump-stage

【问题讨论】:

  • 您确定要将日志写入标准输出吗?
  • 我猜,相应的 log4j 文件本身并没有被选中,所以没有进一步的日志被打印
  • 这能回答你的问题吗 - stackoverflow.com/questions/40762547/…
  • @RakeshGupta 由于安全原因,我已经替换了某些部分
  • @RakeshGupta,这个链接有帮助。我的 log4j2 文件中缺少记录器。非常感谢。你拯救了我的一天。很多东西要学!!

标签: spring-boot kubernetes deployment profiling kubernetes-pod


【解决方案1】:

@Rakesh Gupta 的回答解决了我的问题。 Pod 已启动,问题是未设置日志记录级别,我认为 Pod 本身有问题。作为这个项目的新手,我错过了检查日志级别的要点 这是否回答了您的问题 - stackoverflow.com/questions/40762547/... -

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-18
    • 2018-12-16
    • 1970-01-01
    • 2021-04-24
    • 1970-01-01
    • 2017-09-23
    • 2021-07-04
    • 2021-10-07
    相关资源
    最近更新 更多