2019年3月14日 星期四

Hygieia

Github : https://github.com/Hygieia/Hygieia/tree/gh-pages/pages/hygieia
Document : http://hygieia.github.io/Hygieia/getting_started.html

Architecture of Hygieia

Components

LayerDescription
UI LayerThe UI layer (User Interface) is Hygieia’s front- end and contains all the Graphical User Interface (GUI) elements for users to view. It is here where users are also able to configure the dashboard.
API LayerThe Hygieia API layer contains Hygieia APIs and Audit APIs. Hygieia APIs contain all the typical REST API services that work with the source system data (collected by service tasks) and the Internet. Hygieia audit APIs are a collection of API endpoints that serve to audit CI/CD data gathered by Hygieia collectors. This layer is an abstraction of the local data layer and the source system data layer.
DevOps ToolsThis layer entails the multitude of DevOps tools in a CI/CD pipeline. In the diagram, Jira, Git, Sonar, and XLDeploy are listed as examples.
Collectors’ LayerThe Collectors’ Layer fetches data from your DevOps tools. In turn, this data then appears on your Hygieia Dashboard. You can choose to install the collectors applicable to your DevOps tool set from the Hygieia Collectors Inventory.
Database LayerHygieia uses MongoDB as the database for storage and retrieval of data.

Build Hygieia

Build 的時候遇到的問題很多,所幸找到了一個連結
https://github.com/pravsingh/HygieiaLight
裡面很多指令免得大家踩坑。

Build hygieia-core (這個會過)

git clone https://github.com/Hygieia/hygieia-core
cd hygieia-core
mvn clean install package (need to sudo apt install maven at first)

Build Hygieia (這個有點問題)

git clone https://github.com/Hygieia/Hygieia
cd Hygieia
mvn clean install package (不會過)

找到了這個可以直接 build image 的方法
find . | grep Dockerfile | sed -e 's#/docker/Dockerfile##g' | awk '{print "mvn clean package -pl "$1" docker:build";}' | grep -v "/target" | sh

(似乎要用 sudo )



2019年3月13日 星期三

AWS DynamoDB

AWS DynamoDB

https://docs.aws.amazon.com/en_us/amazondynamodb/latest/developerguide/GettingStarted.Python.04.html


2019年3月12日 星期二

AWS Lambda 自動打包

AWS Lambda 有好工具自動打包,事實上也可以打包到各個雲上。

工具 serverless ,是用 node.js 開發的。只要用 npm 安裝即可,npm 這個工具的介紹就不贅述,網路上資料很多。

安裝工具

npm install -g serverless

試用 serverless

這個工具有提供 很多範例程式 供人測試,我們這次使用 python / aws dynamoDB 這個例子。

git clone https://github.com/serverless/examples.git  (載下範例來)

cd aws-python-rest-api-with-dynamodb  (我們選用這個範例)

原本是可以直接用 serverless deploy 這個指令做 deploy,但是我們現在還沒有設好我們 AWS 上的 credentials,所以還需要設定。

設定 AWS credentials 

這個影片教你如何在 IAM 中拿到 key ID 以及 secret,並且透過指令

serverless config credentials --provider aws --key xxxx --secret xxxx

將其存成預設執行的設定檔。


也有一些設定 credentials 的其他方法

正式執行 deploy

serverless deploy

輸出如下: 
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service serverless-rest-api-with-dynamodb.zip file to S3 (5.37 KB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
......................................................................................................
Serverless: Stack update finished...
Service Information
service: serverless-rest-api-with-dynamodb
stage: dev
region: us-east-1
stack: serverless-rest-api-with-dynamodb-dev
resources: 34
api keys:
  None
endpoints:
  POST - https://0c1qlf7h8a.execute-api.us-east-1.amazonaws.com/dev/todos
  GET - https://0c1qlf7h8a.execute-api.us-east-1.amazonaws.com/dev/todos
  GET - https://0c1qlf7h8a.execute-api.us-east-1.amazonaws.com/dev/todos/{id}
  PUT - https://0c1qlf7h8a.execute-api.us-east-1.amazonaws.com/dev/todos/{id}
  DELETE - https://0c1qlf7h8a.execute-api.us-east-1.amazonaws.com/dev/todos/{id}
functions:
  create: serverless-rest-api-with-dynamodb-dev-create
  list: serverless-rest-api-with-dynamodb-dev-list
  get: serverless-rest-api-with-dynamodb-dev-get
  update: serverless-rest-api-with-dynamodb-dev-update
  delete: serverless-rest-api-with-dynamodb-dev-delete
layers:
  None

部署完畢。

測試一下能否執行

範例裡面,會個別教學怎麼執行測試。我們直接列出執行狀況:

注意,REST 接觸的端口,就是上面部署完後的輸出結果,上面我用紅色標註。

建立 Todo 資料
$curl -X POST https://0c1qlf7h8a.execute-api.us-east-1.amazonaws.com/dev/todos --data '{ "text": "Learn Serverless" }'

輸出
{"text": "Learn Serverless", "checked": false, "id": "0828b186-4549-11e9-923d-eaf73cc0b517", "createdAt": 1552451558329, "updatedAt": 1552451558329}

查詢 Todo 資料
$ curl https://0c1qlf7h8a.execute-api.us-east-1.amazonaws.com/dev/todos

輸出
[{"text": "Learn Serverless", "checked": false, "id": "0828b186-4549-11e9-923d-eaf73cc0b517", "createdAt": 1552451558329, "updatedAt": 1552451558329}]

是可以正確執行的。