The new architecture is based on Gitlab-CI and Gitlab Flow.
By default, each commit will trigger a pipeline automatically exclude commit message contains [skip ci].
This components contains FIVE STAGES which are BasicCheck, Build, SelfCheck, DeployDev, Auto-test. It automatic runs totally.
BasicCheck
- check Dockerfile
- check harbor permissions
- check image name
Build
- build docker image
- generate helm package
- update helm version in consul
SelfCheck
- scan image security
- analyse image size
DeployDev
- auto deploy to Dev
AutoTest
- health check
This component connects CI and CD pipeline, also it plays an important role in cross branches operation. Usually, engineer develops in dev branch. CI pipeline ensures the new feature quality. Once some feature needs integration test, engineer will merge related code to sit branch which will enter in CD pipeline.
-
build sit
-
deploy sit
-
deploy uat
-
deploy prod
-
smoke test
Each release of prod, we will archive not only gitlab, but also helm package in case of roll back.
First of all, everything is based on GitLab CI which means you must have a gitlab project to start integration. I will provide an example to explain how to integrate.
Step 1 Create a file named .gitlab-ci.yml under your project root dir.
This project, unified-exam-service, is going to integrate with GitLab CI. The .gitlab-ci.yml is located in the project root.
Step 2 Modify .gitlab-ci-yml as follows.
# vi .gitlab-ci.yml
variables:
INCLUDE: “main.yml” # this is required! It defines what template to include. At present, we only provide `main.yml` template.
init-project:
script:
- git archive —[email protected]:DevOps/templates.git HEAD:gitlab-ci init.py |tar -x # this is required! Please DO NOT change it!
- python3 init.py # this is required! Please DO NOT change it!
tags:
- init # this is required! Please DO NOT change it!
artifacts:
paths:
- gitlab-ci-init.yml # this is required! Please DO NOT change it!
Step 3
-
Commit and push .gitlab-ci.yml. Then check your project website left menu .
-
You will find a pipeline which looks like above image. Then click icon.
-
Then click , you will see the notice message “please download artifacts and rename gitlab-ci-init.yml to .gitlab-ci.yml under your project root dir!”
-
At last overwrite your .gitlab-ci.yml with the downloaded file then commit and push it!
-
If you see the above pipeline under your CI/CD menu, congratulations! Happy GitLab CI!
-
All build is based on Dockerfile.
-
All deploy is based on Helm.