我的 Spring 引导应用程序 Pod 卡在了 kubernetes 中并且没有启动
My Spring boot application Pod is stuck in kubernetes and not being up
Spring 启动应用程序 pod 没有启动,也没有失败,只是卡住了。不知道出了什么问题。附加的屏幕截图是它生成的日志
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
@Rakesh Gupta 的回答解决了我的问题。 Pod 已启动,问题是未设置日志记录级别,我认为 Pod 本身有问题。作为这个项目的新手,我错过了检查日志记录级别的重点
这是否回答了您的问题 - whosebug.com/questions/40762547/… –
Spring 启动应用程序 pod 没有启动,也没有失败,只是卡住了。不知道出了什么问题。附加的屏幕截图是它生成的日志 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
@Rakesh Gupta 的回答解决了我的问题。 Pod 已启动,问题是未设置日志记录级别,我认为 Pod 本身有问题。作为这个项目的新手,我错过了检查日志记录级别的重点 这是否回答了您的问题 - whosebug.com/questions/40762547/… –