Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
update operator test
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmikechen committed Nov 25, 2023
1 parent 32a42f2 commit 53c108d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.submarine.server.k8s.agent;

import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.javaoperatorsdk.operator.Operator;
import io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider;
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
Expand Down Expand Up @@ -49,10 +47,8 @@ public class SubmarineAgentListener {
public static final DateTimeFormatter DTF = DateTimeFormatter.ISO_DATE_TIME;

public static void main(String[] args) throws IOException {
// create kubernetes client
KubernetesClient client = new KubernetesClientBuilder().build();
// create operator
Operator operator = new Operator(client);
Operator operator = new Operator();
// scan all Reconciler implemented subclasses
Reflections reflections = new Reflections("org.apache.submarine.server.k8s.agent");
Set<Class<? extends Reconciler>> reconcilers = reflections.getSubTypesOf(Reconciler.class);
Expand All @@ -69,8 +65,6 @@ public static void main(String[] args) throws IOException {
}
);
LOGGER.info("Starting agent with SUBMARINE_UID={}", OwnerReferenceConfig.getSubmarineUid());
// Adds a shutdown hook that automatically calls stop() when the app shuts down.
operator.installShutdownHook();
// start operator
operator.start();
// Provide a lightweight service to handle health checks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import io.fabric8.kubernetes.api.model.OwnerReferenceBuilder;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
import io.fabric8.kubernetes.internal.KubernetesDeserializer;
import io.javaoperatorsdk.operator.Operator;
import org.apache.ibatis.session.SqlSession;
import org.apache.submarine.commons.utils.SubmarineConfiguration;
Expand Down Expand Up @@ -103,10 +101,10 @@ public static void beforeInit() {

// set client and operator
client = server.getClient();
operator = new Operator(client);
operator = new Operator(client, null);

// create notbook resource
KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1","Notebook", NotebookResource.class);
client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1","Notebook", NotebookResource.class);
CustomResourceDefinition notebookCrd = client
.apiextensions().v1()
.customResourceDefinitions()
Expand All @@ -116,7 +114,7 @@ public static void beforeInit() {
client.apiextensions().v1().customResourceDefinitions().createOrReplace(notebookCrd);

// create tf resource
KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1", "TFJob", TFJob.class);
client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1", "TFJob", TFJob.class);
CustomResourceDefinition tfCrd = client
.apiextensions().v1()
.customResourceDefinitions()
Expand All @@ -126,7 +124,7 @@ public static void beforeInit() {
client.apiextensions().v1().customResourceDefinitions().create(tfCrd);

// create pytorch resource
KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1", "PyTorchJob", PyTorchJob.class);
client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1", "PyTorchJob", PyTorchJob.class);
CustomResourceDefinition ptCrd = client
.apiextensions().v1()
.customResourceDefinitions()
Expand All @@ -136,7 +134,7 @@ public static void beforeInit() {
client.apiextensions().v1().customResourceDefinitions().create(ptCrd);

// create xgboost resource
KubernetesDeserializer.registerCustomKind("apiextensions.k8s.io/v1", "XGBoostJob", XGBoostJob.class);
client.getKubernetesSerialization().registerKubernetesResource("apiextensions.k8s.io/v1", "XGBoostJob", XGBoostJob.class);
CustomResourceDefinition xgbCrd = client
.apiextensions().v1()
.customResourceDefinitions()
Expand Down

0 comments on commit 53c108d

Please sign in to comment.