Commit a7ab664c authored by Stephen Nimmo's avatar Stephen Nimmo
Browse files

Added template code, removed gitlab-ci.yml file

parent 08bb7417
Pipeline #73736 failed with stages
in 2 minutes and 16 seconds
services:
- docker:19.03.12-dind
variables:
DOCKER_HOST: "tcp://docker:2375"
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
test:
stage: test
image: openjdk:11
script: ./mvnw -ntp test
\ No newline at end of file
......@@ -45,6 +45,11 @@
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>10.0.0</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
......
package org.opengroup.osdu.streaming.service;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.AppsV1Api;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.V1Deployment;
import io.kubernetes.client.openapi.models.V1DeploymentBuilder;
import io.kubernetes.client.util.Config;
import org.opengroup.osdu.streaming.model.StreamRecord;
import org.springframework.stereotype.Service;
import org.springframework.web.context.annotation.RequestScope;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@Service
@RequestScope
public class DeploymentAdminServiceImpl implements DeploymentAdminService {
CoreV1Api coreV1Api;
AppsV1Api appsV1Api;
public DeploymentAdminServiceImpl() throws IOException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
coreV1Api = new CoreV1Api();
appsV1Api = new AppsV1Api();
}
@Override
public StreamRecord createStream(StreamRecord streamRecord) {
Map<Object, Object> map = parseForNeededFields(streamRecord);
V1Deployment deployment = new V1DeploymentBuilder()
.withNewMetadata()
.withName("TODO")
.endMetadata()
.withNewSpec()
.endSpec()
.build();
try {
appsV1Api.createNamespacedDeployment("default", deployment, null, null, null);
} catch (ApiException e) {
e.printStackTrace();
}
return null;
}
private Map<Object, Object> parseForNeededFields(StreamRecord streamRecord) {
return new HashMap<>();
}
@Override
public StreamRecord getStreamInfo(String id) {
return null;
......@@ -20,7 +60,8 @@ public class DeploymentAdminServiceImpl implements DeploymentAdminService {
@Override
public void startStream(StreamRecord streamRecord) {
//TODO Check if it's deployed
//TODO
}
@Override
......
apiVersion: apps/v1
kind: Deployment
metadata:
name: streams-${stream.deploymentName}-deployment
namespace: osdu-streams
spec:
replicas: 1
selector:
matchLabels:
run: ${stream.deploymentName}
template:
metadata:
labels:
run: ${stream.deploymentName}
spec:
containers:
- image: ${stream.image}
ports:
- containerPort: ${stream.containerPort}
---
apiVersion: v1
kind: Service
metadata:
name: ${stream.deploymentName}-service
labels:
run: ${stream.deploymentName}
spec:
ports:
- port: ${stream.servicePort}
protocol: TCP
selector:
run: ${stream.deploymentName}
\ No newline at end of file
<mxfile host="Electron" modified="2021-10-25T19:22:24.468Z" agent="5.0 (Macintosh; Intel Mac OS X 11_6_0) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/14.9.6 Chrome/89.0.4389.128 Electron/12.0.16 Safari/537.36" etag="2-ATRw-x48F2hRZM0smG" version="14.9.6" type="device"><diagram id="oPQlikl0BSEGqThpAdY3" name="Page-1">7Vvfc9o4EP5reGzH2BjIY4Ck12mvx4XMXO/pRtgC1MiWR5YTyF9/Kyz/kgwYigmdNA+JvZZW0vetVrtrp+OMg/UnjqLVn8zHtGNb/rrjTDq2PejZ8FsKNqnA7VmpYMmJn4q6hWBGXrESZs0S4uO40lAwRgWJqkKPhSH2REWGOGcv1WYLRqujRmiJDcHMQ9SU/kN8sVLSrmUVD/7AZLlSQw9d9SBAWWMliFfIZy8lkXPXccacMZFeBesxphK7DJe03/2Op/nEOA5Fkw6L6XSxGX+Zfvoy+LH++/X5v401/6C0PCOaqAVjEX3wKJFK02mLTYYFZ0noY6nO6jijlxUReBYhTz59AfJBthIBhbsuXCrFmAu83jnjbo4D2A9mARZ8A01Uh8xUNtXblxIPGbirEgVZO6SoX+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ll/smwOKWg6+Hfuq+T0YimcF14OGcNOKHdiWRt+pSZgWdTc1g2P9TF4O1+bb6jHm1BVAVGE3q+vePU6hRflEs8YsXJBlwoEfFmYdYAJ5H7M6nEkSqksoySQkkN8DFuqKJyWhqcAcpEZSXc1Mfe+ir8T6hrH8juNsS8IiAq0f5Ejqsz7rM0zgPoJYe+9K61SgRKxe4S9EGj7oIoiCPfVRIOul4TyOqkDt0/kl/Yplq3XOmIgFR1EKSnyCCpFGzVaIAnxK/2xhUTKnJF4ZSzxW3xOWO2+JQ5wT62OByEnKIrShDPnS5XkrHKBjDFRz15BBiWpte0EoHTMqv3iZhGxbLUfKgVO8EDV+Pf0gpa5kXv0ICShlTzjT3ZF+S/6cqQRe9VVu38znnNoXsnqQdraMzjFLksbeT2Pz6tvZAx7A3O11PmGfB2CxnyhLitOXJ/IqH/7nDP0Mezfbe0jCctqEhjNN18PodrxVlfjlxd77pUPknoRLjuP9g7zP7eQ03U55zHDEdoLb4rP3NI4o/nfAufsf</diagram></mxfile>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment