Monday, March 28, 2022

IBM Capstone Raman Guide

 Prerequisite: 

            Valid Gitlab Account

            Valid Dockerhub Account and login to local system with that credentials

           

Step 1: Create a single EC2 instance

            AMI : ubuntu 18.04

           Instance Type: t2.medium

           SG : All traffic to open

           key: some valid key

Step 2: Install maven, docker ,gitlab runner

           sudo apt update

Maven:

           sudo apt install maven -y

Docker:

           sudo apt install docker.io -y

GitLab runner:

curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash

sudo apt-get install gitlab-runner

sudo gitlab-runner register

sudo vi /etc/sudoers

and add below entry after root user info and save your file

gitlab-runner ALL=(ALL) NOPASSWD: ALL

GitLab deploy keys

ssh-keygen

cat and copy 

Make branches for dev1, dev2, and release

git branch

git checkout

Code from dev1 or dev2 ---> release branch ---> main branch

   

Step 4: Create a sample maven quick start project using maven archetype.

mvn generate:archetype

com.irfan

artifactID: capstone-maven

Edit pom.xml and put in sonarcloud dependency

<properties>
  <sonar.organization>ibm-capstone-sonarcloud</sonar.organization>
</properties>

Put in sonarcloud variables in the GitLab variables

sonar token

sonar url

Config git global

git config --global user.name ifanrahman

git config --global user.email ifanrahman@gmail.com

make a Dockerfile

craft a robust .gitlab-ci.yml

push into remote repo



Step 10: To create a Dockerfile - multistage to define the steps to include and deploy your jar file.

Step 11: Create Gitlab CI/CD Pipeline where you need to define following stages

  In each stage create a log file and store the information that stage is completed or not.

    build stage:- Create the jar file using mvn clean package command

   builddockerimg stage: Build Dockerfile by adding jar file in the dockerimage.

   ImageScan Stage: docker scan for docker images

   ImagePush stage: docker image is to be pushed to docker hub

   test stage: jar file get created---pass

  Parallel test stage: container from docker image and if you find the container get created it means test is passed


Step 12: In k8s cluster run the NodePort service to expose an application on the browser

No comments:

Post a Comment

Fluentd

Open-source log data collector > why logs? - for compliance (auditing, company, business) - for security (transparency, monitoring, admin...