🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

@stolostron/multicluster-sdk

Package Overview
Dependencies
Maintainers
5
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stolostron/multicluster-sdk

Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.

Source
npmnpm
Version
0.3.4
Version published
Weekly downloads
547
-1.08%
Maintainers
5
Weekly downloads
 
Created
Source

Multicluster SDK for OpenShift Console

A React SDK for working with multicluster OpenShift/Kubernetes resources from the OpenShift Console.

This SDK provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management (RHACM). It aims to provide similar functionality to the dynamic plugin(https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk) SDK but for multicluster scenarios.

Prerequisites

  • Red Hat Advanced Cluster Management for Kubernetes 2.15+

Installation

npm install @stolostron/multicluster-sdk

Usage

The multicluster SDK provides components and hooks that enable your dynamic plugins to work with resources across multiple clusters.

Basic Setup

Setup depends on your usage scenarios.

  • For pages that deal with a single cluster at a time, you can replace hooks, functions, and components from the dynamic plugin SDK with their drop-in replacements from the multicluster SDK. When a compatible version of RHACM is installed on the cluster and a cluster name is given in the arguments or properties of an SDK API, an implementation that works with data from the specified managed cluster will be used. Otherwise, we fall back to the single cluster implementation from the dynamic plugin SDK and work with data on the local cluster.
  • For other APIs that work with multiple clusters at a time (such as functions that leverage RHACM's search capabilities) and do not have an equivalent in the dyanamic plugin SDK, you can call the useIsFleetAvailable hook to check if support is available. Because it is not permitted to call hooks conditionally, if you are using these multicluster SDK hooks, then you must call them with arguments that render the hook in a disabled state when fleet support is unavailable. Otherwise you will get empty results or errors. See the API Reference for details.
  • If you have entire routes or navigation items or any other type of dynamic plugin extension that should only be enabled when multicluster support is available, you can make them conditional on a flag. RHACM enables flags indicating that it provides the prerequisites of the multicluster SDK. This is a versioned flag and within any version of the multicluster SDK, its name is available as the REQUIRED_PROVIDER_FLAG constant.

Working with Resources

// Example code will be added after API stabilization

API Reference

:toolbox: Functions

:gear: fleetK8sCreate

FunctionType
fleetK8sCreate<R extends K8sResourceCommon>(options: OptionsCreate<R>) => Promise<R>

:link: Source

:gear: fleetK8sDelete

FunctionType
fleetK8sDelete<R extends K8sResourceCommon>(options: OptionsDelete<R>) => Promise<R>

:link: Source

:gear: fleetK8sGet

FunctionType
fleetK8sGet<R extends K8sResourceCommon>(options: OptionsGet) => Promise<R>

:link: Source

:gear: fleetK8sPatch

FunctionType
fleetK8sPatch<R extends K8sResourceCommon>(options: OptionsPatch<R>) => Promise<R>

:link: Source

:gear: fleetK8sUpdate

FunctionType
fleetK8sUpdate<R extends K8sResourceCommon>(options: OptionsUpdate<R>) => Promise<R>

:link: Source

FunctionType
FleetResourceLinkReact.FC<FleetResourceLinkProps>

:link: Source

:gear: getFleetK8sAPIPath

FunctionType
getFleetK8sAPIPath(cluster?: string or undefined) => Promise<string>

:link: Source

:gear: useFleetAccessReview

Hook that provides information about user access to a given resource.

FunctionType
useFleetAccessReview({ group, resource, subresource, verb, name, namespace, cluster, }: FleetAccessReviewResourceAttributes) => [boolean, boolean]

Parameters:

  • resourceAttributes: resource attributes for access review
  • resourceAttributes.group: the name of the group to check access for
  • resourceAttributes.resource: the name of the resource to check access for
  • resourceAttributes.subresource: the name of the subresource to check access for
  • resourceAttributes.verb: the "action" to perform; one of 'create' | 'get' | 'list' | 'update' | 'patch' | 'delete' | 'deletecollection' | 'watch' | 'impersonate'
  • resourceAttributes.name: the name
  • resourceAttributes.namespace: the namespace
  • resourceAttributes.cluster: the cluster name to find the resource in

Returns:

Array with isAllowed and loading values.

:link: Source

:gear: useFleetClusterNames

FunctionType
useFleetClusterNamesUseFleetClusterNames

:link: Source

:gear: useFleetK8sAPIPath

FunctionType
useFleetK8sAPIPathUseFleetK8sAPIPath

:link: Source

:gear: useFleetK8sWatchResource

FunctionType
useFleetK8sWatchResourceUseFleetK8sWatchResource

:link: Source

:gear: useFleetPrometheusPoll

FunctionType
useFleetPrometheusPollUsePrometheusPoll

:link: Source

:gear: useHubClusterName

FunctionType
useHubClusterNameUseHubClusterName

:link: Source

:gear: useMulticlusterSearchWatch

FunctionType
useMulticlusterSearchWatchUseMulticlusterSearchWatch

:link: Source

:cocktail: Types

:gear: Fleet

TypeType
FleetT and { cluster?: string }

:link: Source

:gear: FleetK8sResourceCommon

TypeType
FleetK8sResourceCommonFleet<K8sResourceCommon>

:link: Source

:gear: FleetResourceLinkProps

TypeType
FleetResourceLinkPropsFleet<ResourceLinkProps>

:link: Source

:gear: UseFleetClusterNames

TypeType
UseFleetClusterNames() => [string[], boolean, any]

:link: Source

:gear: UseFleetK8sAPIPath

TypeType
UseFleetK8sAPIPath( cluster?: string ) => [k8sAPIPath: string or undefined, loaded: boolean, error: Error or undefined]

:link: Source

:gear: UseFleetK8sWatchResource

TypeType
UseFleetK8sWatchResource<R extends FleetK8sResourceCommon or FleetK8sResourceCommon[]>( initResource: FleetWatchK8sResource or null ) => WatchK8sResult<R> or [undefined, boolean, any]

:link: Source

:gear: UseHubClusterName

TypeType
UseHubClusterName() => [hubClusterName: string or undefined, loaded: boolean, error: any]

:link: Source

Utilities

  • Fleet resource typing support through TypeScript interfaces

Contributing

All contributions to the repository must be submitted under the terms of the Apache Public License 2.0. For contribution guidelines, see CONTRIBUTING.md.

Keywords

multicluster

FAQs

Package last updated on 07 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts