WIP Prototype multicluster sdk#169
WIP Prototype multicluster sdk#169KevinFCormier wants to merge 5 commits intoredhat-developer:mainfrom
Conversation
Signed-off-by: Kevin Cormier <kcormier@redhat.com>
Signed-off-by: Kevin Cormier <kcormier@redhat.com>
Signed-off-by: Kevin Cormier <kcormier@redhat.com>
Signed-off-by: Kevin Cormier <kcormier@redhat.com>
Signed-off-by: Kevin Cormier <kcormier@redhat.com>
| useIsFleetAvailable, | ||
| } from '@stolostron/multicluster-sdk'; | ||
|
|
||
| export function useMulticlusterK8sWatchResource<T extends K8sResourceCommon | K8sResourceCommon[]>( |
There was a problem hiding this comment.
@keithchong The useFleetK8sWatchResource(s) hooks are good for getting data directly from a single cluster, over the cluster-proxy if this is a managed cluster rather than the hub.
If you want data from the entire fleet, we have useFleetSearchPoll that gets a subset of data from ACM search. We can work with the search team to have additional fields indexed if you need them on a page that can show resources from across the fleet.
|
|
||
| useEffect(() => { | ||
| if (isFleetAvailable) { | ||
| setFeatureFlag(FLAG_GITOPS_MULTICLUSTER, isFleetAvailable); |
There was a problem hiding this comment.
Since your console-extensions.json file is JSON and not TypeScript, you can call our hook to check if multicluster SDK is available. If it was in TypeScript, you could use the REQUIRED_PROVIDER_FLAG constant directly. See https://www.npmjs.com/package/@stolostron/multicluster-sdk#gear-required_provider_flag
This will be modified when there is a new minimum version of ACM required for new features in the SDK. Checking via useIsFleetAvailable will be checking for the same flag, so this is a valid way to do it as well.
| /> | ||
| </PfLabel> | ||
| </FlexItem> | ||
| {sources && sources.length && revisions && revisions.length && ( |
There was a problem hiding this comment.
On some apps created in ACM, I'm finding sources is not always defined. And from ACM search, we will not have this information currently.
| <Title headingLevel="h2">{obj.kind} events</Title> | ||
| </PageSection> | ||
| {obj && <ResourceEventStream resource={obj} />} | ||
| {obj && <FleetResourceEventStream resource={obj} />} |
There was a problem hiding this comment.
Drop-in replacement that will work over cluster-proxy if obj.cluster is defined.
| {app.cluster !== hubClusterName ? ( | ||
| <Link | ||
| to={`/k8s/cluster/${app.cluster}/ns/${app.metadata.namespace}/argoproj.io~v1alpha1~Application/${app.metadata.name}`} | ||
| > | ||
| {app.metadata.name} | ||
| </Link> | ||
| ) : ( | ||
| <ResourceLink | ||
| groupVersionKind={modelToGroupVersionKind(ApplicationModel)} | ||
| name={app.metadata.name} | ||
| namespace={app.metadata.namespace} | ||
| // cluster={app.cluster} | ||
| inline={true} | ||
| > | ||
| <span className="pf-u-pl-sm"> | ||
| {isApplicationRefreshing(app) && <Spinner size="sm" />} | ||
| </span> | ||
| </ResourceLink> | ||
| )} |
There was a problem hiding this comment.
Normally I would recommend just converting to a <FleetResourceLink> here, but the problem is that ACM currently considers itself to be the plugin responsible for displaying Argo apps. See https://github.com/stolostron/console/blob/main/frontend/plugins/acm/console-extensions.ts#L242
That extension allows plugins to declare that they have a route for displaying a given resource kind.
| "/k8s/cluster/:cluster/ns/:ns/argoproj.io~v1alpha1~Application/:name" | ||
| ] | ||
| }, | ||
| "type": "console.page/route" |
There was a problem hiding this comment.
Because multicluster support is not native to OCP, you need to have your own route defined for multicluster resources.
| const { | ||
| cluster, | ||
| name, | ||
| ns: namespace, | ||
| } = useParams<{ | ||
| cluster?: string; | ||
| name: string; | ||
| ns: string; | ||
| }>(); |
There was a problem hiding this comment.
Because for the multicluster route it is not behaving as a "console.page/resource/details" extension, the details will not be passed as propped. Getting them from URL params in both single and multicluster case.
No description provided.