harbor icon indicating copy to clipboard operation
harbor copied to clipboard

Show attached container labels on UI

Open warmfusion opened this issue 4 years ago • 8 comments

Is your feature request related to a problem? Please describe. We are creating containers with a set of predefined labels as part of our Ci./CD flow. These labels are not visible on the Harbor UI.

Describe the solution you'd like At a minimum it'd be great to be able to view labels on a container from the UI under the 'Overview' section (ie alongside Author, date etc) so that I might find more information about the container which has been embedded into labels.

For example. when using the kaniko builder on a gitlab-ci environment, we are introducing labels as follows;

/kaniko/executor
      --label com.custom.project-namespace="${CI_PROJECT_NAMESPACE}"
      --label com.custom.owner="${GITLAB_USER_EMAIL}"
      --label org.label-schema.vendor="Company Name"
      --label org.label-schema.url="${CI_PROJECT_URL}"
      --label org.label-schema.vcs-ref="${CI_COMMIT_SHA}"
      --label org.label-schema.name="${CI_PROJECT_NAMESPACE}-${CI_PROJECT_NAME}"
      --label org.label-schema.build-date="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
      --context $CI_PROJECT_DIR/
      --dockerfile $CI_PROJECT_DIR/Dockerfile
      --destination harbor.example.com/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}

I'd like to be able to see the URL, Build-Date, and Owner information on the UI such that we can identify a containers 'heritage' when navigating the UI.

warmfusion avatar Nov 12 '20 14:11 warmfusion

I found some documentation about the annotations ui within the system, and that it uses the org.opencontainers paths so updated my configuration as follows;

      --label org.opencontainers.image.url="${CI_PROJECT_URL}"
      --label org.opencontainers.image.revision="${CI_COMMIT_SHA}"
      --label org.opencontainers.image.ref.title="${CI_PROJECT_NAMESPACE}-${CI_PROJECT_NAME}"
      --label org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"

No change in the visibility of these annotations on user interface unfortunately.

warmfusion avatar Nov 12 '20 15:11 warmfusion

The annotation reflects the attributes in oci-image: https://github.com/opencontainers/image-spec/blob/master/annotations.md

Harbor abstracts these data from image manifest: https://github.com/opencontainers/image-spec/blob/master/manifest.md

So I'd suggest you double check if kaniko populate the annotation into manifest while building the image.

reasonerjt avatar Nov 16 '20 06:11 reasonerjt

So using docker inspect on the kaniko built container;

[
    {
        "Config": {
            ...
            "Labels": {
                "com.custom.owner": "toby.jackson@REDACT",
                "com.custom.project-namespace": "tjackson02",
                "org.opencontainers.image.created": "2020-11-12T14:54:17Z",
                "org.opencontainers.image.ref.title": "tjackson02-knockknock",
                "org.opencontainers.image.revision": "84d4d2bb30d797d2a52ee32fc357d837a70ce29d",
                "org.opencontainers.image.url": "https://REDACT/tjackson02/knockknock",
                "org.opencontainers.image.vendor": "Company Name"
            }
        }
    }
]

Based on your links I suspect the information is being added, but perhaps in the wrong area of the manifests?

How can I see the OCI manifest file for a built container (if possible?)

warmfusion avatar Nov 19 '20 11:11 warmfusion

These labels, at least the org.label-schema ones are from label-schema.org which appears to be gaining some traction. It would be great to expose them in the UI, or even use them to populate the repository info page.

deedubs avatar Dec 04 '20 15:12 deedubs

We've just successfully migrated from Harbor 2.1 to 2.2.1, mainly because we were hopeful to now see the image labels on the UI, based on https://github.com/goharbor/harbor/pull/13014.

Unfortunately, hopes were shattered.

Well, technically, the labels are now visible on the UI, but only as part of the "Config" attribute of the image. This is what we are seeing now with Harbor 2.2:

grafik

Well, okay, the labels are visible. But the way they are presented is not really useful, isn't it? You also cannot retrieve the labels using the REST API this way. (Well, you technically can, but you would have to parse the config-attribute by yourself. Again, not really useful).

I've created a mockup of what I've hoped to see in Harbor 2.2:

grafik

As you can see, I've added a new table "Labels" directly below the existing "Overview" table. This way, the labels are properly presented. (As an alternative to the new "Labels" table, I think it would also be totally fine to just add all the labels to the existing "Overview" table. I guess this would be easier, because there would be no need to change any models.)

ChristianCiach avatar Mar 31 '21 16:03 ChristianCiach

I've just learned that "Annotations" and "Labels" are not the same thing. "Labels" are not shown on the "Overview"-table, but "Annotations" are.

Unfortunately, it doesn't seem to be possible to add proper annotations when creating images using docker build. To add annotations to OCI artifacts, Podman or Buildah should be used to build the images.

This is slightly disappointing, because we're still using Docker for our build pipelines.

Anyway, I still think Harbor should also show the Config -> Labels of Docker-images on the UI, not just the annotations.

ChristianCiach avatar Mar 31 '21 16:03 ChristianCiach

After reading comments here and in related issues, i can't understand: is there any actual way to utilize "Labels" or "Annotations" columns in Harbor UI? I get that labels coming from dockerfile LABEL k=v or kaniko --label k=v are not OCI annotations, and i can't find any information on how to edit manifest when creating an image to add annotations there. Since these columns exist in UI, i suppose someone is using them? How?

Rast1234 avatar Nov 09 '21 00:11 Rast1234

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

github-actions[bot] avatar Jul 06 '22 09:07 github-actions[bot]

I still don't get it. In our build pipeline I am adding labels to our images before pushing them to Harbor. But in Harbor the labels columns is just empty although there are shown in the JSON representation in the config. How can I make them visible in the UI? image

ngoeddel-openi avatar Mar 05 '24 12:03 ngoeddel-openi

@ngoeddel-openi, these labels you see are Harbor Labels. You set, edit and view them only in Harbor.

Vad1mo avatar Mar 05 '24 13:03 Vad1mo