Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Data Flow
Real Time
Streams
Stream Admin Service
Commits
3cdc5bfe
Commit
3cdc5bfe
authored
Oct 26, 2021
by
Stephen Nimmo
Browse files
Incremental update of DeploymentAdminServiceImpl
parent
c6a5706d
Pipeline
#73959
passed with stage
in 1 minute and 15 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
3cdc5bfe
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<java.version>
1
.8
</java.version>
<java.version>
1
1
</java.version>
<maven.compiler.source>
${java.version}
</maven.compiler.source>
<maven.compiler.source>
${java.version}
</maven.compiler.source>
<maven.compiler.target>
${java.version}
</maven.compiler.target>
<maven.compiler.target>
${java.version}
</maven.compiler.target>
<!-- Dependency Versions -->
<!-- Dependency Versions -->
...
@@ -105,6 +105,14 @@
...
@@ -105,6 +105,14 @@
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
9
</source>
<target>
9
</target>
</configuration>
</plugin>
</plugins>
</plugins>
</build>
</build>
...
...
src/main/java/org/opengroup/osdu/streaming/service/DeploymentAdminServiceImpl.java
View file @
3cdc5bfe
...
@@ -5,52 +5,70 @@ import io.kubernetes.client.openapi.ApiException;
...
@@ -5,52 +5,70 @@ import io.kubernetes.client.openapi.ApiException;
import
io.kubernetes.client.openapi.Configuration
;
import
io.kubernetes.client.openapi.Configuration
;
import
io.kubernetes.client.openapi.apis.AppsV1Api
;
import
io.kubernetes.client.openapi.apis.AppsV1Api
;
import
io.kubernetes.client.openapi.apis.CoreV1Api
;
import
io.kubernetes.client.openapi.apis.CoreV1Api
;
import
io.kubernetes.client.openapi.models.V1Container
;
import
io.kubernetes.client.openapi.models.V1ContainerBuilder
;
import
io.kubernetes.client.openapi.models.V1Deployment
;
import
io.kubernetes.client.openapi.models.V1Deployment
;
import
io.kubernetes.client.openapi.models.V1DeploymentBuilder
;
import
io.kubernetes.client.openapi.models.V1DeploymentBuilder
;
import
io.kubernetes.client.util.Config
;
import
io.kubernetes.client.util.Config
;
import
org.opengroup.osdu.streaming.exception.StreamAdminException
;
import
org.opengroup.osdu.streaming.model.StreamRecord
;
import
org.opengroup.osdu.streaming.model.StreamRecord
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.context.annotation.RequestScope
;
import
org.springframework.web.context.annotation.RequestScope
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
@Service
@Service
@RequestScope
@RequestScope
public
class
DeploymentAdminServiceImpl
implements
DeploymentAdminService
{
public
class
DeploymentAdminServiceImpl
implements
DeploymentAdminService
{
CoreV1Api
coreV1Api
;
private
CoreV1Api
coreV1Api
;
AppsV1Api
appsV1Api
;
private
AppsV1Api
appsV1Api
;
private
String
namespace
;
private
String
deploymentSuffix
=
"deployment"
;
private
String
selectorMatchLabelKey
=
"run"
;
public
DeploymentAdminServiceImpl
()
throws
IOException
{
public
DeploymentAdminServiceImpl
(
CoreV1Api
coreV1Api
,
AppsV1Api
appsV1Api
,
@Value
(
"${deployment.namespace}"
)
String
namespace
)
{
ApiClient
client
=
Config
.
defaultClient
();
this
.
coreV1Api
=
coreV1Api
;
Configuration
.
setDefaultApiClient
(
client
);
this
.
appsV1Api
=
appsV1Api
;
coreV1Api
=
new
CoreV1Api
();
this
.
namespace
=
namespace
;
appsV1Api
=
new
AppsV1Api
();
}
}
@Override
@Override
public
StreamRecord
createStream
(
StreamRecord
streamRecord
)
{
public
StreamRecord
createStream
(
StreamRecord
streamRecord
)
{
Map
<
Object
,
Object
>
map
=
parseForNeededFields
(
streamRecord
);
String
deploymentName
=
this
.
getDeploymentName
(
streamRecord
);
V1Deployment
deployment
=
new
V1DeploymentBuilder
()
V1Deployment
deployment
=
new
V1DeploymentBuilder
()
.
withNewMetadata
()
.
withNewMetadata
()
.
withName
(
"TODO"
)
.
withName
(
String
.
format
(
"%s-%s"
,
deploymentName
,
this
.
deploymentSuffix
))
.
withNamespace
(
this
.
namespace
)
.
endMetadata
()
.
endMetadata
()
.
withNewSpec
()
.
withNewSpec
()
.
withReplicas
(
0
)
.
withNewSelector
()
.
withMatchLabels
(
Map
.
of
(
this
.
selectorMatchLabelKey
,
deploymentName
))
.
endSelector
()
.
withNewTemplate
()
.
withNewMetadata
()
.
withLabels
(
Map
.
of
(
this
.
selectorMatchLabelKey
,
deploymentName
))
.
endMetadata
()
.
withNewSpec
()
.
withContainers
(
new
V1ContainerBuilder
()
.
withImage
(
"TEST"
)
.
build
())
.
endSpec
()
.
endTemplate
()
.
endSpec
()
.
endSpec
()
.
build
();
.
build
();
try
{
try
{
appsV1Api
.
createNamespacedDeployment
(
"default"
,
deployment
,
null
,
null
,
null
);
V1Deployment
namespacedDeployment
=
appsV1Api
.
createNamespacedDeployment
(
namespace
,
deployment
,
null
,
null
,
null
);
}
catch
(
ApiException
e
)
{
}
catch
(
ApiException
e
)
{
e
.
printStackTrace
(
);
throw
new
StreamAdminException
(
e
);
}
}
return
null
;
return
streamRecord
;
}
}
p
rivate
Map
<
Object
,
Object
>
parseForNeededFields
(
StreamRecord
streamRecord
)
{
p
ublic
String
getDeploymentName
(
StreamRecord
streamRecord
)
{
return
new
HashMap
<>
();
return
streamRecord
.
getKind
();
}
}
@Override
@Override
...
...
src/main/java/org/opengroup/osdu/streaming/util/KubernetesAdminConfiguration.java
0 → 100644
View file @
3cdc5bfe
package
org.opengroup.osdu.streaming.util
;
import
io.kubernetes.client.openapi.ApiClient
;
import
io.kubernetes.client.openapi.apis.AppsV1Api
;
import
io.kubernetes.client.openapi.apis.CoreV1Api
;
import
io.kubernetes.client.util.Config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.io.IOException
;
@Configuration
public
class
KubernetesAdminConfiguration
{
public
KubernetesAdminConfiguration
()
throws
IOException
{
ApiClient
client
=
Config
.
defaultClient
();
io
.
kubernetes
.
client
.
openapi
.
Configuration
.
setDefaultApiClient
(
client
);
}
@Bean
public
CoreV1Api
coreV1Api
()
{
return
new
CoreV1Api
();
}
@Bean
public
AppsV1Api
appsV1Api
()
{
return
new
AppsV1Api
();
}
}
src/main/resources/application.properties
View file @
3cdc5bfe
...
@@ -7,4 +7,7 @@ spring.main.allow-bean-definition-overriding=true
...
@@ -7,4 +7,7 @@ spring.main.allow-bean-definition-overriding=true
logging.level.root
=
INFO
logging.level.root
=
INFO
osdu.storage.api
=
https://blah:1234/api/storage/v2
osdu.storage.api
=
https://blah:1234/api/storage/v2
\ No newline at end of file
deployment.namespace
=
osdu-streams
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment