gpt4 book ai didi

redis - 在 k8s 中创建 redis 部署时退避重启失败的容器

转载 作者:可可西里 更新时间:2023-11-01 11:23:46 25 4
gpt4 key购买 nike

我正在尝试使用 kubernetes/redis 图像在 k8s 中启动部署对象。但我收到错误消息Back-off restarting failed container。只有 redis 图像会出现问题,我能够使用 postgres 图像等成功运行部署。

这是配置文件:

apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
spec:
replicas: 1
selector:
matchLabels:
component: redis
template:
metadata:
labels:
component: redis
spec:
containers:
- name: redis
image: kubernetes/redis
ports:
- containerPort: 6379

描述 pod 输出:

Name:               redis-deployment-57dcf8ff69-9v8sz
Namespace: default
Priority: 0
PriorityClassName: <none>
Node: minikube/10.0.2.15
Start Time: Sun, 10 Mar 2019 11:13:00 +0530
Labels: component=redis
pod-template-hash=57dcf8ff69
Annotations: <none>
Status: Running
IP: 172.17.0.8
Controlled By: ReplicaSet/redis-deployment-57dcf8ff69
Containers:
redis:
Container ID: docker://556544175a99da6cd704ddc5ae6e65ee0a424275872d86543bbfef6eebceff5b
Image: kubernetes/redis
Image ID: docker-pullable://kubernetes/redis@sha256:60e8254f473b1df64340da257e8e0a029c0ac67a76bdde296f11eba6cde515c7
Port: 6379/TCP
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Sun, 10 Mar 2019 20:12:26 +0530
Finished: Sun, 10 Mar 2019 20:13:28 +0530
Ready: False
Restart Count: 13
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-zqj5b (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-zqj5b:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-zqj5b
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 9h default-scheduler Successfully assigned default/redis-deployment-57dcf8ff69-9v8sz to minikube
Normal Pulling 5h (x5 over 9h) kubelet, minikube pulling image "kubernetes/redis"
Normal Pulled 5h (x5 over 5h) kubelet, minikube Successfully pulled image "kubernetes/redis"
Normal Created 5h (x5 over 5h) kubelet, minikube Created container
Normal Started 5h (x5 over 5h) kubelet, minikube Started container
Warning BackOff 5h (x53 over 5h) kubelet, minikube Back-off restarting failed container
Normal SandboxChanged 17m kubelet, minikube Pod sandbox changed, it will be killed and re-created.
Normal Pulling 11m (x4 over 16m) kubelet, minikube pulling image "kubernetes/redis"
Normal Pulled 11m (x4 over 16m) kubelet, minikube Successfully pulled image "kubernetes/redis"
Normal Created 11m (x4 over 16m) kubelet, minikube Created container
Normal Started 11m (x4 over 16m) kubelet, minikube Started container
Warning BackOff 1m (x39 over 15m) kubelet, minikube Back-off restarting failed container

我在此示例中使用 kubernetes/redis 图像,因为使用 redis 图像完全失败,因为 kubectl 无法从 dockerhub 中获取图像,我得到了表示拉取图像失败的错误。不知道为什么!

谁能帮帮我。

编辑---

日志

kubectl.exe logs redis-deployment-57dcf8ff69-9v8sz
Could not connect to Redis at -p:6379: Name or service not known
Failed to find master.

最佳答案

下面的配置文件对我有用。

apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
spec:
replicas: 1
selector:
matchLabels:
component: redis
template:
metadata:
labels:
component: redis
spec:
containers:
- name: redis
image: gcr.io/google_containers/redis:v1
env:
- name: MASTER
value: "true"
ports:
- containerPort: 6379

关于redis - 在 k8s 中创建 redis 部署时退避重启失败的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55089042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com