This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added kubernetes deployment etc Added logic for health and readiness checks * Renamed gateway and server images Updated readme for building project locally for using inside kubernetes * Corrected import paths Removed imports which pointed out to internal repo * Fixed healthcheck probes for gateway
- Loading branch information
Showing
14 changed files
with
375 additions
and
74 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
bin | ||
.vscode | ||
debug |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -10,67 +10,89 @@ These instructions will get you a copy of the project up and running on your loc | |
|
||
### Prerequisites | ||
|
||
#### Local setup: | ||
Need `mysql` or `mariadb` installed. | ||
Install go dep | ||
|
||
E.g. | ||
|
||
Install database engine: | ||
``` | ||
$ sudo dnf install mariadb mariadb-server | ||
``` sh | ||
go get -u github.com/golang/dep/cmd/dep | ||
``` | ||
|
||
Start database server: | ||
``` | ||
$ systemctl start mariadb | ||
``` | ||
Need `postgresql` installed locally or running inside docker container within `contacts` database created. | ||
You can change the name of database in `dsn` parameter in `server` app. | ||
Table creation in this example is omitted as it will be done autmotically by `gorm`. | ||
|
||
Create `atlas-contacts-app` database: | ||
### Installing | ||
|
||
``` | ||
$ mysql -u root | ||
``` | ||
#### Build the project | ||
|
||
``` | ||
MariaDB [(none)]> CREATE DATABASE atlas-contacts-app; | ||
``` sh | ||
make vendor | ||
make | ||
``` | ||
|
||
Create necessary table: | ||
``` | ||
$ mysql -u root atlas-contacts-app < ./migrations/0001_contacts.sql | ||
``` | ||
If this process finished with errors it's likely that docker doesn't allow to mount host directory in its container. | ||
Therefore you are proposed to run `su -c "setenforce 0"` command to fix this issue. | ||
|
||
#### Local setup | ||
|
||
### Installing | ||
Please note that you should have the following ports opened on you local workstation: `:8080 :9090 :8088 :8089`. | ||
If they are busy - please change them via corresponding parameters of `gateway` and `server` binaries. | ||
|
||
#### Local setup: | ||
Run GRPC server: | ||
|
||
Build the project. | ||
``` | ||
make | ||
``` sh | ||
./bin/server -dsn "host=localhost port=5432 user=postgres password=postgres sslmode=disable dbname=contacts" | ||
``` | ||
|
||
Run GRPC gateway: | ||
``` | ||
|
||
``` sh | ||
./bin/gateway | ||
``` | ||
|
||
Run GRPC server: | ||
``` | ||
./bin/server -dsn root:@tcp/atlas-contacts-app | ||
#### Try atlas-contacts-app | ||
|
||
``` sh | ||
curl http://localhost:8080/atlas-contacts-app/v1/contacts -d '{"first_name": "Mike", "email_address": "[email protected]"}' | ||
``` | ||
|
||
Try atlas-contacts-app: | ||
``` sh | ||
curl http://localhost:8080/atlas-contacts-app/v1/contacts -d '{"first_name": "Bob", "email_address": "[email protected]"}' | ||
``` | ||
curl http://localhost:8080/atlas-contacts-app/v1/contacts -d '{"first_name": "Mike", "email_address": "[email protected]"}' | ||
|
||
``` sh | ||
curl http://localhost:8080/atlas-contacts-app/v1/contacts?_filter='first_name=="Mike"' | ||
|
||
#### Local Kubernetes setup | ||
|
||
Open a seperate terminal session where execute `eval $(minikube docker-env)`. This is needed to make these images available for local kubernetes without pushing them to global repo. | ||
|
||
Then: | ||
|
||
``` sh | ||
make image | ||
make up | ||
``` | ||
|
||
To shutdown and cleanup: | ||
|
||
``` sh | ||
make down | ||
make image-clean | ||
rm -rf bin | ||
``` | ||
curl http://localhost:8080/atlas-contacts-app/v1/contacts -d '{"first_name": "Bob", "email_address": "[email protected]"}' | ||
|
||
#### Try local Kubernetes atlas-contacts-app | ||
|
||
``` sh | ||
curl http://$(minikube ip):31500/atlas-contacts-app/v1/contacts -d '{"first_name": "Mike", "email_address": "[email protected]"}' | ||
``` | ||
|
||
``` sh | ||
curl http://$(minikube ip):31500/atlas-contacts-app/v1/contacts -d '{"first_name": "Bob", "email_address": "[email protected]"}' | ||
``` | ||
curl http://localhost:8080/atlas-contacts-app/v1/contacts?_filter='first_name=="Mike"' | ||
|
||
``` sh | ||
curl http://$(minikube ip):31500/atlas-contacts-app/v1/contacts?_filter='first_name=="Mike"' | ||
``` | ||
|
||
## Deployment | ||
|
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
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
Oops, something went wrong.