Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
derekoneil committed Aug 8, 2018
0 parents commit 8d24e8c
Show file tree
Hide file tree
Showing 22 changed files with 25,693 additions and 0 deletions.
29 changes: 29 additions & 0 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Automating Deployment from DevCS to ACC
---------------------------------------

These instructions are a *temporary hack* to support deployment from
DevCS to ACC until built-in and fully integrated support is available
in DevCS. I repeat--this is a temporary hack so please use with caution.


You can use `deploy.sh` as a *build step* in a DevCS Maven
build to push a generated application archive to ACC.

### Usage

`sh deploy.sh <id domain> <user id> <user password> <app name> <archive file>`

The `<archive file>` is assumed to be in the Maven generated `target` folder.

### Example
`sh deploy.sh jcsdemo888 demouser demopass MyApp myapp-dist.zip`

Installation
------------

Copy `deploy.sh` to the root of your DevCS project and commit to GIT so that it can be called from Maven.

Disclaimer
==========
Obviously hardcoding credentials is not a real solution but until DevCS
provides built-in deployment this is a workable solution for demos.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
About
=====

This repository contains the code for the Twitter feed microservice that you will use during the [Oracle Container Native Application Development workshop](http://oracle.github.io/learning-library/workshops/container-native-development).
During the workshop you will Dockerize this Java microservice using Wercker, configure a CI/CD pipeline, and deploy the microservice to Oracle's managed Kubernetes service.


Build
=====

Build the application and the distribution zip file with the build.sh file. It simply runs `mvn clean assembly:assembly`. That will result in a zip file in the target folder that can be uploaded to Java SE CS.


Run Locally
===========

On successful build, you can run the app with `sh target/bin/start` which is a shell script generated by the Maven build that constructs the correct classpath to dependencies in target/repo.


Deploy
======

You will create Wercker pipelines to build, publish, and deploy this microservice during the workshop.
44 changes: 44 additions & 0 deletions alpha-office-product-catalog.kubernetes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: product-catalog-app
labels:
commit: 48f74f435786d54673ac8c01f06a5fc69fb4b484
spec:
replicas: 2
selector:
matchLabels:
app: product-catalog-app
template:
metadata:
labels:
app: product-catalog-app
commit: 48f74f435786d54673ac8c01f06a5fc69fb4b484
spec:
containers:
- name: product-catalog-app-container
image: derekoneil/alpha-office-product-catalog
imagePullPolicy: Always
ports:
- name: pc-app-port
containerPort: 80
protocol: TCP
imagePullSecrets:
- name: wercker
---
apiVersion: v1
kind: Service
metadata:
name: product-catalog-service
labels:
app: product-catalog-app
commit: 48f74f435786d54673ac8c01f06a5fc69fb4b484
spec:
ports:
- port: 30000
targetPort: 80
selector:
app: product-catalog-app
commit: 48f74f435786d54673ac8c01f06a5fc69fb4b484
type: LoadBalancer
---
24 changes: 24 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh
#
#*******************************************************************************
# /*
# * File: build.sh
# *
# * Copyright (c) 2016 Oracle and/or its affiliates.
# *
# * You may not use this file except in compliance with the Universal Permissive
# * License (UPL), Version 1.0 (the "License.")
# *
# * You may obtain a copy of the License at https://opensource.org/licenses/UPL.
# *
# * 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.
# */
#
# @author Phil Chung
#*******************************************************************************
mvn clean assembly:assembly
79 changes: 79 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh
#
#*******************************************************************************
# /*
# * File: deploy.sh
# *
# * Copyright (c) 2016 Oracle and/or its affiliates.
# *
# * You may not use this file except in compliance with the Universal Permissive
# * License (UPL), Version 1.0 (the "License.")
# *
# * You may obtain a copy of the License at https://opensource.org/licenses/UPL.
# *
# * 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.
# */
#
# @author Phil Chung
#*******************************************************************************

export ID_DOMAIN=$1
export USER_ID=$2
export USER_PASSWORD=$3
export APP_NAME=$4
export ARCHIVE_FILE=$5
export ARCHIVE_LOCAL=target/$ARCHIVE_FILE
export APAAS_HOST=apaas.us.oraclecloud.com

# CREATE CONTAINER
echo '\n[info] Creating container\n'
curl -i -X PUT \
-u ${USER_ID}:${USER_PASSWORD} \
https://${ID_DOMAIN}.storage.oraclecloud.com/v1/Storage-$ID_DOMAIN/$APP_NAME

# PUT ARCHIVE IN STORAGE CONTAINER
echo '\n[info] Uploading application to storage\n'
curl -i -X PUT \
-u ${USER_ID}:${USER_PASSWORD} \
https://${ID_DOMAIN}.storage.oraclecloud.com/v1/Storage-$ID_DOMAIN/$APP_NAME/$ARCHIVE_FILE \
-T $ARCHIVE_LOCAL

# See if application exists
let httpCode=`curl -i -X GET \
-u ${USER_ID}:${USER_PASSWORD} \
-H "X-ID-TENANT-NAME:${ID_DOMAIN}" \
-H "Content-Type: multipart/form-data" \
-sL -w "%{http_code}" \
https://${APAAS_HOST}/paas/service/apaas/api/v1.1/apps/${ID_DOMAIN}/${APP_NAME} \
-o /dev/null`

# If application exists...
if [ $httpCode == 200 ]
then
# Update application
echo '\n[info] Updating application...\n'
curl -i -X PUT \
-u ${USER_ID}:${USER_PASSWORD} \
-H "X-ID-TENANT-NAME:${ID_DOMAIN}" \
-H "Content-Type: multipart/form-data" \
-F archiveURL=${APP_NAME}/${ARCHIVE_FILE} \
https://${APAAS_HOST}/paas/service/apaas/api/v1.1/apps/${ID_DOMAIN}/${APP_NAME}
else
# Create application and deploy
echo '\n[info] Creating application...\n'
curl -i -X POST \
-u ${USER_ID}:${USER_PASSWORD} \
-H "X-ID-TENANT-NAME:${ID_DOMAIN}" \
-H "Content-Type: multipart/form-data" \
-F "name=${APP_NAME}" \
-F "runtime=java" \
-F "subscription=Hourly" \
-F archiveURL=${APP_NAME}/${ARCHIVE_FILE} \
https://${APAAS_HOST}/paas/service/apaas/api/v1.1/apps/${ID_DOMAIN}
fi
echo '\n[info] Deployment complete\n'
56 changes: 56 additions & 0 deletions kubernetes.yml.template.final
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: twitter-feed-v2
labels:
commit: ${WERCKER_GIT_COMMIT}
spec:
replicas: 2
selector:
matchLabels:
app: twitter-feed
template:
metadata:
labels:
app: twitter-feed
commit: ${WERCKER_GIT_COMMIT}
color: green
spec:
containers:
- name: twitter-feed
image: ${DOCKER_REPO}:${WERCKER_GIT_BRANCH}-${WERCKER_GIT_COMMIT}
imagePullPolicy: Always
ports:
- name: twitter-feed
containerPort: 8080
protocol: TCP
volumeMounts:
- name: podinfo
mountPath: /tmp
readOnly: false
volumes:
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
imagePullSecrets:
- name: wercker
---
apiVersion: v1
kind: Service
metadata:
name: twitter-feed
labels:
app: twitter-feed
commit: ${WERCKER_GIT_COMMIT}
spec:
ports:
- port: 30000
targetPort: 8080
selector:
app: twitter-feed
color: green
type: ClusterIP
---
6 changes: 6 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"runtime": {
"majorVersion": "8"
},
"command": "sh target/bin/start"
}
Loading

0 comments on commit 8d24e8c

Please sign in to comment.