Reputation: 651
When trying to deploy my project to openshift with the yml-file underneath I get an error of Init:CrashLoopBackOff. Does anyone see what is wrong or have any tips on how to investigate this further than just looking at the Events of the pod. The events say "Container image "url/the-app:snapshot" already present on machine"
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: {}
Upvotes: 0
Views: 2372
Reputation: 311387
The state Init:CrashLoopBackOff
means that one of your initContainers
is crashing. You would normally diagnose this by looking at the logs for the container (kubectl logs the-app -c init-test-data
), but in this case there's an obvious problem.
You've set the args
in your init-test-data
container to...
apt-get install --yes git clone https://MYGITREPO.git
...but that's not a valid command. It looks like you have accidentally mashed two commands together. Something like this might work:
command:
- /bin/sh
- -c
args:
- |
apt-get install --yes git
git clone https://MYGITREPO.git
Although there's really no particular reason to use both command
and args
; this will also work just fine:
command:
- /bin/sh
- -c
- |
apt-get install --yes git
git clone https://MYGITREPO.git
(But you probably want to explicitly cd
to an appropriate directory first).
NB: In YAML, this:
command:
- /bin/sh
- -c
Is exactly identical to:
command: ["/bin/sh", "-c"]
But I prefer the previous form.
Upvotes: 1