Changing image scope

You can change the scope of an image to restrict or expand its availability within the cluster.

By default, images in the private image registry are assigned to the namespace scope. You can make the images available to all namespaces by setting a global scope or limit the images to a specific namespace.

Required user type or access level: Cluster administrator, team administrator, editor, or operator

You must have access to the namespace that currently contains the image. You can assign images to a scope of either global or namespace. An image with the scope namespace is accessible from within a single namespace only, but an image with the global scope can be accessed from all namespaces.

Changing the image scope from the management console

  1. From the navigation menu, click Container Images.
  2. For the image that you want to update, click the Options icon (Options icon) and select Change Scope.
  3. Select the scope from the drop-down menu in the Image dialog box.
  4. Click Change Image Scope.

Changing the image scope from the command line

  1. Configure the kubectl CLI. See Accessing your IBM Cloud Private cluster by using the kubectl CLI for more information.
  2. Edit the image.

    • To change the scope from namespace to global, run the following command:

      kubectl get image <image name> -n=namespace -o yaml \
      | sed 's/scope: namespace/scope: global/g' | kubectl replace -f -
      

      The <image name> value is the name of the image that you want to move.

    • To change the scope from global to namespace, run the following command:

      kubectl get image <image name> -n=namespace -o yaml \
      | sed 's/scope: global/scope: namespace/g' | kubectl replace -f -
      

      For example, to change the image scope of an image that is named dev/keepalived from global to namespace. Run the following command:

      kubectl get image keepalived -n=dev -o yaml \
      | sed 's/scope: global/scope: namespace/g' | kubectl replace -f -
      

The scope of your image is changed.