Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ if $ENABLE_BATCHING;then
fi
if true
then
hostip=$(echo $HOST_IP|awk '{print $3}')
echo $hostip
sed -i "2s/localhost/${hostip}/g" conf
sed -i "2s/localhost/${HOST_IP}/g" conf
fi

python app.py
12 changes: 12 additions & 0 deletions scripts/examples/kv_store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ You need to buy a domain and https certificate first.
place server.key and server.pem in /etc/nginx.

Then place the nginx.conf in /etc/nginx and restart nginx.

## 3. k8s deployment

```bash
kubectl apply -f streamnet-dep.yml # deploy cluster
kubectl port-forward pod/streamnet-5c44964cfd-d69wh 8888:5000 # expose port of a single pod

kubectl describe pods streamnet-5c44964cfd-s67fp
curl http://localhost:8888/add_neighbors -X POST -H "Content-Type: application/json" -d @neighbor.json # connect pods

kubectl apply -f streamnet-svc.yml # expose streamnet-cli services
```
3 changes: 3 additions & 0 deletions scripts/examples/kv_store/neighbor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"uris" : ["tcp://10.1.0.26:13700"]
}
20 changes: 13 additions & 7 deletions scripts/examples/kv_store/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ http {
sendfile on;

upstream app_servers {
server LOCAL_IP:5000;
server LOCAL_IP:6000;
server 172.26.160.25:5000;
server 172.26.160.25:6000;
}

server {
listen 443 ssl;
server_name WEBSITE_LINK
listen 443 ssl http2;
server_name streamnet-chain.com www.streamnet-chain.com
ssl on; #开启ssl支持
ssl_certificate /etc/nginx/server.pem; #指定服务器证书路径
ssl_certificate_key /etc/nginx/server.key; #指定私钥证书路径
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
keepalive_timeout 70;

#ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
#ssl_ciphers HIGH:!aNULL:!MD5;
#ssl_prefer_server_ciphers on;
#keepalive_timeout 70;

location / {
proxy_pass http://app_servers;
Expand Down
37 changes: 37 additions & 0 deletions scripts/examples/kv_store/streamnet-dep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: streamnet
labels:
name: streamnet
app: streamnet
spec:
replicas: 3
selector:
matchLabels:
app: streamnet
template:
metadata:
labels:
app: streamnet
spec:
containers:
- name: streamnet
image: stplaydog/streamnet:dev
command: ["/entrypoint.sh"]
ports:
- containerPort: 14700
name: streamnet
protocol: TCP
- name: streamnet-cli
image: stplaydog/streamnet-cli:dev
command: ["/docker-entrypoint.sh"]
env:
- name: "ENABLE_BATCHING"
value: "true"
- name: "HOST_IP"
value: "localhost"
ports:
- containerPort: 5000
name: streamnet-cli
protocol: TCP
16 changes: 16 additions & 0 deletions scripts/examples/kv_store/streamnet-svc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: streamnet
labels:
name: streamnet
app: dev
spec:
selector:
name: streamnet
type: NodePort
ports:
- port: 5000
name: streamnet
targetPort: 5000
protocol: TCP
37 changes: 14 additions & 23 deletions scripts/front_end/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,38 @@

### mysql set up

download -> install -> run mysql on you machine

loggin with root to create trias user create databases and grant privileges
```bash
mysql -u root
create user 'trias'@'%' identified by 'trias@123';
create database trias_cli;
create database trias;
grant all privileges on trias.* to trias@'%';
grant all privileges on trias_cli.* to trias@'%';
```
Bring mysql up

source tables into database
```bash
mvn package
cd scripts/front_end/trias-oauth/oauth-server/src/main/resources/db/
mysql -u trias -p trias
source trias_server-init.sql
source trias-server_ddl.sql
docker-compose up
```

Compile oauth services (In trias-oauth/oauth-resource/ and oauth-server/).

```bash
./gradlew clean build
```

cd scripts/front_end/trias-oauth/oauth-resource/src/main/resources/db/
mysql -u trias -p trias_cli
source trias_cli-init.sql
source trias_cli_user_ddl.sql
DB migration (In trias-oauth/oauth-resource/ and oauth-server/)

```bash
./gradlew flywayClean
./gradlew flywayMigrate
```

### OAuth server / client set up

start oauth and oauth cli
```bash
$TRIAS_OAUTH_CLIENT=/opt/trias/oauth/client
export TRIAS_OAUTH_CLIENT=/opt/trias/oauth/client
mkdir -p $TRIAS_OAUTH_CLIENT
cp scripts/front_end/trias-oauth/oauth-resource/target/oauth-resource-1.0-SNAPSHOT.jar $TRIAS_OAUTH_CLIENT
cp scripts/front_end/trias-oauth/oauth-resource/src/main/resources/application.yml $TRIAS_OAUTH_CLIENT
cp scripts/front_end/trias-oauth/oauth-resource/src/main/resources/logback-spring.xml $TRIAS_OAUTH_CLIENT
cd $TRIAS_OAUTH_CLIENT
java -jar oauth-resource-1.0-SNAPSHOT.jar &

$TRIAS_OAUTH_SERVER=/opt/trias/oauth/server
export TRIAS_OAUTH_SERVER=/opt/trias/oauth/server
mkdir -p $TRIAS_OAUTH_SERVER
cp scripts/front_end/trias-oauth/oauth-server/target/oauth-server-1.0-SNAPSHOT.jar $TRIAS_OAUTH_SERVER
cp scripts/front_end/trias-oauth/oauth-server/src/main/resources/application.yml $TRIAS_OAUTH_SERVER
Expand Down
59 changes: 59 additions & 0 deletions scripts/front_end/trias-oauth/oauth-resource/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file was generated by the Gradle 'init' task.
*/

buildscript {
dependencies {
classpath 'mysql:mysql-connector-java:5.1.40' // for flyway
}
}

plugins {
id 'java'
id 'maven-publish'
id 'org.flywaydb.flyway' version "5.1.4"
id 'org.springframework.boot' version '2.1.3.RELEASE'
}

apply plugin: 'org.springframework.boot'

repositories {
mavenLocal()
maven {
url = 'http://repo.maven.apache.org/maven2'
}
}

dependencies {
compile 'org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-security:2.1.4.RELEASE'
compile 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.0.0.RELEASE'
compile 'org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1'
compile 'org.apache.httpcomponents:httpclient:4.5.8'
compile 'org.apache.httpcomponents:httpmime:4.5.8'
compile 'com.google.code.gson:gson:2.8.5'
compile 'org.apache.commons:commons-lang3:3.8.1'
runtime 'mysql:mysql-connector-java:8.0.15'
}

flyway {
url = 'jdbc:mysql://127.0.0.1:10633/trias_cli?useSSL=false'
user = 'trias'
password = 'trias@123'
}

group = 'com.trias'
version = '1.0-SNAPSHOT'
sourceCompatibility = '1.8'

publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading