Skip to content

Commit

Permalink
[issue-212] - Add ODH application, provisioning and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiobrz committed Jan 7, 2025
1 parent c8e6327 commit c3e201f
Show file tree
Hide file tree
Showing 13 changed files with 775 additions and 4 deletions.
23 changes: 23 additions & 0 deletions core/src/main/java/org/jboss/intersmash/IntersmashConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ public class IntersmashConfig {
private static final String HYPERFOIL_OPERATOR_PACKAGE_MANIFEST = "intersmash.hyperfoil.operators.package_manifest";
private static final String COMMUNITY_HYPERFOIL_OPERATOR_PACKAGE_MANIFEST = "hyperfoil-bundle";
private static final String DEFAULT_HYPERFOIL_OPERATOR_PACKAGE_MANIFEST = COMMUNITY_HYPERFOIL_OPERATOR_PACKAGE_MANIFEST;
private static final String OPEN_DATA_HUB_OPERATOR_CATALOG_SOURCE_NAME = "intersmash.odh.operators.catalog_source";
private static final String OPEN_DATA_HUB_OPERATOR_INDEX_IMAGE = "intersmash.odh.operators.index_image";
private static final String OPEN_DATA_HUB_OPERATOR_CHANNEL = "intersmash.odh.operators.channel";
private static final String OPEN_DATA_HUB_OPERATOR_PACKAGE_MANIFEST = "intersmash.odh.operators.package_manifest";
private static final String COMMUNITY_OPEN_DATA_HUB_OPERATOR_PACKAGE_MANIFEST = "opendatahub-operator";
private static final String DEFAULT_OPEN_DATA_HUB_OPERATOR_PACKAGE_MANIFEST = COMMUNITY_OPEN_DATA_HUB_OPERATOR_PACKAGE_MANIFEST;

// Bootable Jar
private static final String BOOTABLE_JAR_IMAGE_URL = "intersmash.bootable.jar.image";

Expand Down Expand Up @@ -407,4 +414,20 @@ public static String keycloakOperatorChannel() {
public static String keycloakOperatorPackageManifest() {
return XTFConfig.get(KEYCLOAK_OPERATOR_PACKAGE_MANIFEST, DEFAULT_KEYCLOAK_OPERATOR_PACKAGE_MANIFEST);
}

public static String openDataHubOperatorCatalogSource() {
return XTFConfig.get(OPEN_DATA_HUB_OPERATOR_CATALOG_SOURCE_NAME, defaultOperatorCatalogSourceName());
}

public static String openDataHubOperatorIndexImage() {
return XTFConfig.get(OPEN_DATA_HUB_OPERATOR_INDEX_IMAGE);
}

public static String openDataHubOperatorChannel() {
return XTFConfig.get(OPEN_DATA_HUB_OPERATOR_CHANNEL);
}

public static String openDataHubOperatorPackageManifest() {
return XTFConfig.get(OPEN_DATA_HUB_OPERATOR_PACKAGE_MANIFEST, DEFAULT_OPEN_DATA_HUB_OPERATOR_PACKAGE_MANIFEST);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (C) 2024 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.intersmash.application.operator;

import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.dscinitialization.v1.DSCInitialization;

/**
* End user Application interface which presents an Open Data Hub/OpenShift AI operator application.
* Only relevant model APIs are currently exposed, more would be added on demand
*
* The application will be deployed by:
* <ul>
* <li>{@link org.jboss.intersmash.provision.operator.OpenDataHubOperatorProvisioner}</li>
* </ul>
*/
public interface OpenDataHubOperatorApplication extends OperatorApplication {

/**
* Provides read access to the deployed {@link DataScienceCluster} instance.
* @return A {@link DataScienceCluster} instance that is deployed.
*/
DataScienceCluster getDataScienceCluster();

/**
* Provides read access to the {@link DSCInitialization} instance that should be used to initialize the
* deployed {@link DataScienceCluster}, represented by {@link #getDataScienceCluster} getter.
* @return A {@link DSCInitialization} instance that configures the deployed {@link DataScienceCluster}
*/
DSCInitialization getDSCInitialization();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* Copyright (C) 2023 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.intersmash.provision.openshift;

import org.jboss.intersmash.application.operator.OpenDataHubOperatorApplication;
import org.jboss.intersmash.provision.operator.OpenDataHubOperatorProvisioner;
import org.jboss.intersmash.provision.operator.model.odh.DSCInitializationList;
import org.jboss.intersmash.provision.operator.model.odh.DataScienceClusterList;
import org.jboss.intersmash.provision.operator.model.odh.FeatureTrackerList;
import org.jboss.intersmash.provision.operator.model.odh.MonitoringList;

import cz.xtf.core.openshift.OpenShifts;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinitionList;
import io.fabric8.kubernetes.client.NamespacedKubernetesClientAdapter;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperationsImpl;
import io.fabric8.openshift.client.NamespacedOpenShiftClient;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.dscinitialization.v1.DSCInitialization;
import io.opendatahub.features.v1.FeatureTracker;
import io.opendatahub.platform.services.v1alpha1.Monitoring;
import lombok.NonNull;

public class OpenDataHubOpenShiftOperatorProvisioner
// leverage Open Data Hub common Operator based provisioner behavior
extends OpenDataHubOperatorProvisioner<NamespacedOpenShiftClient>
// ... and common OpenShift provisioning logic, too
implements OpenShiftProvisioner<OpenDataHubOperatorApplication> {

private static final String OPENSHIFT_OPERATORS_NAMESPACE = "openshift-operators";

public OpenDataHubOpenShiftOperatorProvisioner(
@NonNull OpenDataHubOperatorApplication application) {
super(application);
}

@Override
protected String getTargetNamespace() {
return OPENSHIFT_OPERATORS_NAMESPACE;
}

@Override
public NamespacedKubernetesClientAdapter<NamespacedOpenShiftClient> client() {
return OpenShifts.admin();
}

@Override
public String execute(String... args) {
return OpenShiftProvisioner.super.execute(args);
}

// =================================================================================================================
// Related to generic provisioning behavior
// =================================================================================================================
@Override
protected void removeClusterServiceVersion() {
this.execute("delete", "csvs", currentCSV, "-n", this.getTargetNamespace(), "--ignore-not-found");
}

@Override
protected void removeSubscription() {
this.execute("delete", "subscription", packageManifestName, "-n", this.getTargetNamespace(), "--ignore-not-found");
}

// =================================================================================================================
// Client related
// =================================================================================================================
@Override
public NonNamespaceOperation<CustomResourceDefinition, CustomResourceDefinitionList, Resource<CustomResourceDefinition>> customResourceDefinitionsClient() {
return OpenShifts.admin().apiextensions().v1().customResourceDefinitions();
}

@Override
protected HasMetadataOperationsImpl<DataScienceCluster, DataScienceClusterList> dataScienceClusterCustomResourcesClient(
CustomResourceDefinitionContext crdc) {
return OpenShifts.admin().newHasMetadataOperation(crdc, DataScienceCluster.class, DataScienceClusterList.class);
}

@Override
protected HasMetadataOperationsImpl<DSCInitialization, DSCInitializationList> dscInitializationCustomResourcesClient(
CustomResourceDefinitionContext crdc) {
return OpenShifts.admin().newHasMetadataOperation(crdc, DSCInitialization.class, DSCInitializationList.class);
}

@Override
protected HasMetadataOperationsImpl<FeatureTracker, FeatureTrackerList> featureTrackerCustomResourcesClient(
CustomResourceDefinitionContext crdc) {
return OpenShifts.admin().newHasMetadataOperation(crdc, FeatureTracker.class, FeatureTrackerList.class);
}

@Override
protected HasMetadataOperationsImpl<Monitoring, MonitoringList> monitoringCustomResourcesClient(
CustomResourceDefinitionContext crdc) {
return OpenShifts.admin().newHasMetadataOperation(crdc, Monitoring.class, MonitoringList.class);
}
}
Loading

0 comments on commit c3e201f

Please sign in to comment.