localkube doesn't pull images from local docker registry
Closed this issue · 1 comments
If I run
$ docker build -t hharnisc/thetime .
The image builds as expected and I can run it with a docker run
command. However after deploying with spread build .
The image is stuck trying to pull the image from docker hub.
Below is the log output from kubectrl describe po thetime
Name: thetime-axe64
Namespace: default
Node: default/10.0.2.15
Start Time: Tue, 24 May 2016 23:17:52 -0500
Labels: app=thetime,role=backend,version=0.0.1
Status: Pending
IP: 10.32.0.3
Controllers: ReplicationController/thetime
Containers:
thetime:
Container ID:
Image: hharnisc/thetime
Image ID:
Port: 8080/TCP
QoS Tier:
cpu: BestEffort
memory: BestEffort
State: Waiting
Reason: ImagePullBackOff
Ready: False
Restart Count: 0
Environment Variables:
Conditions:
Type Status
Ready False
No volumes.
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
4m 4m 1 {default-scheduler } Normal Scheduled Successfully assigned thetime-axe64 to default
4m 1m 5 {kubelet default} spec.containers{thetime} Normal Pulling pulling image "hharnisc/thetime"
4m 1m 5 {kubelet default} spec.containers{thetime} Warning Failed Failed to pull image "hharnisc/thetime": Error: image hharnisc/thetime not found
4m 1m 5 {kubelet default} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "thetime" with ErrImagePull: "Error: image hharnisc/thetime not found"
4m 2s 18 {kubelet default} spec.containers{thetime} Normal BackOff Back-off pulling image "hharnisc/thetime"
4m 2s 18 {kubelet default} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "thetime" with ImagePullBackOff: "Back-off pulling image \"hharnisc/thetime\""
If I ssh/login to the running redspread/localkube container with
$ docker exec -it 0f232e507ec2 sh
And list docker images within the localkube container, I get the following output
$ docker ls
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
hharnisc/thetime latest sha256:6d5c6 39 minutes ago 120.8 MB
mhart/alpine-node latest sha256:c6403 7 days ago 45.99 MB
redspreadapps/localkube latest sha256:79b86 7 weeks ago 124.8 MB
weaveworks/weaveexec 1.4.5 sha256:e566e 12 weeks ago 60.67 MB
weaveworks/weave 1.4.5 sha256:28d6d 12 weeks ago 19.24 MB
gcr.io/google_containers/pause 2.0 sha256:2b583 7 months ago 350.2 kB
After I do a docker push hharnisc/thetime
, the image runs as expected in localkube.
So it turns out I needed to add another line to service.rc.yml file to only pull from docker hub if it isn't present in the local registry.
But the idea is to add this line to the containers:
containers:
- name: my-service
image: hharnisc/my-service
imagePullPolicy: IfNotPresent # <--- needed this
ports:
- containerPort: 8080
More detailed description of the change:
hharnisc/generator-kube-service#1