skip to Main Content

This is my deployment manifest

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

I have tried several times to apply Kubernetes manifest with this Yaml file but it is throws the below mentioned error.

Failed to pull image "mongo": rpc error: code = Unknown desc = context deadline exceeded
  Warning  Failed     13s    kubelet            Error: ErrImagePull
  Normal   BackOff    13s    kubelet            Back-off pulling image "mongo"
  Warning  Failed     13s    kubelet            Error: ImagePullBackOff

If someone could hep me fix this issue it would be helpful.

2

Answers


  1. instead of "mongo" for the image use this: "registry.hub.docker.com/library/mongo"

    Login or Signup to reply.
  2. I just copied the manifest from your request and deployed it in my cluster

    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
              value: admin
            - name: MONGO_INITDB_ROOT_PASSWORD
              value: admin123
    

    mongo was deployed without issues. You must not have connectivity to internet. please check

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search