Info
Solution: Choose for temporary Blue and Green deployment. More detail can be found in this Custom Blue Green Deployment With Nginx And Gitlab Ci
Blue and Green deployment strategy
Nginx with bash scripting
-
With the bash script is registered via cronjob, we need to consider about two things
- Nginx need to be setup for
reverse proxy
androute traffic
when downtime occur - Docker will have strategy about scale up and down the service for reducing down time
- Nginx need to be setup for
-
With
nginx
configuration, it will be possible to reload a new configuration Nginx and except downtime when updating service withnginx
(Service will have retries but not return 5xx Error) -
On the script, it will flexibly re-change between 2 configurations via Blue Green Deployment Docker for Zero Downtime
-
Have
sleep
command between them, so it will change to default when the service becomes stable
Docker
With Docker strategy, it will perform some this task like
- When have new image on container registry, it will perform pull new image on that time. Update the
.env
file fromS3
- After that, it will scale up the service with 2 new containers, first once for routing traffic from old to new and rename new to original version. Proxy will be return to original version for process a new job
- This strategy will be occur quickly and carefully by having the health checking of container on each progress.
- It will reduce downtime when applied new service into. After deploy and recreate success, that will remove both container and image of old one for reclaim resource and update new tags into location for extract for next time.
How to running this script manually
Required tools to perform this script
-
This script is created for only
Debian
distro (Ubuntu, Kali, Raspian, Debian, …) not support for (RedHat, Centos, …). Need to consideration when installing -
Bash Script will need into some tools on below list
- Docker:
docker-compose, docker.io
- Download Tools:
curl, wget
JSON
processing:jq
- Docker:
Manually run this script
-
Parameter is obligated to pass for your command (Please input with right position with numeric):
- Name of the
gitlab
account (This account needs to be work with Token Generated - Token need put into ~/.credentials/gitlab)(E.x: Xeus-DevOps)
- Path to env file for whole container (This
.env
file is same as.env
file provide for docker-compose)(E.x: /some_platform/.env)
- Path to Nginx configuration file (Nginx configuration file for reverse proxy)
(E.x: /some_platform/nginx/nginx_default.conf)
- Optional with 2 - 3 containers (This will help optimize the resource for initialization containers, Require huge ram above 3 opt)
(E.x: 2 or 3)
- Name of the
-
Executable command (Before running this command, make sure it have rule execution enabled)
-
For rule execution enabled, run command:
chmod +x <your_bash_file>
orchmod 0700 <your_bash_file>
-
For running the command: using
bash
or./<your_script>
The contents of script can find out ▶️ ▶️ Blue Green Deployment Docker for Zero Downtime