Skip to content

Commit

Permalink
#4 - initial lambda infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
obriensystems committed Apr 11, 2021
1 parent 9d8e6cb commit b90efeb
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 0 deletions.
45 changes: 45 additions & 0 deletions reference-aws-lambda/pom.xml
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>
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;
}
}

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;
}
}
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;
}
}
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());
}
}
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
95 changes: 95 additions & 0 deletions reference-helm/src/main/scripts/provision_cluster.sh
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

0 comments on commit b90efeb

Please sign in to comment.