forked from derekoneil/twitter-feed-oke
-
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
0 parents
commit 8d24e8c
Showing
22 changed files
with
25,693 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,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. |
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 @@ | ||
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. |
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,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 | ||
--- |
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,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 |
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,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' |
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,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 | ||
--- |
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,6 @@ | ||
{ | ||
"runtime": { | ||
"majorVersion": "8" | ||
}, | ||
"command": "sh target/bin/start" | ||
} |
Oops, something went wrong.