openshift / origin

Conformance test suite for OpenShift
http://www.openshift.org
Apache License 2.0
8.48k stars 4.7k forks source link

StatefulSet pulls image from docker hub instead of internal registry #17157

Closed zalintyre closed 6 years ago

zalintyre commented 6 years ago

I'm using Kubernetes 1.5 in OpenShift. I pushed all my customized docker images to OpenShift's internal registry. When using a DeploymentConfig, everything works fine, kubernetes pulls the right image.

When using a StatefulSet, Kubernetes won't find my docker image in the internal registry and instead pulls an image from docker hub.

My StatefulSet:

        spec:
          containers:
            - image: zookeeper:latest
              args:
                - bin/zkServer.sh
                - 'start-foreground'

It would work when i put the internal registry URL in front of the image name like this:

image: 172.30.158.156:5000/<projectname>/zookeeper:latest

But when I'm working with multiple clusters, this isn't practical (and again, it works with DeploymentConfigs)

Version
$ oc version
oc v3.6.0+c4dd4cf
kubernetes v1.6.1+5115d708d7
features: Basic-Auth

Server https://master.*********:443
openshift v1.5.0
kubernetes v1.5.2+43a9be4
Steps To Reproduce

Change a DeploymentConfig using an internal image to a StatefulSet.

Current Result

See description above.

Expected Result

I expected the same behavior as with DeploymentConfigs: That kubernetes would pull the image from the internal registry.

zalintyre commented 6 years ago

FYI, i posted this issue at kubernetes first and they think it's an OpenShift issue: https://github.com/kubernetes/kubernetes/issues/55003

smarterclayton commented 6 years ago

oc set image-lookup on an image stream called zookeeper will make it so that an image stream tag for zookeeper:latest will be loaded from the registry when accessed directly in a stateful set, daemonset, deployment, replica set, job, or cronjob.

mfojtik commented 6 years ago

@dsfranzi what Clayton suggested, lemme know if that fixes your problem.

@smarterclayton do we have docs about oc set image-lookup ?

zalintyre commented 6 years ago

oc set image-lookup zookeeper didn't work, the result of oc set image-lookup always stays the same:

$ oc set image-lookup
NAME              LOCAL
solr              false
spark             false
spark-ui-proxy    false
zeppelin          false
zookeeper         false
zoonavigator-api  false
zoonavigator-web  false

I also tried to delete the ImageStream and redeploy my template with this config (lookupPolicy: local), but still no luck:

  # ImageStream
  - apiVersion: v1
    kind: ImageStream
    metadata:
      name: zookeeper
    spec:
      lookupPolicy:
        local: true
      tags:
        - annotations: null
          from:
            kind: DockerImage
            name: 'zookeeper:latest'
          generation: null
          importPolicy: {}
          name: latest
          referencePolicy:
            type: ''

P.S.: @mfojtik I think you mentioned this piece of documentation: https://docs.openshift.com/container-platform/3.6/dev_guide/managing_images.html#using-is-with-k8s ?

smarterclayton commented 6 years ago

set-image lookup only works on 3.6 and above

zalintyre commented 6 years ago

So what can I use with 1.5? I don't consider adding the IP address of the internal registry to the image spec a permanent solution.

And the key question is: Why does it work for DeploymentConfigs but not for StatefulSets?

smarterclayton commented 6 years ago

There is no solution for 1.5 for StatefulSets. We added this feature into 3.6 to address the use case, before that it was not possible.

DeploymentConfigs were built with image substitution in mind. There is a trigger field on the API spec that provides this behavior.

On Mon, Nov 6, 2017 at 10:38 AM, Franz Wimmer notifications@github.com wrote:

So what can I use with 1.5? I don't consider adding the IP address of the internal registry to the image spec a permanent solution.

And the key question is: Why does it work for DeploymentConfigs but not for StatefulSets?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/openshift/origin/issues/17157#issuecomment-342186545, or mute the thread https://github.com/notifications/unsubscribe-auth/ABG_p4Y48cr1rMPIBwyGl3_GBsLNKowQks5szyf_gaJpZM4QQSWs .

zalintyre commented 6 years ago

So basically my only workaround - before I can upgrade to 3.6 - is to upload all my images to docker hub?

openshift-bot commented 6 years ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented 6 years ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot commented 6 years ago

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

parkwart commented 5 years ago

i ran into the same issue. was able to resolve from local registry by adding this annotation: *alpha.image.policy.openshift.io/resolve-names: ''** OC Documentaiton