-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add docker volume 1. Add local docker volume through override docker-compose 2. Default no volume mount * Add comment for cached mode * 1. Use default mysql images mysql:8.0.22 2. Remove from Docker.env 3. Open changes for mysql image tag using `MYSQL_IMAGE_TAG` environment variable * Update README * add named volume * Add labels in swarm mmode * Remove invalid env variable * remove echo * Remove container_name & restart from docker-compose.yml * Add comment for depends_on * Update build.yml include override file in ci pipeline * Add mount path * Remove quote * Update all step for local deployment in README * Update README * Update README * Update README * Add persistent for mysql in swarm mode * Update README * Update README * Update README * Correct env path in README Co-authored-by: Raghav2211 <[email protected]>
- Loading branch information
1 parent
acf3ccb
commit 4689898
Showing
10 changed files
with
195 additions
and
35 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
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
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,9 +1,8 @@ | ||
# Set these env variables | ||
|
||
#App variables | ||
PSI_TODO_IMAGE=psi-todo | ||
|
||
#Database variables | ||
# Mysql variables | ||
MYSQL_IMAGE_TAG=8.0.22 | ||
MYSQL_USER=root | ||
MYSQL_PASSWORD=root | ||
MYSQL_DATABASE=psi | ||
MYSQL_DATABASE=psi | ||
MYSQL_DATA_DEST_PATH=/var/lib/mysql |
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,17 +1,18 @@ | ||
# Set these env variables | ||
|
||
#App variables | ||
# App variables | ||
PSI_TODO_REPLICA=1 | ||
PSI_TODO_IMAGE=psi-todo:1.0.0 | ||
PSI_TODO_STACK_IMAGE=localhost:5000/psi-todo | ||
PSI_TODO_IMAGE_TAG=1.0.0 | ||
PSI_TODO_STACK_IMAGE=localhost:5000/psi-todo | ||
#BASIC_AUTH_ENABLE | ||
# if BASIC_AUTH_ENABLE=true [Default is false] then set below two variables | ||
#BASIC_AUTH_USERNAME= | ||
#BASIC_AUTH_PASSWORD= | ||
|
||
#Database variables | ||
# Mysql variables | ||
MYSQL_IMAGE_TAG=8.0.22 | ||
MYSQL_USER=root | ||
MYSQL_PASSWORD=root | ||
MYSQL_DATABASE=psi | ||
#MYSQL_DATA_SRC_PATH= | ||
MYSQL_DATA_DEST_PATH=/var/lib/mysql | ||
#BASIC_AUTH_ENABLE | ||
# if BASIC_AUTH_ENABLE=true [Default is false] then set below two variables | ||
#BASIC_AUTH_USERNAME= | ||
#BASIC_AUTH_PASSWORD= |
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 |
---|---|---|
@@ -1,14 +1,28 @@ | ||
version: "3" | ||
services: | ||
psimysql: | ||
deploy: | ||
deploy: | ||
labels: | ||
name: mysql | ||
version: ${MYSQL_IMAGE_TAG:-8.0.22} | ||
component: database | ||
env: "local" | ||
placement: | ||
constraints: | ||
- "node.role == worker" | ||
psitodoapp: | ||
image: ${PSI_TODO_STACK_IMAGE} | ||
deploy: | ||
deploy: | ||
labels: | ||
name: psi-todo | ||
version: ${PSI_TODO_IMAGE_TAG:-latest} | ||
component: web | ||
env: "local" | ||
replicas: ${PSI_TODO_REPLICA} | ||
placement: | ||
constraints: | ||
- "node.role == worker" | ||
- "node.role == worker" | ||
restart_policy: | ||
condition: on-failure | ||
delay: 5s | ||
max_attempts: 5 |
15 changes: 15 additions & 0 deletions
15
todo-app/env/local/docker-stack-persistent-compose-override.yml
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,15 @@ | ||
version: "3" | ||
services: | ||
psimysql: | ||
volumes: | ||
- mysql_data:${MYSQL_DATA_DEST_PATH}:cached # Strong consistency is quite expensive, requiring coordination between all of a files writers to guarantee | ||
# they don’t inappropriately clobber each other’s changes | ||
# So Relax consistency guarantees using `cached` mode (Don’t do this in production …) | ||
volumes: | ||
mysql_data: | ||
# To use below configuration for host path ensure MYSQL_DATA_SRC_PATH should exists | ||
# driver: local | ||
# driver_opts: | ||
# type: none | ||
# device: $PWD/${MYSQL_DATA_SRC_PATH} | ||
# o: bind |
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,108 @@ | ||
# Deploy Todo Application in swarm cluster | ||
# Deploy Todo Application in swarm cluster | ||
|
||
- Local Deployment | ||
|
||
## Local Deployment ## | ||
|
||
- Setup cluster | ||
|
||
Install Dependencies and run cluster | ||
|
||
```bash | ||
# Install all dependencies for local cluster | ||
$ bash install-dependencies.sh all | ||
|
||
# Boot local cluster [ Swarm Manager(s)/Worker(s) node ] | ||
$ bash cluster.sh create local | ||
``` | ||
|
||
Verify cluster | ||
|
||
```bash | ||
$ bash cluster.sh view local | ||
------------------------------------------------------------Nodes------------------------------------------------------------ | ||
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION | ||
zsrfmw8g8wavf8nsq1uo8xz7j * manager1 Ready Active Leader 19.03.12 | ||
quwa5fhv5vk7cuzw8m88prj8m worker1 Ready Active 19.03.12 | ||
------------------------------------------------------------Vm(s)------------------------------------------------------------ | ||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS | ||
manager1 * virtualbox Running tcp://192.168.99.149:2376 v19.03.12 | ||
worker1 - virtualbox Running tcp://192.168.99.150:2376 v19.03.12 | ||
``` | ||
|
||
|
||
- Link host docker client to the VM's docker daemon | ||
```bash | ||
$ eval $(docker-machine env manager1) | ||
``` | ||
- Build | ||
[Build & Create Docker Image](../README.md#build) | ||
- Deploy the Stack | ||
```bash | ||
# Local registry | ||
$ docker service create --name registry --publish 5000:5000 registry:2 | ||
# Tag the image as localhost:5000/psi-todo. This creates an additional tag for the existing image. | ||
$ docker tag psi-todo:1.0.0 localhost:5000/psi-todo | ||
# Push the image to the local registry running at localhost:5000 | ||
$ docker push localhost:5000/psi-todo | ||
# Remove locally cached images | ||
$ docker image remove psi-todo | ||
$ docker image remove psi-todo:1.0.0 | ||
$ docker image remove localhost:5000/psi-todo | ||
# Deploy todo app cluster | ||
$ docker stack deploy -c <(docker-compose --env-file=../env/<env>/Docker.env -f ../docker-compose.yaml -f ../env/<env>/docker-stack-compose-override.yml config) psi-todo | ||
# or | ||
# Apply persistent with mysql | ||
docker stack deploy -c <(docker-compose --env-file=../env/local/Docker.env -f ../docker-compose.yaml -f ../env/local/docker-stack-compose-override.yml -f ../env/local/docker-stack-persistent-compose-override.yml config) psi-todo | ||
``` | ||
- Verify all service up & running | ||
```bash | ||
$ docker service ls | ||
ID NAME MODE REPLICAS IMAGE PORTS | ||
x2or6oc3lkes psi-todo_psimysql replicated 1/1 mysql:8.0.22 | ||
zd2vezg73ksd psi-todo_psitodoapp replicated 1/1 localhost:5000/psi-todo:latest *:8080->8080/tcp | ||
ac6h0l8eg3ko registry replicated 1/1 registry:2 *:5000->5000/tcp | ||
``` | ||
- Access swagger api endpoint with below url. | ||
http://localhost:8080/swagger-ui/ | ||
- Uninstalling the Stack | ||
```bash | ||
$ docker stack rm psi-todo | ||
``` | ||
- Configuration | ||
The following table lists the configurable parameters of the TodoApp swarm cluster and their default values. | ||
Parameter | Description | Default | ||
--- | --- | --- | ||
`PSI_TODO_REPLICA` | No of replica for Todo-app | `1` | ||
`PSI_TODO_STACK_IMAGE` | Todo-app Image | `localhost:5000/psi-todo` | ||
`BASIC_AUTH_ENABLE` | Enable spring Basic-Auth | `false` | ||
`BASIC_AUTH_USERNAME` | Username of Basic-Auth | `` | ||
`BASIC_AUTH_PASSWORD` | Password of Basic-Auth | `` | ||
`MYSQL_IMAGE_TAG` | Image tag for Mysql | `8.0.22` | ||
`MYSQL_USER` | Username of new user to create | `root` | ||
`MYSQL_PASSWORD` | Password for the new user | `root` | ||
`MYSQL_DATABASE` | Name for new database to create | `psi` | ||
`MYSQL_DATA_SRC_PATH` | Host path for persistence mysql data | `` | ||
`MYSQL_DATA_DEST_PATH` | Mount directory path in mysql container | `/var/lib/mysql` | ||