当尝试使用yml-文件将我的项目部署到openshift时,我会得到一个错误Init:CrashLoopBackOff。是否有人看到了什么是错误的,或有任何关于如何进一步调查这一问题的建议,而不仅仅是观察吊舱的事件。这些事件显示“容器映像”url/-app:快照“已经出现在机器上”。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: the-app
name: the-app
spec:
replicas: 1
selector:
matchLabels:
app: the-app
strategy:
type: Recreate
redeployOnConfigChange: true
template:
metadata:
labels:
app: the-app
spec:
containers:
- image: {{ image_registry }}/the-app:{{ the-app-version }}
imagePullPolicy: Always
name: the-app
ports:
- containerPort: 10202
protocol: TCP
livenessProbe:
httpGet:
path: /actuator/health
port: 10202
scheme: HTTP
initialDelaySeconds: 20
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /actuator/health
port: 10202
scheme: HTTP
initialDelaySeconds: 20
timeoutSeconds: 10
env:
- name: SPRING_PROFILES_ACTIVE
value: "prod"
- name: ENVIRONMENT_SERVER_PORT
value: "10202"
volumeMounts:
- name: my-config
mountPath: /my-config
- name: input-data
mountPath: /input-data
initContainers:
- name: init-test-data
image: {{ image_registry }}/the-app:{{ the-app-version }}
command: ["/bin/sh","-c"]
args: ['apt-get install --yes git clone https://MYGITREPO.git']
volumeMounts:
- mountPath: /tmp
name: input-data
volumes:
- name: my-config
configMap:
name: my-configmap
- name: input-data
emptyDir: {}
identity:
enabled: true
logging:
index: "{{ splunk_index }}"
---
apiVersion: v1
kind: Service
metadata:
labels:
app: the-app
name: the-app
spec:
ports:
- name: 10202-tcp
port: 10202
protocol: TCP
targetPort: 10202
selector:
app: the-app
status:
loadBalancer: {}发布于 2022-04-28 21:08:19
状态Init:CrashLoopBackOff意味着您的initContainers中有一个正在崩溃。您通常会通过查看容器的日志(kubectl logs the-app -c init-test-data)来诊断这一点,但在本例中存在一个明显的问题。
您已经将args设置为.
apt-get install --yes git clone https://MYGITREPO.git...but,这不是一个有效的命令。看起来你不小心把两个命令混在一起了。像这样的东西可能会起作用:
command:
- /bin/sh
- -c
args:
- |
apt-get install --yes git
git clone https://MYGITREPO.git虽然使用command和args并没有什么特别的理由,但这也会很好:
command:
- /bin/sh
- -c
- |
apt-get install --yes git
git clone https://MYGITREPO.git(但您可能希望首先显式地将cd放到适当的目录中)。
注:在YAML中,这是:
command:
- /bin/sh
- -c与以下完全相同:
command: ["/bin/sh", "-c"]但我更喜欢以前的表格。
https://stackoverflow.com/questions/72050183
复制相似问题