hoeghh / kubernetes_the_easy_way

Automating Kubernetes the hard way with Vagrant and scripts
MIT License
20 stars 11 forks source link

How to make use of own docker registry #37

Closed vikasgubbi closed 6 years ago

vikasgubbi commented 6 years ago

Hi,

How to make use of own private docker registry or export/import of docker image for deployment. Is it possible for both the methods.

Regards,Vikas

hoeghh commented 6 years ago

When using this project, you can use docker images from the docker hub or from where ever you want. You specify that in the image. If you dont want to upload an image to eg. the docker hub, you can copy the image to the nodes before deployment. Then the node will already have the image, and use that instead of pulling one from the hub.

vikasgubbi commented 6 years ago

Hi,

Please assist , details below

[vagrant@k8s-worker-1 ~]$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE mongodb latest ad627cd74195 17 minutes ago 437MB weaveworks/weave-npc 2.3.0 21545eb3d6f9 2 months ago 47.2MB weaveworks/weave-kube 2.3.0 f15514acce73 2 months ago 96.8MB gcr.io/google_containers/pause-amd64 3.0 99e59f495ffa 2 years ago 747kB

vikas@ubuntu:~/working$ more mongodb.yaml apiVersion: apps/v1 kind: Deployment metadata: name: mongodb labels: app: mongodb spec: replicas: 3 selector: matchLabels: app: mongodb template: metadata: labels: app: mongodb spec: containers:


Regards,Vikas

hoeghh commented 6 years ago

How many workers did you make?

Try kubectl get pods -o wide

Then you can see which node the pod is scheduled on.

vikasgubbi commented 6 years ago

Hi,

I need to deploy the existing imported docker image ,getting below message.Please let me know how to do so.

[vagrant@k8s-worker-2 ~]$ sudo docker images REPOSITORY TAG IMAGE ID CREATED SIZE mongonew latest f6e11dbc36f9 About a minute ago 437MB weaveworks/weave-npc 2.3.0 21545eb3d6f9 2 months ago 47.2MB weaveworks/weave-kube 2.3.0 f15514acce73 2 months ago 96.8MB gcr.io/google_containers/k8s-dns-sidecar-amd64 1.14.7 db76ee297b85 8 months ago 42MB gcr.io/google_containers/k8s-dns-kube-dns-amd64 1.14.7 5d049a8c4eec 8 months ago 50.3MB gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 1.14.7 5feec37454f4 8 months ago 41MB gcr.io/google_containers/pause-amd64 3.0 99e59f495ffa 2 years ago 747kB


Events: Type Reason Age From Message


Normal Scheduled 7m default-scheduler Successfully assigned mongodb2-9f7b4c9c5-p4zwb to k8s-worker-1 Normal SuccessfulMountVolume 7m kubelet, k8s-worker-1 MountVolume.SetUp succeeded for volume "default-token-xh8sk" Normal SandboxChanged 6m (x2 over 6m) kubelet, k8s-worker-1 Pod sandbox changed, it will be killed and re-created. Normal Pulling 6m (x3 over 6m) kubelet, k8s-worker-1 pulling image "mongonew" Warning Failed 5m (x3 over 6m) kubelet, k8s-worker-1 Failed to pull image "mongonew": rpc error: code = Unknown desc = Error response from daemon: pull access denied for mongonew, repository does not exist or may require 'docker login' Warning Failed 5m (x3 over 6m) kubelet, k8s-worker-1 Error: ErrImagePull Normal BackOff 5m (x6 over 6m) kubelet, k8s-worker-1 Back-off pulling image "mongonew" Warning Failed 1m (x20 over 6m) kubelet, k8s-worker-1 Error: ImagePullBackOff

vikas@ubuntu:~/working$ kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE mongodb-cf496b778-4w98q 0/1 CreateContainerError 0 6m 20.0.192.4 k8s-worker-2 mongodb-cf496b778-n8d5j 0/1 ErrImageNeverPull 0 6m 20.0.0.4 k8s-worker-1 mongodb-cf496b778-zm8z6 0/1 CreateContainerError 0 6m 20.0.192.3 k8s-worker-2 mongodb2-9f7b4c9c5-j6trp 0/1 ImagePullBackOff 0 8m 20.0.192.2 k8s-worker-2 mongodb2-9f7b4c9c5-jvpt4 0/1 ImagePullBackOff 0 8m 20.0.0.2 k8s-worker-1 mongodb2-9f7b4c9c5-p4zwb 0/1 ImagePullBackOff 0 8m 20.0.0.3 k8s-worker-1

Type Reason Age From Message


Normal Scheduled 3m default-scheduler Successfully assigned mongodb-cf496b778-n8d5j to k8s-worker-1 Normal SuccessfulMountVolume 3m kubelet, k8s-worker-1 MountVolume.SetUp succeeded for volume "default-token-xh8sk" Warning ErrImageNeverPull 1m (x12 over 3m) kubelet, k8s-worker-1 Container image "mongonew" is not present with pull policy of Never Warning Failed 1m (x12 over 3m) kubelet, k8s-worker-1 Error: ErrImageNeverPull

Regards,Vikas

vikasgubbi commented 6 years ago

Hi,

rephrasing the question

I need to deploy the imported docker image in one node to all the nodes in the cluster, how to do so

Regards,Vikas

hoeghh commented 6 years ago

If you dont push it to a registry, you will have to import it to all nodes manually. One at the time.

hoeghh commented 6 years ago

try tagging it with something like vikas/mongodb:4 . Save it, copy it to worker nodes, and import it. Then in your yaml file, reference to it as vikas/mongodb:4.

It should work.

vikasgubbi commented 6 years ago

Hi,

Thanks , i will try.

Regards,Vikas