Skip to content

Commit

Permalink
test updates for cluster wide and single namespace notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ukclivecox committed Dec 7, 2018
1 parent 51ba6f7 commit 05a8729
Show file tree
Hide file tree
Showing 7 changed files with 1,111 additions and 2,926 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import io.seldon.apife.deployments.DeploymentStore;
import io.seldon.apife.deployments.DeploymentsHandler;
import io.seldon.apife.exception.SeldonAPIException;
import io.seldon.apife.k8s.KubernetesUtil;
import io.seldon.protos.DeploymentProtos.SeldonDeployment;

@Component
Expand All @@ -63,6 +64,7 @@ public class SeldonGrpcServer {
public static final int TIMEOUT = 5;
private int maxMessageSize = io.grpc.internal.GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE;
private int grpcReadTimeout = DEFAULT_GRPC_READ_TIMEOUT;
private final KubernetesUtil k8sUtil = new KubernetesUtil();

@Autowired
public SeldonGrpcServer(AppProperties appProperties,DeploymentStore deploymentStore,TokenStore tokenStore,DeploymentsHandler deploymentsHandler,AnnotationsConfig annotations)
Expand Down Expand Up @@ -207,8 +209,13 @@ private void blockUntilShutdown() throws InterruptedException {
}

public void deploymentAdded(SeldonDeployment resource) {
ManagedChannel channel = ManagedChannelBuilder.forAddress(resource.getSpec().getName(), appProperties.getEngineGrpcContainerPort()).usePlaintext(true).build();
channelStore.put(resource.getSpec().getOauthKey(),channel);
final String namespace = k8sUtil.getNamespace(resource);
final String endpoint = resource.getSpec().getName() + "." + namespace;
final ManagedChannel channel = ManagedChannelBuilder.forAddress(endpoint, appProperties.getEngineGrpcContainerPort()).usePlaintext(true).build();
if (appProperties.isSingleNamespace())
channelStore.put(resource.getSpec().getOauthKey(),channel);
final String namespacedKey = resource.getSpec().getOauthKey() + namespace;
channelStore.put(namespacedKey,channel);
}

public void deploymentRemoved(SeldonDeployment resource) {
Expand Down
17 changes: 17 additions & 0 deletions api-frontend/src/main/java/io/seldon/apife/k8s/KubernetesUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.seldon.apife.k8s;

import org.apache.commons.lang3.StringUtils;

import io.seldon.protos.DeploymentProtos.SeldonDeployment;

public class KubernetesUtil {

public String getNamespace(SeldonDeployment d)
{
if (StringUtils.isEmpty(d.getMetadata().getNamespace()))
return "default";
else
return d.getMetadata().getNamespace();
}

}
Loading

0 comments on commit 05a8729

Please sign in to comment.