Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------- Secret manager -----------------------------------------------------------------
- [ec2-user@ip-172-31-41-59 ~]$ docker network create ip-net
- efc44817ff3a60963f482466c5f33b2b420dd64ef9332f4327c660e8270e9ee3
- [ec2-user@ip-172-31-41-59 ~]$ docker container run --name redis --network ip-net --restart always -d redis:latest
- Unable to find image 'redis:latest' locally
- docker container run \
- --name ip-api \
- --network ip-net \
- --restart always \
- -d \
- -p 8080:8080 \
- -e REDIS_PORT="6379" \
- -e REDIS_HOST="redis" \
- -e APP_PORT="8080" \
- -e API_KEY_FROM_SECRETSMANAGER="True" \
- -e SECRET_NAME="geolocation_secret" \
- -e SECRET_KEY="geolocation_api_key" \
- -e REGION_NAME="ap-south-1" \
- fujikomalan/ipgeolocation-api-service
- 09a277a3ad068d1d26d3b1254d253227f2990bc1daae7ca10fab34369a422593
- [ec2-user@ip-172-31-41-59 ~]$ docker container ls -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 09a277a3ad06 fujikomalan/ipgeolocation-api-service "python3 app.py" About a minute ago Up About a minute 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp ip-api
- 342e48ee42b6 redis:latest "docker-entrypoint.s…" 38 minutes ago Up 38 minutes 6379/tcp redis
- [ec2-user@ip-172-31-41-59 ~]$
- [ec2-user@ip-172-31-41-59 ~]$
- IAM Role policy
- {
- "Version": "2012-10-17",
- "Statement": [
- {
- "Effect": "Allow",
- "Action": [
- "secretsmanager:GetResourcePolicy",
- "secretsmanager:GetSecretValue"
- ],
- "Resource": "arn:aws:secretsmanager:ap-south-1:945577359662:secret:geolocation_secret-8e9tZD"
- },
- {
- "Effect": "Allow",
- "Action": "secretsmanager:ListSecrets",
- "Resource": "*"
- }
- ]
- }
- ---------------------------------------------------------------- Docker Swarm -----------------------------------------------------------------
- [ec2-user@ip-172-31-40-192 ~]$ docker swarm init
- Swarm initialized: current node (6cs1iq3gba80awdlqqaqzb6v5) is now a manager.
- To add a worker to this swarm, run the following command:
- docker swarm join --token SWMTKN-1-4hw9qjhfi1tan0h20e9zgces9c0ybbohkcvwnbq5bhgfdliugg-cuta7eyg5trtoq4fg0j5qfnui 172.31.40.192:2377
- To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker swarm join-token worker
- To add a worker to this swarm, run the following command:
- docker swarm join --token SWMTKN-1-4hw9qjhfi1tan0h20e9zgces9c0ybbohkcvwnbq5bhgfdliugg-cuta7eyg5trtoq4fg0j5qfnui 172.31.40.192:2377
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-44-177 ~]$ docker swarm join --token SWMTKN-1-4hw9qjhfi1tan0h20e9zgces9c0ybbohkcvwnbq5bhgfdliugg-cuta7eyg5trtoq4fg0j5qfnui 172.31.40.192:2377
- This node joined a swarm as a worker.
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-33-112 ~]$ docker swarm join --token SWMTKN-1-4hw9qjhfi1tan0h20e9zgces9c0ybbohkcvwnbq5bhgfdliugg-cuta7eyg5trtoq4fg0j5qfnui 172.31.40.192:2377
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker node ls
- ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION
- cpqu4fkc9w3e0wq3sl4jy04u8 ip-172-31-33-112.ap-south-1.compute.internal Ready Active 20.10.23
- 6cs1iq3gba80awdlqqaqzb6v5 * ip-172-31-40-192.ap-south-1.compute.internal Ready Active Leader 20.10.23
- 6ekz9hlnnk7gb5uo89lh7xid5 ip-172-31-44-177.ap-south-1.compute.internal Ready Active 20.10.23
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker service create \
- > --name web \
- > -p 80:80 \
- > --replicas 2 \
- > fujiclado/rolling-hello:green
- hsjjfemcxdjmljlpa743pptc6
- overall progress: 2 out of 2 tasks
- 1/2: running [==================================================>]
- 2/2: running [==================================================>]
- verify: Service converged
- [ec2-user@ip-172-31-40-192 ~]$ docker service ls
- ID NAME MODE REPLICAS IMAGE PORTS
- hsjjfemcxdjm web replicated 2/2 fujiclado/rolling-hello:green *:80->80/tcp
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker service ps web
- ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
- irbv5suh5paq web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Running Running 30 seconds ago
- a7vy79e44b2v web.2 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Running Running 30 seconds ago
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker service update --replicas 6 web
- web
- overall progress: 6 out of 6 tasks
- 1/6: running [==================================================>]
- 2/6: running [==================================================>]
- 3/6: running [==================================================>]
- 4/6: running [==================================================>]
- 5/6: running [==================================================>]
- 6/6: running [==================================================>]
- verify: Service converged
- [ec2-user@ip-172-31-40-192 ~]$ docker service ps web
- ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
- irbv5suh5paq web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Running Running 7 minutes ago
- a7vy79e44b2v web.2 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Running Running 7 minutes ago
- csskfimpn678 web.3 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Running Running 13 seconds ago
- oppheyor3i6f web.4 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Running Running 13 seconds ago
- gzhs7c9qsoly web.5 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Running Running 8 seconds ago
- 1eyaoer5lfov web.6 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Running Running 8 seconds ago
- ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- ------------ Stopping the container to check whether the swar will create a new container -----------------------
- [ec2-user@ip-172-31-40-192 ~]$ ssh ec2-13-127-210-25.ap-south-1.compute.amazonaws.com
- , #_
- ~\_ ####_ Amazon Linux 2023
- ~~ \_#####\
- ~~ \###|
- ~~ \#/ ___ https://aws.amazon.com/linux/amazon-linux-2023
- ~~ V~' '->
- ~~~ /
- ~~._. _/
- _/ _/
- _/m/'
- Last login: Mon Jun 5 10:16:38 2023 from 172.31.40.192
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-44-177 ~]$ docker container ls -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 09f9c1aecc7d fujiclado/rolling-hello:green "/docker-entrypoint.…" About a minute ago Up About a minute web.3.csskfimpn678zg0ctyrap8jwo
- 73c3f7990eab fujiclado/rolling-hello:green "/docker-entrypoint.…" 8 minutes ago Up 8 minutes web.1.irbv5suh5paqnm6e65xnf3eql
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-44-177 ~]$ docker container stop web.1.irbv5suh5paqnm6e65xnf3eql
- web.1.irbv5suh5paqnm6e65xnf3eql
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-44-177 ~]$
- [ec2-user@ip-172-31-44-177 ~]$ docker container ls -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 1af5e6538d2f fujiclado/rolling-hello:green "/docker-entrypoint.…" 7 seconds ago Up 1 second web.1.bbzhffwsq9v98r7phzx27rssg
- 09f9c1aecc7d fujiclado/rolling-hello:green "/docker-entrypoint.…" About a minute ago Up About a minute web.3.csskfimpn678zg0ctyrap8jwo
- 73c3f7990eab fujiclado/rolling-hello:green "/docker-entrypoint.…" 9 minutes ago Exited (1) 7 seconds ago web.1.irbv5suh5paqnm6e65xnf3eql
- [ec2-user@ip-172-31-44-177 ~]$
- ---------------------------- Image update ---------------------------------
- [ec2-user@ip-172-31-40-192 ~]$ docker service update --image fujiclado/rolling-hello:blue web
- web
- overall progress: 6 out of 6 tasks
- 1/6: running [==================================================>]
- 2/6: running [==================================================>]
- 3/6: running [==================================================>]
- 4/6: running [==================================================>]
- 5/6: running [==================================================>]
- 6/6: running [==================================================>]
- verify: Service converged
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker service ps web
- ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
- hkllb256on9s web.1 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Running Running 34 seconds ago
- bbzhffwsq9v9 \_ web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 35 seconds ago
- irbv5suh5paq \_ web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Failed 6 minutes ago "task: non-zero exit (1)"
- lyqxzb5ioree web.2 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Running Running 10 seconds ago
- a7vy79e44b2v \_ web.2 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 10 seconds ago
- mq6ehaicya2d web.3 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Running Running 29 seconds ago
- csskfimpn678 \_ web.3 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 30 seconds ago
- i0y4ffysbdur web.4 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Running Running 18 seconds ago
- oppheyor3i6f \_ web.4 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 20 seconds ago
- liz7g5lpy3ka web.5 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Running Running 24 seconds ago
- gzhs7c9qsoly \_ web.5 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 26 seconds ago
- oiw7cyyxkk9a web.6 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Running Running 14 seconds ago
- 1eyaoer5lfov \_ web.6 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 15 seconds ago
- [ec2-user@ip-172-31-40-192 ~]$ docker service update --image fujiclado/rolling-hello:yellow web
- web
- overall progress: 6 out of 6 tasks
- 1/6: running [==================================================>]
- 2/6: running [==================================================>]
- 3/6: running [==================================================>]
- 4/6: running [==================================================>]
- 5/6: running [==================================================>]
- 6/6: running [==================================================>]
- verify: Service converged
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker service ps web
- ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
- zn7d89txdirx web.1 fujiclado/rolling-hello:yellow ip-172-31-44-177.ap-south-1.compute.internal Running Running 38 seconds ago
- hkllb256on9s \_ web.1 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 40 seconds ago
- bbzhffwsq9v9 \_ web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 2 minutes ago
- irbv5suh5paq \_ web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Failed 8 minutes ago "task: non-zero exit (1)"
- yywk4kb55g74 web.2 fujiclado/rolling-hello:yellow ip-172-31-33-112.ap-south-1.compute.internal Running Running 43 seconds ago
- lyqxzb5ioree \_ web.2 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 45 seconds ago
- a7vy79e44b2v \_ web.2 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 2 minutes ago
- s8181x8ecgz5 web.3 fujiclado/rolling-hello:yellow ip-172-31-44-177.ap-south-1.compute.internal Running Running 33 seconds ago
- mq6ehaicya2d \_ web.3 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 34 seconds ago
- csskfimpn678 \_ web.3 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 2 minutes ago
- 2ieldul5r4so web.4 fujiclado/rolling-hello:yellow ip-172-31-33-112.ap-south-1.compute.internal Running Running 23 seconds ago
- i0y4ffysbdur \_ web.4 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 24 seconds ago
- oppheyor3i6f \_ web.4 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 2 minutes ago
- ysipxd6duf4p web.5 fujiclado/rolling-hello:yellow ip-172-31-40-192.ap-south-1.compute.internal Running Running 27 seconds ago
- liz7g5lpy3ka \_ web.5 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 30 seconds ago
- gzhs7c9qsoly \_ web.5 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 2 minutes ago
- ybba2xoi0vjt web.6 fujiclado/rolling-hello:yellow ip-172-31-40-192.ap-south-1.compute.internal Running Running 19 seconds ago
- oiw7cyyxkk9a \_ web.6 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 19 seconds ago
- 1eyaoer5lfov \_ web.6 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 2 minutes ago
- [ec2-user@ip-172-31-40-192 ~]$
- ------------------------------------------------------------- Rollback =---------------------------------------------------------------`
- [ec2-user@ip-172-31-40-192 ~]$ docker service rollback web
- web
- rollback: manually requested rollback
- overall progress: rolling back update: 6 out of 6 tasks
- 1/6: running [> ]
- 2/6: running [> ]
- 3/6: running [> ]
- 4/6: running [> ]
- 5/6: running [> ]
- 6/6: running [> ]
- verify: Service converged
- [ec2-user@ip-172-31-40-192 ~]$
- [ec2-user@ip-172-31-40-192 ~]$ docker service ps web
- ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
- y1w1qblkwoaa web.1 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Running Running 31 seconds ago
- zn7d89txdirx \_ web.1 fujiclado/rolling-hello:yellow ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 32 seconds ago
- hkllb256on9s \_ web.1 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown about a minute ago
- bbzhffwsq9v9 \_ web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 3 minutes ago
- irbv5suh5paq \_ web.1 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Failed 9 minutes ago "task: non-zero exit (1)"
- 9c2e6buauiao web.2 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Running Running 9 seconds ago
- yywk4kb55g74 \_ web.2 fujiclado/rolling-hello:yellow ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 9 seconds ago
- lyqxzb5ioree \_ web.2 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 2 minutes ago
- a7vy79e44b2v \_ web.2 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 3 minutes ago
- j4werr91exfm web.3 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Running Running 27 seconds ago
- s8181x8ecgz5 \_ web.3 fujiclado/rolling-hello:yellow ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 28 seconds ago
- mq6ehaicya2d \_ web.3 fujiclado/rolling-hello:blue ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown about a minute ago
- csskfimpn678 \_ web.3 fujiclado/rolling-hello:green ip-172-31-44-177.ap-south-1.compute.internal Shutdown Shutdown 3 minutes ago
- mocprbrlf67z web.4 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Running Running 13 seconds ago
- 2ieldul5r4so \_ web.4 fujiclado/rolling-hello:yellow ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 14 seconds ago
- i0y4ffysbdur \_ web.4 fujiclado/rolling-hello:blue ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown about a minute ago
- oppheyor3i6f \_ web.4 fujiclado/rolling-hello:green ip-172-31-33-112.ap-south-1.compute.internal Shutdown Shutdown 3 minutes ago
- 5hpmudq2t4sa web.5 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Running Running 22 seconds ago
- ysipxd6duf4p \_ web.5 fujiclado/rolling-hello:yellow ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 23 seconds ago
- liz7g5lpy3ka \_ web.5 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown about a minute ago
- gzhs7c9qsoly \_ web.5 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 3 minutes ago
- osytt025v0s3 web.6 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Running Running 18 seconds ago
- ybba2xoi0vjt \_ web.6 fujiclado/rolling-hello:yellow ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 19 seconds ago
- oiw7cyyxkk9a \_ web.6 fujiclado/rolling-hello:blue ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown about a minute ago
- 1eyaoer5lfov \_ web.6 fujiclado/rolling-hello:green ip-172-31-40-192.ap-south-1.compute.internal Shutdown Shutdown 3 minutes ago
Advertisement
Add Comment
Please, Sign In to add comment