microservice
Screenshots
A Pull Request being Built in Staging Environment
A Successful Pull Request Built in Staging Environment
Continuous Integration System notification to GitHub when a PR is being built.
Continuous Integration System notification to GitHub upon a successful PR build.
Deploying on Docker
Create Docker Machine. Use this only if you have Docker Machine installed.
./1-docker_create-docker-machine.sh
Deploy MySQL
./2-docker_deploy-mysql.sh
Deploy the App
./3-docker_deploy-microservice.sh
Deploy the App using the Dockerfile in ./docker/microservice/
./3-docker_deploy-microservice-v2.sh
Clean up
./docker_cleanup.sh
Remove Docker Machine( optional)
./5-docker_remove-docker-machine.sh
Deploying on Kubernetes using kubectl( By default qa profile will be activated)
Deploy MySQL. Note that this Deployment uses Config Maps to initialize the Database.
./6-kubectl_deploy-mysql.sh
Deploy MySQL( Pass TARGET_IMAGE_NAME to push it to your own Image Repository). By default the Service will be deployed in LoadBalancer configuration. Furthermore qa Spring Profile will be activated. imagePullPolicy in the Deployment is set to Always to make sure the image gets downloaded everytime.
./7-kubectl_deploy-microservice.sh TARGET_IMAGE_NAME
Clean up
./8-kubectl_cleanup.sh
Deploying on Kubernetes using Helm
Deploy the app with Helm using the below command. Note that this script will initialize the Database with a Config Map and that can be maximum 1MB in size( need to confirm this).
./9-helm_deploy.sh
Deploy the app with Helm using the below command. It will build the MySQL image with the initialization scripts. The script assumes your App image is already in built and pushed.
./9-helm_deploy-v2.sh
Clean up
./9-helm_cleanup.sh
Configuring Jenkins
Adding the Pipeline to Jenkins
Open Blue Ocean Plugin. Click New Pipeline Button to create the new Pipeline. Jenkins will guide you through the rest of the process. Select GitHub then you may be asked to create a GitHub Access Token.
Adding Webhooks
Go to Credentials -> System -> Global Credentials and click Add Credentials. Select Secret Text. Then add a Shared Secret between Jenkins and Your GitHub Project. Go to Configuration( Manage Jenkins). Then click Advanced Button which comes under GitHub. Select your Shared Secret. Then click Save. Go to your GitHub Project Settings -> Webhooks. Click Add Webhook. Payload URL will be /github-webhook/. Select application/json as Content Type. Then select Send me everything under Triggers. Now you are all set.
Adding Environment Variables
To add Environment Variables for your Cluster go to Manage Jenkins Section.
Pull Request Build Strategy
In the Project Configuration select the option shown to prevent Branches associated with Pull Requests getting built twice.
Discarded Directory
You might find some useful code snippets in ./discarded directory.
ToDos
Handle Webhook Events from the Jenkinsfile( Commits, Tags, PRs)Build the AppPush the App to Dockerhub or some private RepositoryDeploy the App( Using helm)Rollback ( Using Helm)Infrastructure Configuration( In the Infrastructure Repo)Make use of skipping stages in Jenkins Pipelines( When Directive)