You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by pi...@apache.org on 2021/12/12 17:30:44 UTC
[submarine] branch master updated: SUBMARINE-1105. implementation of the base frame of k8s-agent
This is an automated email from the ASF dual-hosted git repository.
pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new dd1c1aa SUBMARINE-1105. implementation of the base frame of k8s-agent
dd1c1aa is described below
commit dd1c1aabf3438850f88e911bf55e42a39f1949b5
Author: FatalLin <fa...@gmail.com>
AuthorDate: Thu Dec 9 21:06:04 2021 +0800
SUBMARINE-1105. implementation of the base frame of k8s-agent
### What is this PR for?
just like we discussed earlier, we would like to turn submarine into a more k8s specialize solution; thus I build the base frame k8s-agent in this PR, which is responsible for tracking different types of custom resource we created - tfjob, pytorch job, and note book.
### What type of PR is it?
Feature
### Todos
* implement the customResourceHandler for each custom resource.
* add the building process into current building progress.
### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-1105
### How should this be tested?
For now the codes is quite simple, I think we could add the unit test once the customResource handler is done.
### Screenshots (if appropriate)
![Screen Shot 2021-11-30 at 11 06 09 PM](https://user-images.githubusercontent.com/5687317/144861686-03f612ab-6768-447d-b529-d965aa5e70ad.png)
![Screen Shot 2021-11-30 at 11 06 24 PM](https://user-images.githubusercontent.com/5687317/144861707-6fc772fb-54ae-465c-930e-63c4b8ec359e.png)
### Questions:
* Do the license files need updating? No
* Are there breaking changes for older versions? No
* Does this need new documentation? Yes (Design Doc)
Author: FatalLin <fa...@gmail.com>
Signed-off-by: Kevin <pi...@apache.org>
Closes #822 from FatalLin/SUBMARINE-1105 and squashes the following commits:
9ce6a33f [FatalLin] modify echo content
c68a77e2 [FatalLin] add license annocement and updage submarine-daemon
30eb6af1 [FatalLin] implementation of the base frame of k8s-agent
---
bin/{submarine.sh => agent.sh} | 12 +-
bin/common.sh | 8 +-
bin/submarine-daemon.sh | 6 +-
bin/submarine.sh | 4 +-
conf/submarine-env.sh.template | 6 +-
dev-support/docker-images/agent/Dockerfile | 44 ++++++
dev-support/docker-images/agent/build.sh | 62 ++++++++
submarine-server/server-submitter/pom.xml | 9 +-
.../server-submitter/submarine-k8s-agent/pom.xml | 171 +++++++++++++++++++++
.../src/assembly/distribution.xml | 69 +++++++++
.../src/assembly/src-distribution.xml | 53 +++++++
.../submarine/server/k8s/agent/HandlerFactory.java | 35 +++++
.../submarine/server/k8s/agent/SubmarineAgent.java | 75 +++++++++
.../server/k8s/agent/bean/CustomResourceType.java | 35 +++++
.../k8s/agent/handler/CustomResourceHandler.java | 74 +++++++++
15 files changed, 639 insertions(+), 24 deletions(-)
diff --git a/bin/submarine.sh b/bin/agent.sh
similarity index 75%
copy from bin/submarine.sh
copy to bin/agent.sh
index e8c109b..c3f4c07 100755
--- a/bin/submarine.sh
+++ b/bin/agent.sh
@@ -16,7 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-USAGE="Usage: bin/submarine.sh [--config <conf-dir>]"
+USAGE="Usage: bin/agent.sh [--config <conf-dir>]"
if [[ "$1" == "--config" ]]; then
shift
@@ -43,10 +43,10 @@ GET_MYSQL_JAR=false
cd ${BIN}/>/dev/null
-SUBMARINE_SERVER_NAME="Submarine Server"
-SUBMARINE_SERVER_LOGFILE="${SUBMARINE_LOG_DIR}/submarine.log"
-SUBMARINE_SERVER_MAIN=org.apache.submarine.server.SubmarineServer
-JAVA_OPTS+="${SUBMARINE_SERVER_JAVA_OPTS:-""} ${SUBMARINE_SERVER_MEM:-""} -Dsubmarine.log.file=${SUBMARINE_SERVER_LOGFILE}"
+SUBMARINE_AGENT_NAME="Submarine Agent"
+SUBMARINE_AGENT_LOGFILE="${SUBMARINE_LOG_DIR}/agent.log"
+SUBMARINE_AGENT_MAIN=org.apache.submarine.server.k8s.agent.SubmarineAgent
+JAVA_OPTS+="${SUBMARINE_APP_JAVA_OPTS:-""} ${SUBMARINE_APP_MEM:-""} -Dsubmarine.log.file=${SUBMARINE_AGENT_LOGFILE}"
add_jar_in_dir "${BIN}/../lib"
@@ -55,4 +55,4 @@ if [[ ! -d "${SUBMARINE_LOG_DIR}" ]]; then
$(mkdir -p "${SUBMARINE_LOG_DIR}")
fi
-exec $JAVA_RUNNER $JAVA_OPTS -cp ${SUBMARINE_SERVER_CLASSPATH} ${SUBMARINE_SERVER_MAIN} "$@" | tee -a "${SUBMARINE_SERVER_LOGFILE}" 2>&1
+exec $JAVA_RUNNER $JAVA_OPTS -cp ${SUBMARINE_APP_CLASSPATH} ${SUBMARINE_AGENT_MAIN} "$@" | tee -a "${SUBMARINE_AGENT_LOGFILE}" 2>&1
diff --git a/bin/common.sh b/bin/common.sh
index ecf9469..3ebe87f 100755
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -42,12 +42,12 @@ if [[ -f "${SUBMARINE_CONF_DIR}/submarine-env.sh" ]]; then
. "${SUBMARINE_CONF_DIR}/submarine-env.sh"
fi
-SUBMARINE_SERVER_CLASSPATH+=":${SUBMARINE_CONF_DIR}"
+SUBMARINE_APP_CLASSPATH+=":${SUBMARINE_CONF_DIR}"
function add_each_jar_in_dir(){
if [[ -d "${1}" ]]; then
for jar in $(find -L "${1}" -maxdepth 1 -name '*jar'); do
- SUBMARINE_SERVER_CLASSPATH="$jar:$SUBMARINE_SERVER_CLASSPATH"
+ SUBMARINE_APP_CLASSPATH="$jar:$SUBMARINE_APP_CLASSPATH"
done
fi
}
@@ -55,14 +55,14 @@ function add_each_jar_in_dir(){
function add_each_jar_in_dir_recursive(){
if [[ -d "${1}" ]]; then
for jar in $(find -L "${1}" -type f -name '*jar'); do
- SUBMARINE_SERVER_CLASSPATH="$jar:$SUBMARINE_SERVER_CLASSPATH"
+ SUBMARINE_APP_CLASSPATH="$jar:$SUBMARINE_APP_CLASSPATH"
done
fi
}
function add_jar_in_dir(){
if [[ -d "${1}" ]]; then
- SUBMARINE_SERVER_CLASSPATH="${1}/*:${SUBMARINE_SERVER_CLASSPATH}"
+ SUBMARINE_APP_CLASSPATH="${1}/*:${SUBMARINE_APP_CLASSPATH}"
fi
}
diff --git a/bin/submarine-daemon.sh b/bin/submarine-daemon.sh
index f7fcdc8..cdf9d9a 100755
--- a/bin/submarine-daemon.sh
+++ b/bin/submarine-daemon.sh
@@ -36,7 +36,7 @@ cd ${BIN}/>/dev/null
SUBMARINE_SERVER_NAME="Submarine Server"
SUBMARINE_SERVER_LOGFILE="${SUBMARINE_LOG_DIR}/submarine.log"
SUBMARINE_SERVER_MAIN=org.apache.submarine.server.SubmarineServer
-JAVA_OPTS+="${SUBMARINE_SERVER_JAVA_OPTS} ${SUBMARINE_SERVER_MEM} -Dsubmarine.log.file=${SUBMARINE_SERVER_LOGFILE}"
+JAVA_OPTS+="${SUBMARINE_APP_JAVA_OPTS} ${SUBMARINE_APP_MEM} -Dsubmarine.log.file=${SUBMARINE_SERVER_LOGFILE}"
add_jar_in_dir "${BIN}/../lib"
@@ -120,9 +120,9 @@ function start() {
initialize_default_directories
- echo "SUBMARINE_SERVER_CLASSPATH: ${SUBMARINE_SERVER_CLASSPATH}" >> "${SUBMARINE_SERVER_LOGFILE}"
+ echo "SUBMARINE_APP_CLASSPATH: ${SUBMARINE_APP_CLASSPATH}" >> "${SUBMARINE_SERVER_LOGFILE}"
- nohup $JAVA_RUNNER $JAVA_OPTS -cp $SUBMARINE_SERVER_CLASSPATH $SUBMARINE_SERVER_MAIN >> "${SUBMARINE_SERVER_LOGFILE}" 2>&1 < /dev/null &
+ nohup $JAVA_RUNNER $JAVA_OPTS -cp $SUBMARINE_APP_CLASSPATH $SUBMARINE_SERVER_MAIN >> "${SUBMARINE_SERVER_LOGFILE}" 2>&1 < /dev/null &
pid=$!
if [[ ! -z "${pid}" ]]; then
echo "${SUBMARINE_SERVER_NAME} start"
diff --git a/bin/submarine.sh b/bin/submarine.sh
index e8c109b..6e94e7e 100755
--- a/bin/submarine.sh
+++ b/bin/submarine.sh
@@ -46,7 +46,7 @@ cd ${BIN}/>/dev/null
SUBMARINE_SERVER_NAME="Submarine Server"
SUBMARINE_SERVER_LOGFILE="${SUBMARINE_LOG_DIR}/submarine.log"
SUBMARINE_SERVER_MAIN=org.apache.submarine.server.SubmarineServer
-JAVA_OPTS+="${SUBMARINE_SERVER_JAVA_OPTS:-""} ${SUBMARINE_SERVER_MEM:-""} -Dsubmarine.log.file=${SUBMARINE_SERVER_LOGFILE}"
+JAVA_OPTS+="${SUBMARINE_APP_JAVA_OPTS:-""} ${SUBMARINE_APP_MEM:-""} -Dsubmarine.log.file=${SUBMARINE_SERVER_LOGFILE}"
add_jar_in_dir "${BIN}/../lib"
@@ -55,4 +55,4 @@ if [[ ! -d "${SUBMARINE_LOG_DIR}" ]]; then
$(mkdir -p "${SUBMARINE_LOG_DIR}")
fi
-exec $JAVA_RUNNER $JAVA_OPTS -cp ${SUBMARINE_SERVER_CLASSPATH} ${SUBMARINE_SERVER_MAIN} "$@" | tee -a "${SUBMARINE_SERVER_LOGFILE}" 2>&1
+exec $JAVA_RUNNER $JAVA_OPTS -cp ${SUBMARINE_APP_CLASSPATH} ${SUBMARINE_SERVER_MAIN} "$@" | tee -a "${SUBMARINE_SERVER_LOGFILE}" 2>&1
diff --git a/conf/submarine-env.sh.template b/conf/submarine-env.sh.template
index 97ae1d8..0eeafd4 100644
--- a/conf/submarine-env.sh.template
+++ b/conf/submarine-env.sh.template
@@ -19,11 +19,11 @@
# export JAVA_HOME=java
# Debug Submarine server
-# export SUBMARINE_SERVER_JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
+# export SUBMARINE_APP_JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
# Set Submarine server memory
-# export SUBMARINE_SERVER_MEM="-Xms1024m -Xmx1024m -XX:MaxPermSize=512m"
+# export SUBMARINE_APP_MEM="-Xms1024m -Xmx1024m -XX:MaxPermSize=512m"
# Set Submarine server classpath. If you want to visit hdfs, just add hadoop
# configuration path.
-# export SUBMARINE_SERVER_CLASSPATH+=":/usr/local/hadoop/etc/hadoop"
+# export SUBMARINE_APP_CLASSPATH+=":/usr/local/hadoop/etc/hadoop"
diff --git a/dev-support/docker-images/agent/Dockerfile b/dev-support/docker-images/agent/Dockerfile
new file mode 100644
index 0000000..873a185
--- /dev/null
+++ b/dev-support/docker-images/agent/Dockerfile
@@ -0,0 +1,44 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+FROM alpine:3.10
+MAINTAINER Apache Software Foundation <de...@submarine.apache.org>
+
+# If you are in China, enabling the following two lines of code can speed up the build of the image, but it may cause failure in travis.
+# So when submitting the code, please make sure the following 2 lines of code are in a commented state
+# RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.10/main" > /etc/apk/repositories
+# RUN echo "http://mirrors.ustc.edu.cn/alpine/v3.10/community" >> /etc/apk/repositories
+
+# INSTALL openjdk
+RUN apk update && \
+ apk add --no-cache openjdk8 tzdata bash tini&& \
+ cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
+ echo Asia/Shanghai > /etc/timezone && \
+ apk del tzdata && \
+ rm -rf /tmp/* /var/cache/apk/*
+
+ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk/jre
+
+# Install Submarine
+ADD ./tmp/submarine-k8s-agent-*.tar.gz /opt/
+RUN ln -s /opt/submarine-k8s-agent-* "/opt/submarine-current"
+ADD ./tmp/submarine-site.xml "/opt/submarine-current/conf/"
+ADD ./tmp/mysql-connector-java-5.1.39.jar "/opt/submarine-current/lib/"
+
+WORKDIR /opt/submarine-current
+
+ENTRYPOINT ["/sbin/tini", "--"]
+
+CMD ["/bin/bash", "-c", "/opt/submarine-current/bin/agent.sh"]
diff --git a/dev-support/docker-images/agent/build.sh b/dev-support/docker-images/agent/build.sh
new file mode 100755
index 0000000..8d680a8
--- /dev/null
+++ b/dev-support/docker-images/agent/build.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+set -euxo pipefail
+
+SUBMARINE_VERSION=0.7.0-SNAPSHOT
+SUBMARINE_IMAGE_NAME="apache/submarine:sidecar-agent-${SUBMARINE_VERSION}"
+
+if [ -L ${BASH_SOURCE-$0} ]; then
+ PWD=$(dirname $(readlink "${BASH_SOURCE-$0}"))
+else
+ PWD=$(dirname ${BASH_SOURCE-$0})
+fi
+export CURRENT_PATH=$(cd "${PWD}">/dev/null; pwd)
+export SUBMARINE_HOME=${CURRENT_PATH}/../../..
+
+if [ ! -d "${SUBMARINE_HOME}/submarine-server/server-submitter/submarine-k8s-agent/target" ]; then
+ mkdir -p "${SUBMARINE_HOME}/submarine-server/server-submitter/submarine-k8s-agent/target"
+fi
+submarine_dist_exists=$(find -L "${SUBMARINE_HOME}/submarine-server/server-submitter/submarine-k8s-agent/target" -name "submarine-k8s-agent-${SUBMARINE_VERSION}.tar.gz")
+# Build source code if the package doesn't exist.
+if [[ -z "${submarine_dist_exists}" ]]; then
+ cd "${SUBMARINE_HOME}/submarine-server/server-submitter/submarine-k8s-agent"
+ mvn clean package -DskipTests
+fi
+
+mkdir -p "${CURRENT_PATH}/tmp"
+cp ${SUBMARINE_HOME}/submarine-server/server-submitter/submarine-k8s-agent/target/submarine-k8s-agent-${SUBMARINE_VERSION}.tar.gz "${CURRENT_PATH}/tmp"
+
+# download mysql connect java
+MYSQL_VERSION=5.1.39
+MYSQL_JAR_URL="https://repo1.maven.org/maven2/mysql/mysql-connector-java/${MYSQL_VERSION}/mysql-connector-java-${MYSQL_VERSION}.jar"
+tmpfile=$(mktemp)
+trap "test -f $tmpfile && rm $tmpfile" RETURN
+curl -L -o $tmpfile ${MYSQL_JAR_URL}
+mv $tmpfile ${CURRENT_PATH}/tmp/mysql-connector-java-${MYSQL_VERSION}.jar
+
+# Replace the mysql jdbc.url in the submarine-site.xml file with the link name of the submarine container
+# `submarine-database` is submarine database container name
+cp ${SUBMARINE_HOME}/conf/submarine-site.xml "${CURRENT_PATH}/tmp/"
+sed -i.bak 's/127.0.0.1:3306/submarine-database:3306/g' "${CURRENT_PATH}/tmp/submarine-site.xml"
+
+# build image
+cd ${CURRENT_PATH}
+echo "Start building the ${SUBMARINE_IMAGE_NAME} docker image ..."
+docker build -t ${SUBMARINE_IMAGE_NAME} .
+
+# clean temp file
+rm -rf "${CURRENT_PATH}/tmp"
diff --git a/submarine-server/server-submitter/pom.xml b/submarine-server/server-submitter/pom.xml
index 700ff58..18bb3ee 100644
--- a/submarine-server/server-submitter/pom.xml
+++ b/submarine-server/server-submitter/pom.xml
@@ -16,11 +16,7 @@
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ --><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>submarine-server</artifactId>
<groupId>org.apache.submarine</groupId>
@@ -35,6 +31,7 @@
<modules>
<module>submitter-k8s</module>
+ <module>submarine-k8s-agent</module>
</modules>
-</project>
+</project>
\ No newline at end of file
diff --git a/submarine-server/server-submitter/submarine-k8s-agent/pom.xml b/submarine-server/server-submitter/submarine-k8s-agent/pom.xml
new file mode 100644
index 0000000..5eb624e
--- /dev/null
+++ b/submarine-server/server-submitter/submarine-k8s-agent/pom.xml
@@ -0,0 +1,171 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+ -->
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.submarine</groupId>
+ <artifactId>submarine-server-submitter</artifactId>
+ <version>0.7.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>submarine-k8s-agent</artifactId>
+ <name>Submarine: K8S Agent</name>
+
+ <properties>
+ <agent.k8s.client-java.version>11.0.1</agent.k8s.client-java.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>io.kubernetes</groupId>
+ <artifactId>client-java</artifactId>
+ <version>${agent.k8s.client-java.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.submarine</groupId>
+ <artifactId>submarine-server-core</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk15on</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>src</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>src-dist</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>${project.artifactId}-${project.version}-src</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <descriptors>
+ <descriptor>src/assembly/src-distribution.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies-runtime</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <includeScope>runtime</includeScope>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-dependencies-system</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <includeScope>system</includeScope>
+ <excludeTransitive>true</excludeTransitive>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>${plugin.maven.assembly.version}</version>
+ <executions>
+ <execution>
+ <id>dist</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ <attach>false</attach>
+ <descriptors>
+ <descriptor>src/assembly/distribution.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/assembly/distribution.xml b/submarine-server/server-submitter/submarine-k8s-agent/src/assembly/distribution.xml
new file mode 100644
index 0000000..463ffbb
--- /dev/null
+++ b/submarine-server/server-submitter/submarine-k8s-agent/src/assembly/distribution.xml
@@ -0,0 +1,69 @@
+<!--
+ 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. See accompanying LICENSE file.
+-->
+
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <id>distribution</id>
+ <formats>
+ <format>dir</format>
+ <format>tar.gz</format>
+ </formats>
+
+
+ <files>
+ <file>
+ <source>../../../LICENSE-binary</source>
+ <outputDirectory>/</outputDirectory>
+ <destName>LICENSE</destName>
+ </file>
+ <file>
+ <source>../../../NOTICE-binary</source>
+ <outputDirectory>/</outputDirectory>
+ <destName>NOTICE</destName>
+ </file>
+ </files>
+
+ <fileSets>
+ <fileSet>
+ <directory>../../../licenses-binary</directory>
+ <outputDirectory>/licenses</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>../../../conf</directory>
+ <outputDirectory>/conf</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>../../../bin</directory>
+ <outputDirectory>/bin</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>./target</directory>
+ <outputDirectory>/lib</outputDirectory>
+ <includes>
+ <include>submarine-k8s-agent-${project.version}.jar</include>
+ </includes>
+ </fileSet>
+
+ <fileSet>
+ <directory>./target/dependency</directory>
+ <outputDirectory>/lib</outputDirectory>
+ </fileSet>
+
+ </fileSets>
+
+</assembly>
diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/assembly/src-distribution.xml b/submarine-server/server-submitter/submarine-k8s-agent/src/assembly/src-distribution.xml
new file mode 100644
index 0000000..c3e2a89
--- /dev/null
+++ b/submarine-server/server-submitter/submarine-k8s-agent/src/assembly/src-distribution.xml
@@ -0,0 +1,53 @@
+<!--
+ 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. See accompanying LICENSE file.
+-->
+
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <id>src</id>
+ <formats>
+ <format>dir</format>
+ <format>tar.gz</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>../</directory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <excludes>
+ <exclude>.git/**</exclude>
+ <exclude>**/.gitignore</exclude>
+ <exclude>**/.svn</exclude>
+ <exclude>**/*.iws</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iml</exclude>
+ <exclude>**/.classpath</exclude>
+ <exclude>**/.project</exclude>
+ <exclude>**/.settings</exclude>
+ <exclude>**/target/**</exclude>
+ <exclude>submodules/**/target/**</exclude>
+ <exclude>submarine-workbench/workbench-web/dist/**</exclude>
+ <exclude>submarine-workbench/workbench-web/node_modules/**</exclude>
+ <!-- until the code that does this is fixed -->
+ <exclude>**/*.log</exclude>
+ <exclude>**/build/**</exclude>
+ <exclude>**/file:/**</exclude>
+ <exclude>**/SecurityAuth.audit*</exclude>
+ <exclude>submarine-cloud/bin/**</exclude>
+ <exclude>dev-support/submarine-installer/package/hadoop/yarn/lib/native/**</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/HandlerFactory.java b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/HandlerFactory.java
new file mode 100644
index 0000000..5005284
--- /dev/null
+++ b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/HandlerFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.submarine.server.k8s.agent;
+
+import org.apache.submarine.server.k8s.agent.bean.CustomResourceType;
+import org.apache.submarine.server.k8s.agent.handler.CustomResourceHandler;
+
+public class HandlerFactory {
+
+ private static String HANDLER_POSTFIX = "Handler";
+ private static String HANDLER_PACKAGE = "org.apache.submarine.server.k8s.agent.handler";
+
+ public static CustomResourceHandler getHandler(CustomResourceType crType) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+ String handlerClassStr = HANDLER_PACKAGE + "." + crType.getCustomResourceType() + HANDLER_POSTFIX;
+ Class handlerClass = Class.forName(handlerClassStr);
+ return (CustomResourceHandler)handlerClass.newInstance();
+ }
+}
diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/SubmarineAgent.java b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/SubmarineAgent.java
new file mode 100644
index 0000000..1057a55
--- /dev/null
+++ b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/SubmarineAgent.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.submarine.server.k8s.agent;
+
+import java.io.IOException;
+
+import org.apache.submarine.server.k8s.agent.bean.CustomResourceType;
+import org.apache.submarine.server.k8s.agent.handler.CustomResourceHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.kubernetes.client.openapi.ApiClient;
+import io.kubernetes.client.openapi.Configuration;
+import io.kubernetes.client.openapi.apis.CoreV1Api;
+import io.kubernetes.client.util.Config;
+import io.kubernetes.client.util.Watch;
+import io.kubernetes.client.util.Watchable;
+import io.kubernetes.client.util.generic.GenericKubernetesApi;
+
+
+public class SubmarineAgent {
+ private static final Logger LOG = LoggerFactory.getLogger(SubmarineAgent.class);
+ private String namespace;
+ private String customResourceType;
+ private String customResourceName;
+ private CustomResourceType type;
+ private CustomResourceHandler handler;
+
+
+ public SubmarineAgent(String namespace, String customResourceType, String customResourceName) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
+ this.namespace = namespace;
+ this.customResourceType = customResourceType;
+ this.customResourceName = customResourceName;
+ this.type = CustomResourceType.valueOf(customResourceType);
+ this.handler = HandlerFactory.getHandler(this.type);
+
+ }
+
+ public void start() {
+
+ }
+
+
+ public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
+ String namespace = System.getenv("NAMESPACE");
+ String customResourceType = System.getenv("CUSTOM_RESOURCE_TYPE");
+ String customResourceName = System.getenv("CUSTOM_RESOURCE_NAME");
+ LOG.info(String.format("NAMESPACE:%s", customResourceType));
+ LOG.info(String.format("CUSTOM_RESOURCE_TYPE:%s", customResourceType));
+ LOG.info(String.format("CUSTOM_RESOURCE_NAME:%s", customResourceName));
+
+ SubmarineAgent agent = new SubmarineAgent(customResourceType, customResourceType, customResourceName);
+ agent.start();
+
+ }
+
+
+}
diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/bean/CustomResourceType.java b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/bean/CustomResourceType.java
new file mode 100644
index 0000000..f85d634
--- /dev/null
+++ b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/bean/CustomResourceType.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.submarine.server.k8s.agent.bean;
+
+public enum CustomResourceType {
+ TFJob("tfJob"), PYTORCHJob("pytorchJob"), Notebook("notebook");
+
+ private String customResourceType;
+
+ CustomResourceType(String customResourceType) {
+ this.customResourceType = customResourceType;
+ }
+
+ public String getCustomResourceType() {
+ return this.customResourceType;
+ }
+
+}
diff --git a/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/handler/CustomResourceHandler.java b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/handler/CustomResourceHandler.java
new file mode 100644
index 0000000..271ebc7
--- /dev/null
+++ b/submarine-server/server-submitter/submarine-k8s-agent/src/main/java/org/apache/submarine/server/k8s/agent/handler/CustomResourceHandler.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.submarine.server.k8s.agent.handler;
+
+import java.io.IOException;
+
+import io.kubernetes.client.openapi.ApiClient;
+import io.kubernetes.client.openapi.Configuration;
+import io.kubernetes.client.openapi.apis.CoreV1Api;
+import io.kubernetes.client.util.Config;
+
+public abstract class CustomResourceHandler {
+ private CoreV1Api coreApi;
+ private ApiClient client = null;
+ private String namespace;
+ private String crType;
+ private String crName;
+
+ public CustomResourceHandler() throws IOException {
+ this.client = Config.defaultClient();
+ Configuration.setDefaultApiClient(client);
+ this.coreApi = new CoreV1Api(this.client);
+ }
+
+ public abstract void init(String namespace, String crType, String crName);
+ public abstract void run();
+ public abstract void onAddEvent();
+ public abstract void onModifyEvent();
+ public abstract void onDeleteEvent();
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getCrType() {
+ return crType;
+ }
+
+ public void setCrType(String crType) {
+ this.crType = crType;
+ }
+
+ public String getCrName() {
+ return crName;
+ }
+
+ public void setCrName(String crName) {
+ this.crName = crName;
+ }
+
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org