Skip to content

oc import-image attempts to watch all imagestream of namespace after an import  #13214

Closed
@AlbertoPeon

Description

@AlbertoPeon
Version

$ oc version
oc v1.4.1+3f9807a
kubernetes v1.4.0+776c994
features: Basic-Auth

Problem description

We have a set of images that we build outside of OpenShift, push to an external Docker registry and then we import them to OpenShif with oc import-image.

For that, a lightweight serviceaccount is provisioned and assigned the following role:

apiVersion: v1
kind: Role
metadata:
 ....
rules:
- apiGroups:
  - ""
  attributeRestrictions: null
  resourceNames:
  - image_name
  resources:
  - imagestreams
  - imagestreams/layers
  verbs:
  - create
  - delete
  - edit
  - get
  - list
  - update
  - watch

As you can see, we only allow to modify resources with name 'image_name'

However, when running oc import-image:

$ oc import-image $image:$tag -n openshift --token $token
Importing (ctrl+c to stop waiting) ...
error: unable to determine if the import completed successfully - please run 'oc describe -n openshift imagestream/image' to see if the tags were updated as expected: User "system:serviceaccount:openshift:sa" cannot watch imagestreams in project "openshift"

The import actually succeeds but the command fails (returns != 0 status code) trying to display the imported images. It seems that the command tries to watch all the imagestreams in the namespace?

As a workaround, I can add an extra rule to the role defined above like:

  - apiGroups:
    - ""
    attributeRestrictions: null
    resources:
    - imagestreams
    verbs:
    - watch

However, it will be more convenient if this permission wasn't required to just import images.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions