Skip to content

Commit c8cd06e

Browse files
authored
Merge pull request #148 from saksham-gera/dev
Migrated kong with cassandra to kong with postgres in fri/server
2 parents 9d2d922 + f79567c commit c8cd06e

File tree

2 files changed

+113
-72
lines changed

2 files changed

+113
-72
lines changed

fri/DOCKER-README.md

Lines changed: 86 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,99 @@
22

33
Open Terminal and run the following commands:-
44

5-
````
5+
```
66
$ sudo apt-get update
77
$ sudo apt-get install curl
88
$ curl -fsSL https://get.docker.com/ | sh
9-
````
10-
Optional command:- To run docker commands without sudo
11-
````
9+
```
10+
11+
Optional command:- To run docker commands without sudo
12+
13+
```
1214
$ sudo usermod -aG docker <system_username>
13-
````
14-
The above command add the system username in the docker group, Restart the system to complete the process.
15+
```
1516

16-
After restart run
17+
The above command adds the system username to the docker group. Restart the system to complete the process.
1718

18-
````
19-
$ sudo service docker start
20-
````
19+
After restart, run
20+
21+
```
22+
$ sudo service docker start
23+
```
2124

2225
# Building FRI Container
2326

2427
Now, we elaborate on building FRI as a container, together with the Kong API Gateway.
2528

2629
Connect to the Server VM, assuming x.x.x.x to be the IP address of your server.
27-
````
30+
31+
```
2832
$ ssh -i "controlcore.pem" ubuntu@x.x.x.x
29-
````
33+
```
34+
3035
Perform Git clone if this is the first time you are configuring the Server
31-
````
36+
37+
```
3238
$ git clone git@github.com/ControlCore-Project/concore.git
33-
````
39+
```
3440

35-
First build the Docker Container of the FRI.
36-
````
41+
First build & run the Docker Container of the FRI.
42+
43+
```
3744
$ git pull
3845
46+
$ cd fri
47+
3948
$ docker build -t fri .
40-
````
49+
50+
$ docker run -d --name fri -p 8090:8080 fri
51+
```
4152

4253
# Running Control-Core FRI with Kong as containers
4354

44-
If you are already running FRI, make sure to stop and clear existing FRI container as it is likely conflict with the port. If there is Kong gateway running in default ports, stop and clear it too.
45-
````
55+
If you are already running FRI, make sure to stop and clear existing FRI containers as they will likely conflict with the port. If there is a Kong gateway running in default ports, stop and clear it too.
56+
57+
```
4658
$ docker stop fri
4759
$ docker rm fri
4860
$ docker stop kong
4961
$ docker rm kong
50-
````
62+
$ docker stop kong-database
63+
$ docker rm kong-database
64+
```
5165

52-
Start and configure Cassandra container for Kong API.
53-
````
66+
Start and configure PostgreSQL container for Kong API.
67+
68+
```
5469
$ docker run -d --name kong-database \
55-
-p 9042:9042 \
56-
cassandra:3
70+
-p 5432:5432 \
71+
-e POSTGRES_USER=kong \
72+
-e POSTGRES_DB=kong \
73+
-e POSTGRES_PASSWORD=kong \
74+
postgres:13
75+
```
5776

77+
Run the Kong migrations for PostgreSQL.
5878

79+
```
5980
$ docker run --rm \
6081
--link kong-database:kong-database \
61-
-e "KONG_DATABASE=cassandra" \
82+
-e "KONG_DATABASE=postgres" \
6283
-e "KONG_PG_HOST=kong-database" \
6384
-e "KONG_PG_USER=kong" \
6485
-e "KONG_PG_PASSWORD=kong" \
65-
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
66-
kong kong migrations bootstrap
67-
````
86+
kong/kong-gateway:latest kong migrations bootstrap
87+
```
6888

6989
Start Kong
70-
````
90+
91+
```
7192
$ docker run -d --name kong \
7293
--link kong-database:kong-database \
73-
-e "KONG_DATABASE=cassandra" \
94+
-e "KONG_DATABASE=postgres" \
7495
-e "KONG_PG_HOST=kong-database" \
96+
-e "KONG_PG_USER=kong" \
7597
-e "KONG_PG_PASSWORD=kong" \
76-
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
7798
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
7899
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
79100
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
@@ -83,62 +104,62 @@ $ docker run -d --name kong \
83104
-p 8443:8443 \
84105
-p 8001:8001 \
85106
-p 8444:8444 \
86-
kong
87-
````
107+
kong/kong-gateway:latest
108+
```
88109

89110
Start FRI container
90-
````
91-
$ nohup sudo docker run --name fri -p 8090:8080 fri > controlcore.out &
92-
````
93-
94-
Delete if there is a previously configured Kong service. If not, skip this step. First you need to find the ID-VALUE for the route with a GET command before deleting the route and service.
95-
````
96-
$ curl -X GET "http://localhost:8001/services/fri/routes"
97-
````
98-
Use the ID output from above to issue the delete command as below (issue this only if you have a previous conflicting service definiton in kong. Otherwise, skip this step):
99-
````
100-
$ curl -X DELETE "http://localhost:8001/services/fri/routes/ID-VALUE"
101111

102-
$ curl -X DELETE "http://localhost:8001/services/fri/"
103-
````
112+
```
113+
$ nohup sudo docker run --name fri -p 8090:8080 fri > controlcore.out &
114+
```
104115

105116
Define Kong Service and Route.
106117

107-
First Configure a Kong service, replacing the variable "private-ip" with the private IP address of your server below.
108-
````
118+
First, configure a Kong service, replacing the variable "private-ip" with the private IP address of your server below.
119+
120+
```
109121
$ curl -i -X POST --url http://localhost:8001/services/ --data 'name=fri' --data 'url=http://private-ip:8090'
110-
````
111-
Then configure route to the service
112-
````
122+
```
123+
124+
Then configure a route to the service
125+
126+
```
113127
$ curl -i -X POST --url http://localhost:8001/services/fri/routes --data 'paths=/'
114-
````
128+
```
115129

116130
Now, controlcore.org is routed through the Kong APIs.
117131

118-
119132
# Troubleshooting the FRI
120133

121134
Connect to the Server VM
122-
````
135+
136+
```
123137
$ ssh -i "controlcore.pem" ubuntu@x.x.x.x
124-
````
138+
```
139+
125140
Check the Server logs.
126-
````
141+
142+
```
127143
$ tail -f controlcore.out
128-
````
144+
```
145+
129146
or
130-
````
147+
148+
```
131149
$ docker logs fri -f
132-
````
150+
```
151+
133152
Find the FRI docker container
134-
````
153+
154+
```
135155
$ docker ps
136-
````
137-
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
138-
dfdd3b3d3308 fri "python main.py" 38 minutes ago Up 38 minutes 0.0.0.0:80->80/tcp fri
156+
```
157+
158+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES dfdd3b3d3308 fri "python main.py" 38 minutes ago Up 38 minutes 0.0.0.0:80->80/tcp fri
139159

140160
Access the container
141-
````
161+
162+
```
142163
$ docker exec -it dfdd /bin/bash
143-
````
164+
```
144165

fri/docker-compose.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,39 @@ services:
99
- 8090:8080
1010
command: tail -f /dev/null
1111

12-
kong-database:
13-
image: cassandra:3
12+
postgres:
13+
image: postgres:13
14+
container_name: kong-database
15+
restart: always
16+
environment:
17+
POSTGRES_USER: kong
18+
POSTGRES_PASSWORD: kong
19+
POSTGRES_DB: kong
1420
ports:
15-
- 9042:9042
21+
- 5432:5432
22+
volumes:
23+
- postgres_data:/var/lib/postgresql/data
24+
25+
kong-migrations:
26+
image: kong
27+
depends_on:
28+
- postgres
29+
environment:
30+
KONG_DATABASE: postgres
31+
KONG_PG_HOST: kong-database
32+
KONG_PG_USER: kong
33+
KONG_PG_PASSWORD: kong
34+
command: kong migrations bootstrap
1635

1736
kong:
1837
image: kong
1938
depends_on:
20-
- kong-database
39+
- kong-migrations
2140
environment:
22-
KONG_DATABASE: cassandra
41+
KONG_DATABASE: postgres
2342
KONG_PG_HOST: kong-database
43+
KONG_PG_USER: kong
2444
KONG_PG_PASSWORD: kong
25-
KONG_CASSANDRA_CONTACT_POINTS: kong-database
2645
KONG_PROXY_ACCESS_LOG: /dev/stdout
2746
KONG_ADMIN_ACCESS_LOG: /dev/stdout
2847
KONG_PROXY_ERROR_LOG: /dev/stderr
@@ -34,4 +53,5 @@ services:
3453
- 8001:8001
3554
- 8444:8444
3655

37-
56+
volumes:
57+
postgres_data:

0 commit comments

Comments
 (0)