'the kubernetes pod container exists with Segmentation fault when running rust pod
Today I found the kubernetes pod shows log:
Back-off restarting failed container
the container shows exists info:
terminated
Reason: Error - exit code: 139
and the pod always did not ready and could not serve the request, but when I check the pod log:
release git:(main) kubectl logs admin-service-5bdf47b85c-bdqdw -n reddwarf-pro
➜ release git:(main)
there is no message output. why did this happen? what should I do to fix this problem? This is the Dockerfile:
# to reduce the docker image size
# build stage
FROM rust:1.54-alpine as builder
WORKDIR /app
COPY . /app
RUN rustup default stable
RUN apk update && apk add --no-cache libpq musl-dev pkgconfig openssl-dev postgresql-dev
RUN cargo build --release
# RUN cargo build
# Prod stage
FROM alpine:3.15
WORKDIR /app
ENV ROCKET_ADDRESS=0.0.0.0
# ENV ROCKET_PORT=11014
RUN apk update && apk add --no-cache libpq curl
COPY --from=builder /app/.env /app
COPY --from=builder /app/settings.toml /app
COPY --from=builder /app/target/release/reddwarf-admin /app/
COPY --from=builder /app/Rocket.toml /app
CMD ["./reddwarf-admin"]
could not login into docker container by any ways. when I using describe command:
➜ release git:(main) kubectl describe pod admin-service-745dc87489-j647l -n reddwarf-pro
Name: admin-service-745dc87489-j647l
Namespace: reddwarf-pro
Priority: 0
Node: k8smasterone/172.29.217.209
Start Time: Mon, 02 May 2022 14:19:10 +0800
Labels: app=admin-service
pod-template-hash=745dc87489
Annotations: cni.projectcalico.org/containerID: 41763a38ee120ae7c85cd11fda699f30205a06fe9a5b6175736390d503c26bd3
cni.projectcalico.org/podIP: 10.97.196.208/32
cni.projectcalico.org/podIPs: 10.97.196.208/32
Status: Running
IP: 10.97.196.208
IPs:
IP: 10.97.196.208
Controlled By: ReplicaSet/admin-service-745dc87489
Containers:
admin-service:
Container ID: containerd://406e183d166b861448aa2d3597d3d190ccd5432e92b031721cae356ab00b59b2
Image: registry.cn-hongkong.aliyuncs.com/reddwarf-pro/reddwarf-admin:f1e71525c1996a711f67ca85715d190bafcee07d
Image ID: registry.cn-hongkong.aliyuncs.com/reddwarf-pro/reddwarf-admin@sha256:b39bebf332bc53318e29c8f697592bf76eb9e1676b74017d87c109a74ad3f235
Port: 80/TCP
Host Port: 0/TCP
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 139
Started: Mon, 02 May 2022 14:22:02 +0800
Finished: Mon, 02 May 2022 14:22:03 +0800
Ready: False
Restart Count: 5
Limits:
cpu: 50m
memory: 60Mi
Requests:
cpu: 20m
memory: 6Mi
Environment:
DATABASE_URL: <set to the key 'database_url' of config map 'admin-service-pro-config'> Optional: false
MUSIC_DATABASE_URL: <set to the key 'music_database_url' of config map 'admin-service-pro-config'> Optional: false
QUARK_DATABASE_URL: <set to the key 'quark_database_url' of config map 'admin-service-pro-config'> Optional: false
DICT_DATABASE_URL: <set to the key 'dict_database_url' of config map 'admin-service-pro-config'> Optional: false
ENV: <set to the key 'env' of config map 'admin-service-pro-config'> Optional: false
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-6gfdl (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
kube-api-access-6gfdl:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: Burstable
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 4m8s default-scheduler Successfully assigned reddwarf-pro/admin-service-745dc87489-j647l to k8smasterone
Normal Pulled 2m42s (x5 over 4m7s) kubelet Container image "registry.cn-hongkong.aliyuncs.com/reddwarf-pro/reddwarf-admin:f1e71525c1996a711f67ca85715d190bafcee07d" already present on machine
Normal Created 2m42s (x5 over 4m7s) kubelet Created container admin-service
Normal Started 2m41s (x5 over 4m7s) kubelet Started container admin-service
Warning BackOff 2m16s (x10 over 4m5s) kubelet Back-off restarting failed container
when I pull the image into local MacBook Pro, it works fine. By the way, the server running containerd not using docker.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
