I am trying to create a Kubernetes pod with the following config file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb-deployment
labels:
app: mongodb
spec:
replicas: 1
selector:
matchLabels:
app: mongodb
template:
metadata:
labels:
app: mongodb
spec:
containers:
- name: mongodb
image: mongo
ports:
- containerPort: 27017
env:
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
name: mongodb-secret
key: mongo-root-username
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mongodb-secret
key: mongo-root-password
However, I get an ImagePullBackOff, and when I use kubectl describe pod, here's what's shown:
Name: mongodb-deployment-8f6675bc5-jzmvw
Namespace: default
Priority: 0
Node: minikube/192.168.64.2
Start Time: Thu, 10 Dec 2020 16:30:21 +0800
Labels: app=mongodb
pod-template-hash=8f6675bc5
Annotations: <none>
Status: Pending
IP: 172.17.0.3
IPs:
IP: 172.17.0.3
Controlled By: ReplicaSet/mongodb-deployment-8f6675bc5
Containers:
mongodb:
Container ID:
Image: mongo
Image ID:
Port: 27017/TCP
Host Port: 0/TCP
State: Waiting
Reason: ErrImagePull
Ready: False
Restart Count: 0
Environment:
MONGO_INITDB_ROOT_USERNAME: <set to the key 'mongo-root-username' in secret 'mongodb-secret'> Optional: false
MONGO_INITDB_ROOT_PASSWORD: <set to the key 'mongo-root-password' in secret 'mongodb-secret'> Optional: false
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-w5ltt (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
default-token-w5ltt:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-w5ltt
Optional: false
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 115m default-scheduler Successfully assigned default/mongodb-deployment-8f6675bc5-jzmvw to minikube
Normal Pulling 115m kubelet Pulling image "mongo"
Warning Failed 114m kubelet Failed to pull image "mongo": rpc error: code = Unknown desc = Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Warning Failed 114m kubelet Error: ErrImagePull
Normal BackOff 114m kubelet Back-off pulling image "mongo"
Warning Failed 114m kubelet Error: ImagePullBackOff
I don't think it's a problem with the image/image name. Is there something wrong with my config file?
Any advice would be greatly appreciated!