-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d8e6cb
commit b90efeb
Showing
7 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>cloud.dev9</groupId> | ||
<artifactId>reference-root</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>reference-aws-lambda</artifactId> | ||
<name>reference-aws-lambda</name> | ||
<description>reference-aws-lambda project</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.amazonaws</groupId> | ||
<artifactId>aws-lambda-java-core</artifactId> | ||
<version>1.1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.4.3</version> | ||
<configuration> | ||
<createDependencyReducedPom>false</createDependencyReducedPom> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
reference-aws-lambda/src/main/java/cloud/containerization/reference/nbi/Api.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cloud.containerization.reference.nbi; | ||
|
||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
public class Api { | ||
|
||
private AtomicLong id; | ||
private String content; | ||
|
||
public Api(AtomicLong id, String content) { | ||
this.id = id; | ||
this.content = content; | ||
} | ||
|
||
public AtomicLong getId() { | ||
return id; | ||
} | ||
|
||
public String getContent() { | ||
return content; | ||
} | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
...ce-aws-lambda/src/main/java/cloud/containerization/reference/nbi/LambdaMethodHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cloud.containerization.reference.nbi; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
|
||
public class LambdaMethodHandler { | ||
public String handleRequest(String input, Context context) { | ||
context.getLogger().log("Input: " + input); | ||
return "Hello World - " + input; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...e-aws-lambda/src/main/java/cloud/containerization/reference/nbi/LambdaRequestHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cloud.containerization.reference.nbi; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestHandler; | ||
|
||
public class LambdaRequestHandler | ||
implements RequestHandler<String, String> { | ||
public String handleRequest(String input, Context context) { | ||
context.getLogger().log("Input: " + input); | ||
return "Hello World - " + input; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...lambda/src/main/java/cloud/containerization/reference/nbi/LambdaRequestStreamHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cloud.containerization.reference.nbi; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
|
||
import com.amazonaws.services.lambda.runtime.Context; | ||
import com.amazonaws.services.lambda.runtime.RequestStreamHandler; | ||
|
||
public class LambdaRequestStreamHandler | ||
implements RequestStreamHandler { | ||
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) throws IOException { | ||
String input = IOUtils.toString(inputStream, "UTF-8"); | ||
outputStream.write(("Hello World - " + input).getBytes()); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
reference-aws-lambda/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server.servlet.context-path=/nbi | ||
logging.level.org.springframework.web=DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
############################################################################# | ||
# Copyright © 2020 obrienlabs | ||
# | ||
# 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. | ||
# | ||
############################################################################# | ||
# | ||
# This provisioning script configures a vanilla kubernetes cluster for use | ||
# documentation at | ||
# http://wiki.obrienlabs.cloud/display/DEV/Kubernetes+Developer+Guide | ||
# source from | ||
|
||
usage() { | ||
cat <<EOF | ||
Usage: $0 [PARAMs] | ||
example | ||
sudo ./rke_setup.sh -b dublin -s rke.onap.cloud -e onap -l amdocs -v true | ||
-u : Display usage | ||
-b [branch] : branch = main (required) | ||
-l [username] : login username account (use ubuntu for example) | ||
EOF | ||
} | ||
|
||
install_charts() { | ||
#constants | ||
PORT=8880 | ||
|
||
# echo "user: $USERNAME" | ||
|
||
|
||
|
||
echo "Installing for ${BRANCH}: " | ||
|
||
# echo "Verify all pods up on the kubernetes system - will return localhost:8080 until a host is added" | ||
# echo "kubectl get pods --all-namespaces" | ||
# kubectl get pods --all-namespaces | ||
# echo "install tiller/helm" | ||
# kubectl -n kube-system create serviceaccount tiller | ||
# kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller | ||
# helm init --service-account tiller | ||
# kubectl -n kube-system rollout status deploy/tiller-deploy | ||
|
||
echo "verify both versions are the same below" | ||
if [ "$USERNAME" == "root" ]; then | ||
helm version | ||
else | ||
sudo helm version | ||
fi | ||
|
||
kubectl version | ||
kubectl get services --all-namespaces | ||
kubectl get pods --all-namespaces | ||
echo "finished!" | ||
} | ||
|
||
BRANCH= | ||
VALIDATE=false | ||
USERNAME=ubuntu | ||
|
||
while getopts ":b:u:v" PARAM; do | ||
case $PARAM in | ||
u) | ||
usage | ||
exit 1 | ||
;; | ||
b) | ||
BRANCH=${OPTARG} | ||
;; | ||
v) | ||
VALIDATE=${OPTARG} | ||
;; | ||
?) | ||
usage | ||
exit | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z $BRANCH ]]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
install_charts $BRANCH $VALIDATE | ||
|