Azure Container Registry plugin for Backstage

Red Hat Developer Hub 0.2

The Azure Container Registry (ACR) plugin for Backstage

Red Hat Customer Content Services

Abstract

The ACR plugin displays information about your container images available in the Azure Container Registry.

Chapter 1. Azure Container Registry plugin for Backstage

The Azure Container Registry (ACR) plugin displays information about your container images available in the Azure Container Registry.

1.1. For administrators

1.1.1. Installing and configuring the ACR plugin

The Red Hat Plug-ins for Backstage (RHPIB) packages are hosted in a separate NPM registry, which is maintained by Red Hat. To use these packages, you must adjust your NPM configuration to pull the @redhat scoped packages:

# update your .npmrc or .yarnrc file
yarn config set "@redhat:registry" https://npm.registry.redhat.com
# then pull a package
yarn add @redhat/backstage-plugin-quay

For more information, see npm docs.

Creating a .npmrc file ensures that all the packages are scoped under @redhat and are fetched from Red Hat’s NPM registry, while the rest dependencies remain sourced from other registry.

Procedure

  1. Run the following command to install the ACR plugin:

    yarn workspace app add @redhat/backstage-plugin-acr
  2. Set the proxy to the desired ACR server in the app-config.yaml file as follows:

       # app-config.yaml
       proxy:
         '/acr/api':
           target: 'https://mycontainerregistry.azurecr.io/acr/v1/'
           changeOrigin: true
           headers:
             # If you use Bearer Token for authorization, please replace the 'Basic' with 'Bearer' in the following line.
             Authorization: 'Basic ${ACR_AUTH_TOKEN}'
           # Change to "false" in case of using self hosted artifactory instance with a self-signed certificate
           secure: true
  3. Set the authorization using one of the following options:

    • Basic authorization:

      • Navigate to the ACR portal and go to the Access Keys tab.
      • Retrieve the username and password of the Admin user and use the [Basic Auth Header Generator tool](https://www.debugbear.com/basic-auth-header-generator) or run echo printf '<username>:<password>' | base64 in a terminal to convert the credentials to a basic token.
      • Set the generated token as ACR_AUTH_TOKEN in environment variables.
    • OAuth2:

      • Generate bearer access token using the process described in Authenticate with an Azure Container Registry.

        You can generate a bearer token using your basic authorization token, for example:

        curl --location 'https://<yourregistry>.azurecr.io/oauth2/token?scope=repository%3A*%3A*&service=<yourregistry>.azurecr.io' \ --header 'Authorization: Basic <basic_token>'
      • Set the generated token as ACR_AUTH_TOKEN in environment variables. Also ensure that you replace the Basic with Bearer in the app-config.yaml file.
  4. Enable an additional tab on the entity view page using the packages/app/src/components/catalog/EntityPage.tsx file as follows:

    /* highlight-add-start */
    import { AcrPage, isAcrAvailable } from '@redhat/backstage-plugin-acr';
    
    /* highlight-add-end */
    
    const serviceEntityPage = (
      <EntityPageLayout>
        // ...
        {/* highlight-add-start */}
        <EntityLayout.Route path="/acr" title="ACR">
          <Grid container spacing={3} alignItems="stretch">
            <EntitySwitch>
              <EntitySwitch.Case if={e => Boolean(isAcrAvailable(e))}>
                <Grid item sm={12}>
                  <AcrPage />
                </Grid>
              </EntitySwitch.Case>
            </EntitySwitch>
          </Grid>
        </EntityLayout.Route>
        {/* highlight-add-end */}
      </EntityPageLayout>
    );
  5. Annotate your entity using the following annotations:

    metadata:
        annotations:
            'azure-container-registry/repository-name': `<REPOSITORY-NAME>',

1.2. For users

1.2.1. Using the ACR plugin in Backstage

ACR is a front-end plugin that enables you to view information about the container images from your Azure Container Registry in Backstage.

Prerequisites

Procedure

  1. Open your Backstage application and select a component from the Catalog page.
  2. Go to the ACR tab.

    acr-tab

    The ACR tab in the Backstage UI contains a list of container images and related information, such as TAG, CREATED, LAST MODIFIED, and MANIFEST.

Legal Notice

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.