Finally solved the issue, it was due to a mismatch in the CPU architecture between where I was building the docker image and deploying it. I was building on a Mac and deploying to a x86_64
Container with status CrashLoopBackOff in AKS
I'm trying to deploy a container to AKS but the pod is constantly in CrashLoopBackOff and restarting. I tried with different images but apparently is unrelated with that regard.
The pod has very simple functional behaviour that works fine locally. It's a simple express server listening to the port 9002 and send the message "HELLO" in the path "/".
Anybody can shed light on this topic? Thanks
The deployed container has the following yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: be-simply-depl
spec:
replicas: 1
selector:
matchLabels:
app: be-simply
template:
metadata:
labels:
app: be-simply
spec:
containers:
- name: be-simply
image: dockeraccount/be-simply
---
apiVersion: v1
kind: Service
metadata:
name: be-simply-srv
spec:
selector:
app: be-simply
type: ClusterIP
ports:
- name: be-simply
protocol: TCP
port: 9002
targetPort: 9002
When running:
kubectl describe pod be-simply-depl-79f49b58d7-wksms
Name: be-simply-depl-79f49b58d7-wksms
Namespace: default
Priority: 0
Service Account: default
Node: aks-agentpool-24486413-vmss000000/10.224.0.4
Start Time: Tue, 25 Jul 2023 05:17:17 +0000
Labels:
app=be-simply
pod-template-hash=79f49b58d7
Annotations: <none>
Status:
Running IP: 10.244.0.42
IPs:
IP: 10.244.0.42
Controlled By: ReplicaSet/be-simply-depl-79f49b58d7
Containers: be-simply:
Container ID: containerd://eddf0b34eaeaa8a0223631976d175b1e86d24129300d669a79c217cab4ef5531
Image: manelcastro/be-simply
Image ID: docker.io/manelcastro/be-simply@sha256:c933ed74ed2d1281e793beb9d4555b8951a5dba3ed21bc8dd27c65e0896e13ea
Port: <none>
Host Port: <none>
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Tue, 25 Jul 2023 05:18:06 +0000
Finished: Tue, 25 Jul 2023 05:18:06 +0000 Ready: False Restart Count: 3
Environment: <none>
Mounts: /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-pnhv2 (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
kube-api-access-pnhv2:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true QoS
Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events: Type Reason Age From Message ---- ------ ---- ---- -------
Normal Scheduled 101s default-scheduler Successfully assigned default/be-simply-depl-79f49b58d7-wksms to aks-agentpool-24486413-vmss000000
Normal Pulled 101s kubelet Successfully pulled image "manelcastro/be-simply" in 749.891764ms (749.897064ms including waiting)
Normal Pulled 99s kubelet Successfully pulled image "manelcastro/be-simply" in 735.883614ms (735.889814ms including waiting)
Normal Pulled 82s kubelet Successfully pulled image "manelcastro/be-simply" in 728.026859ms (728.037459ms including waiting)
Normal Created 53s (x4 over 101s) kubelet Created container be-simply
Normal Started 53s (x4 over 101s) kubelet Started container be-simply
Normal Pulled 53s kubelet Successfully pulled image "manelcastro/be-simply" in 733.54339ms (733.55049ms including waiting)
Warning BackOff 15s (x8 over 99s) kubelet Back-off restarting failed container
Azure Kubernetes Service
3 answers
Sort by: Most helpful
-
-
Manel Castro 30 Reputation points
2023-07-26T05:02:29.73+00:00 Finally solved the issue, it was due to a mismatch in the CPU architecture between where I was building the docker image and deploying it. I was building on a Mac and deploying to a x86_64
-
shiva patpi 13,366 Reputation points Microsoft Employee Moderator
2023-07-25T05:36:17.3766667+00:00 As per the pod describe , the exit code 1 basically means your application has failed to start within that process which might be in turn causing failure of container creation and hence pod is not coming into running state.
Reason: CrashLoopBackOff
Last State: Terminated Reason:
Error Exit Code: 1
//////////
As per your deployment YAML file , there is no port number mentioned but in the service YAML file you have mentioned the port number as : 9002.
Probably try to mention the port number in your deployment YAML file also ?
(or)
It might be the case that , the Pod has come to running state and it has done it's job of printing HELLO and later on it has nothing to do - hence went to Crashloopbackoff state.
Try to mention a sleep like below:
command: ["sleep", "3600"]
Regards,
Shiva.