Skip to content

WIP Prototype multicluster sdk#169

Draft
KevinFCormier wants to merge 5 commits intoredhat-developer:mainfrom
KevinFCormier:prototype-multicluster-sdk
Draft

WIP Prototype multicluster sdk#169
KevinFCormier wants to merge 5 commits intoredhat-developer:mainfrom
KevinFCormier:prototype-multicluster-sdk

Conversation

@KevinFCormier
Copy link

No description provided.

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[]>(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 && (
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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} />}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop-in replacement that will work over cluster-proxy if obj.cluster is defined.

Comment on lines +336 to +354
{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>
)}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +476 to +479
"/k8s/cluster/:cluster/ns/:ns/argoproj.io~v1alpha1~Application/:name"
]
},
"type": "console.page/route"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because multicluster support is not native to OCP, you need to have your own route defined for multicluster resources.

Comment on lines +23 to +31
const {
cluster,
name,
ns: namespace,
} = useParams<{
cluster?: string;
name: string;
ns: string;
}>();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant