0

I have 3 nodes kubernetes cluster managing with kubeadm. Previously i used kind and minikube. When I wanted make deployment based on docker image i just need make:

  • kind load docker-image in kind or,
  • minikube cache add in minikube,

Now, when I want make deployment in kubeadm I obviously get ImagePullBackOff. Question: Is a equivalent comment do add image to kubeadm and I can't find it, or there is entirely other way to solve that problem?

EDIT

Maybe, question is not clear enough, so instead of delete it I try to put more details.

I have tree nodes (one control plane, and two workers) with docker, kubeadm, kubelet and kubectl installed on each. One deployment of my future cluster is machine learning module so I need tensorflow:

docker pull tensorflow/tensorflow

Using this image I build my own:

docker build -t mlimage:cluster -f ml.Dockerfile .

Next I prepare deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mldeployment
spec:
  selector:
    matchLabels:
      app: mldeployment
      name: mldeployment
  replicas: 1
  template:
    metadata:
      labels:
        app: mldeployment
        name: mldeployment
    spec:
      containers:
      - name: mlcontainer
        image: mlimage:cluster
        imagePullPolicy: Never
        ports:
        - name: http
          containerPort: 6060

and create it:

kubectl create -f mldeployment.yaml

Now, when I type

kubectl describe pod

In mldeployment are these events:

enter image description here

In that case of minikube or kind it was enought to simply add image to cluster typing

minikibe cache add ...

and

kind load docker-image ...

respectively.

Question is how to add image from my machine to cluster in case of managing it from kubeadm. I assume that there is similar way to do that like for minikube or kind (without creating any connection to docker hub, because everything is locally).

greygreg87
  • 152
  • 2
  • 11
  • Have you read https://computingforgeeks.com/manually-pull-container-images-used-by-kubernetes-kubeadm/ ? Why don't you want to install kubectl and use it during deploying app to pull image https://kubernetes.io/docs/concepts/containers/images/#configuring-nodes-to-authenticate-to-a-private-registry ? – Malgorzata Feb 09 '21 at 09:36
  • @Malgorzata I added more details to my question. – greygreg87 Feb 09 '21 at 14:44
  • Did you ensure that all nodes in the cluster have the same pre-pulled image ? https://kubernetes.io/docs/concepts/containers/images/#pre-pulled-images – Malgorzata Feb 09 '21 at 15:07
  • I have this same question. Were you able to resolve it? – Dan Jun 26 '23 at 18:03

2 Answers2

0

you are getting ImagePullBackOff due to kubeadm maybe going to check inside the registry.

while if you look at both command minikube cache and kind load is for loading the local images into the cluster.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
  • 1
    So, is there any command to load local docker image into cluster via kubeadm in order to make deployments based on that image? – greygreg87 Feb 08 '21 at 10:49
  • kubeadm is creating cluster you can use kubectl to deploy the deployment. – Harsh Manvar Feb 08 '21 at 10:52
  • I know that, but question is how to add image to cluster managed with kubeadm in order to use it in deployment, not how to make deployment via kubectl. – greygreg87 Feb 08 '21 at 12:12
0

As I now understand images for cluster managed via kubeadm should be stored in trusted registry like dockerhub or cloud. But if you want make fast solution in separated networks there is a posibility: Docker registry. There are also some tools ready to use e.g. Trow, or simpler solution. I used second approach, and it works (code is a bit old, so it may needs some changes, this links may be helpful: change apiVersion, add label

After that changes, first create deployment and daemonSet:

kubectl create -f docker-private-registry.json
kubectl create -f docker-private-registry-proxy.json

Add localhost address to image:

docker tag image:tag 127.0.0.1:5000/image:tag

Check full name of docker private registry deployment, and forward port (replace x by exact deployment name:

kubectl get pod
kubectl port-forward docker-private-registry-deployment-xxxxxxxxx-xxxxx 5000:5000 -n default

Open next terminal window and push image to private registry:

docker push 127.0.0.1:5000/image:tag

Finnaly change in deployment.yaml file containers image (add 127.0.0.1:5000/...) and create deployment.

This solution is very unsafe and vulnerable, so use it wisely only in separated networks for test and dev purposes.

greygreg87
  • 152
  • 2
  • 11