I am trying to launch a deployment object in k8s with kubernetes/redis image. But I am getting error Back-off restarting failed container. The issue occurs with just redis image and I am able to successfully run deployments with postgres image etc.
Here is the config file:
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
Describe pod output:
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
I am using the kubernetes/redis image in this example as using redis image completely fails because kubectl is not able to get the image pulled from dockerhub and I get the error which says failed in pulling the image. Not sure why !
Can anyone please help me out here.
EDIT---
Logs
kubectl.exe logs redis-deployment-57dcf8ff69-9v8sz
Could not connect to Redis at -p:6379: Name or service not known
Failed to find master.
Below config file worked for me.
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