-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[issue-212] - Add ODH application, provisioning and tests
- Loading branch information
Showing
13 changed files
with
775 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...c/main/java/org/jboss/intersmash/application/operator/OpenDataHubOperatorApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
112 changes: 112 additions & 0 deletions
112
...ava/org/jboss/intersmash/provision/openshift/OpenDataHubOpenShiftOperatorProvisioner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.