1
votes

i have a kubernetes cluster of 2 machines on bare metal machines on which master machine contains the docker image which i want to deploy only on slave node, but i dont want to use the cloud repository for image storage,i am building docker image from jenkins job which runs on master machine, if i use docker image from dockerhub the deployment works fine, but it gives me an error while deploying on slave node when image is in master machine,

NAME                            READY     STATUS             RESTARTS  AGE

dash-deploy-5bd7cb4484-wvwcr    0/1       ImagePullBackOff   0         22h

hello-deploy-5756df7ff4-mwzcw   1/1       Running            0         21h

hello-deploy uses docker image from docker hub, while dash-deploy uses docker image present on master node, both the deployment are done on slave node. I know there are a lot of other methods to do this, but any help on this would be appreciated. I am using ubuntu 16.04

kubeadm version: &version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-04-27T09:10:24Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

kubectl version Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"d2835416544f298c919e2ead3be3d0864b52323b", GitTreeState:"clean", BuildDate:"2018-02-07T12:22:21Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}

Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

My yaml file looks like

---
apiVersion: extensions/v1beta1     
kind: Deployment    
metadata:    
  name: dash-deploy    
spec:    
  replicas: 1    
  minReadySeconds: 1    
  strategy:    
    type: RollingUpdate    
    rollingUpdate:    
      maxUnavailable: 1    
      maxSurge: 1    
  template:    
    metadata:    
      labels:    
        app: dashboard    
    spec:    
      containers:    
      - name: dash-pod    
        image: 32:32    
        imagePullPolicy: IfNotPresent    
        ports:    
        - containerPort: 8080    
---    
apiVersion: v1    
kind: Service    
metadata:    
  name: dash-svc    
  labels:    
    app: dashboard    
spec:    
  type: NodePort    
  ports:    
  - port: 8080    
    nodePort: 30002    
    protocol: TCP    
  selector:    
    app: dashboard    
---
3

3 Answers

2
votes

The slave needs to download the image from somewhere. Images are not automatically distributed to the slaves.

If you don't want to use dockerhub, you need to host your own Docker Registry in the cluster to download images from it. This guide will help you do it.

0
votes

As fiunchinho mentioned, you can set up a docker registry and use that for your deployments.

Another solution is to export the image from your Jenkins, docker import it on your slave

0
votes

if you don't have a docker registry set up in you environment, then you'll need to load the images on the worker node using docker load -i command