Using a local image to create a pod in K8s

0 votes

I created this image using a dockerfile of my own:

REPOSITORY   TAG     IMAGE ID       CREATED      SIZE

ruby/lab     latest  f1903b1508cb   2 hours ago  729.6 MB

And the kubernetes deployment file:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ruby-deployment
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: ruby
    spec:
      containers:
      - name: ruby-app
        image: ruby/lab
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 4567

But If I try and create the deployment the pods are unable to get the image:

ruby-deployment-3830038651-sa4ii   0/1       ImagePullBackOff   0          7m
ruby-deployment-3830038651-u1tvc   0/1       ImagePullBackOff   0          7m

And:

 8m            2m              6       {kubelet minikube}      spec.containers{ruby}   Normal          Pulling         pulling image "ruby/lab:latest"
  8m            2m              6       {kubelet minikube}      spec.containers{ruby}   Warning         Failed          Failed to pull image "ruby/lab:latest": Error: image ruby/lab not found
  8m            2m              6       {kubelet minikube}                              Warning         FailedSync      Error syncing pod, skipping: failed to "StartContainer" for "ruby" with ErrImagePull: "Error: image ruby/lab not found"

Do I have to upload the image to docker to get this done? I just want to test this locally.

Aug 27, 2018 in Kubernetes by sdfg
• 5,550 points
18,231 views

2 answers to this question.

0 votes

point your docker client to your machine's docker daemon:

eval $(minikube docker-env)

Now, build your image and then create the kubernetes resources using kubectl command but use the following in your YAML file:

imagePullPolicy: IfNotPresent

If you're using minkube you can pass a flag the first time you're creating the minikube machine.

minikube start --insecure-registry

You may also want to read this when using a private registry http://kubernetes.io/docs/user-guide/images/

answered Aug 27, 2018 by ajs3033
• 7,280 points
0 votes
I'm not sure but you can try this. Tag the docker image and push it in a repository on Github and then try to use that tagged image in your deployment.
answered Apr 29, 2019 by Vishaka

Related Questions In Kubernetes

0 votes
1 answer

How to deploy the pod in k8s connect to 3rd party server which using whitelist IP?

Hey, You can connect the pod and the ...READ MORE

answered Oct 29, 2020 in Kubernetes by Sam

edited Oct 6, 2021 by Sarfaraz 357 views
0 votes
3 answers

Retry pull image in a kubernetes pod

If the Pod is part of a ...READ MORE

answered Aug 29, 2018 in Kubernetes by Hannah
• 18,570 points
4,919 views
0 votes
1 answer

Not able to access kubernetes api from a pod in azure

Follow these steps Add --bind-address=0.0.0.0 option to the line https://github.com/kubernetes/kubernetes/blob/v1.2.0/docs/getting-started-guides/coreos/azure/cloud_config_templates/kubernetes-cluster-main-nodes-template.yml#L218  Created ...READ MORE

answered Aug 30, 2018 in Kubernetes by Kalgi
• 52,350 points
432 views
+2 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
1,864 views
0 votes
1 answer

How to use gravitational teleport in a container/kubernetes environment?

You can use teleport to augment kubernetes ...READ MORE

answered Jun 28, 2018 in Kubernetes by ajs3033
• 7,280 points
1,692 views
+1 vote
4 answers

Can I set ulimit for containers in k8s?

You can either modify them via UserData ...READ MORE

answered May 7, 2019 in Kubernetes by Inayat
13,010 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP