Showing posts with label assignments. Show all posts
Showing posts with label assignments. Show all posts

Sunday, March 13, 2022

ASSIGNMENTS: Docker Network Part 1 (Using Custom Network)

 


Challenge: Create a bridge network and run a web app container which stores the data in a database container.

Docker images:
webapp: ramansharma95/webapp
db: ramansharma95/mysql

webapp: This image is used as a webserver container which runs on apache. There is an index.php file hosted on this server in this directory (/var/www/html/index.php) and it is a simple webform to enter details in the database container.

db: This image is used as database container which runs on mysql and stores the data recorded/collected/received from the webserver - webapp. This database container's details should be a part of webapp's connection string.

For webapp container to be connected and functional, we need to create a database called company and a table in the company database called employee which has name, mobile fields IN the db container.

Thursday, March 10, 2022

ASSIGNMENTS: Docker Network Part 3 (None Network)


 


None Network

When no IP address is assigned to the container you can run the container in none network. It is mostly used for applications that need to be tested in an isolated environment. After testing, we can disconnect the container from the network and connect it to another network.


Step 1: Create a centos container on none or null network

docker container run -it --name c1 --network none -d centos

Step 2: Inspect the container and verify that it is running on none networks

docker inspect c1

Step 3: Once the testing is done then remove none network from n1 container and attach bridge network

docker network disconnect none c1

docker network connect bridge c1

Step 4: Verify the n1 container is having bridge network

docker inspect c1

Wednesday, March 9, 2022

ASSIGNMENT: Kubernetes Services (Webserver link and integrate MySQL database)




Assignment by Raman 9 March 2022

1. Create a deployment for a webapp (ramansharma95/webapp) on port 80 (replica =1)

2. Create a deployment for a dbapp (ramansharma95/mysql) on port 3306 (replica=1)

3. Create a NodePort service(name of service webservice) for webapp and nodeport value is 31000.

4. Create a ClusterIP service(name of service db) for dbapp.

5. The webservice should communicate to db. (In webapp there is a connection string which points to db)

-----------------------------------------------------------------------------------------------------------------

1. webapp-deploy.yaml

# webapp-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp-deploy
  labels:
    server: web
spec:
  replicas: 1
  template:
    metadata:
      labels:
        server: web
    spec:
      containers:
      - name: webapp-raman
        image: ramansharma95/webapp
        ports:
        - containerPort: 80
  selector:
    matchLabels:
      server: web


2. dbapp-deploy.yaml

# dbapp-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dbapp-deploy
  labels:
    server: db
spec:
  replicas: 1
  template:
    metadata:
      labels:
        server: db
    spec:
      containers:
      - name: mysql-raman
        image: ramansharma95/mysql
        ports:
        - containerPort: 3306
  selector:
    matchLabels:
      server: db


3. webapp-np.yaml

# Service
# webapp-np.yaml
apiVersion: v1
kind: Service
metadata:
  name: webservice
  labels:
    server: web
spec:
  selector:
    server: web
  type: NodePort
  ports:
  - nodePort: 31000
    #clusterIP (THIS ONE NEED TO CHECK ON YOUR VAGRANTFILE CONFIG WHAT GUEST PORT)
    port: 80
    #service port
    targetPort: 80
    #container port

4. dbapp-ci.yaml

apiVersion: v1
kind: Service
metadata:
  name: db
spec:
  type: ClusterIP
  selector:
    server: db
  ports:
      # By default and for convenience, the `targetPort` is set to the same value as the `port` field.
    - port: 3306
      targetPort: 3306
      # Optional field
      # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)

5. kubectl exec -it dbapp-deploy -- bash
mysql -uroot -pwhizlabs
create database company;
use company;
create table employee ( name varchar(30), mobile varchar(30) );

*enter data into the webserver*

select * from employee

exit


Monday, March 7, 2022

ASSIGNMENT: Kubernetes Pod



Try This
Consideration:- You have 3 nodes ( 1 master and 2 worker nodes) Cluster.

  1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
    kubectl run nginx-pod1 --image=nginx 
    OR
    #nginx-pod1.yaml
    apiVersion: v1
    kind: Pod
    metadata:
        name: nginx-pod1
    spec:
        containers:
            - name: c1
             
    image: nginx

  2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
    kubectl run tomcat-pod1 --image=tomcat
    OR
    #tomcat-pod1.yaml
    apiVersion: v1
    kind: Pod
    metadata:
        name: tomcat-pod1
    spec:
        containers:
            - name: c1
              image: tomcat

  3. Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason.
    kubectl get pods -o wide
    curl <podIP>
    yes able to.
    for nginx is ok but for tomcat need to put port number (8080)

  4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.
    kubectl exec -it tomcat-pod1 -- bash
    curl <nginx-pod1 IP:port>
    can cause in same localhost (calico network layer)


  5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.
    kubectl exec -it nginx-pod1 -- bash
    curl <tomcat-pod1 IP:port>
    can cause in same localhost (calico network layer)

  6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible to do on a running pod?
    No.
    Error from server (AlreadyExists): pods "nginx-pod1" already exists
    kubectl edit pod nginx-pod1 -o yaml (then edit the image to change to tomcat).

  7. Check the restart value of nginx-pod1 (it must change to 1)
    kubectl get pod nginx-pod1 -o wide

  8. check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
    kubectl describe pod tomcat-pod1
    Name:         tomcat-pod1
    Namespace:    default

  9. Display the tomcat-pod1 properties in json format.
    kubectl get pod tomcat-pod1 -o json

  10. Delete all the pods.
    kubectl delete pod --all


Monday, February 28, 2022

ASSIGNMENTS: Docker Network Part 2 (Using Host Network)


Step 1: Download required images

docker pull ramansharma95/webapp
docker pull ramansharma95/mysql

Step 2: Create a webapp container with network as host and DO NOT DO a port forwarding on port number 80 as per custom network cause this assignment is run on host network.

docker container run -it --name web --network host -d ramansharma95/webapp

Go to browser and check that you are able to see the default web page. localhost:80

Step 3: Go inside the container (web) and check the code for index.php cause you will need to edit it a little.

docker exec -it web bash

vi /var/www/html/index.php

edit the username from db to host ip address (192.168.33.10).
# you will find that in the index.php, it has connection configs to connect to a server named 'db' but need to edit to host ip address cause its on the same network and also the required username and password to enter that server.

Step 4:- Create a db container with network defined (note this does not require port forwarding)

docker container run -it --name db --network host -d ramansharma95/mysql

Step 5:- Go inside the container (db).

docker exec -it db bash

5.2 connect to mysql with username root and password whizlabs

mysql -uroot -pwhizlabs

5.3 Create a database company

show databases;

create database company;

show databases;

5.4 Create a table employee with name and mobile field.

use company;

create table employee ( name varchar(30), mobile varchar(30) );

5.5 Show all the records in this table

select * from employee;

Step 6: Go to browser and add some employees details in the webpage and check again records in employee table, it should have those records added.

Step 7: Show all the records in this table.

select * from employee;




ASSIGNMENTS: Docker Volume


 

ASSIGNMENT 1:-

1. Create a docker apache image using Dockerfile.

 2. Create a deploy-vol docker volume.

 3. Run a container using docker apacheimg with port forwarding 80:80 and map /var/www/html folder to deploy-vol.

4. Check default apache page is accessible on the browser.

5. Copy/Create a test.html file under /var/lib/docker/volumes/deploy-vol/_data

6. Check on the browser that you are able to access this webpage (test.html)

7. Go inside the container and create a file newtest.html under /var/www/html and verify that you are able to access it with the browser.


0. mkdir dockvolassignment
0.1 cd dockvolassignment

1. vi Dockerfile

1.2 in Dockerfile:
FROM ubuntu
#from is getting the base image  

ARG DEBIAN_FRONTEND=noninteractive
#noninteractive for automation so it does not ask questions such as geographical..

RUN apt-get update
#run is adding instruction on the instruction layer

RUN apt-get -y install apache2

ADD . /var/www/html
#add is copy the file from host machine to docker image folder

ENTRYPOINT apachectl -D FOREGROUND
#entrypoint whenever docker image is used in a container, some commands need to be executed automatically

ENV name DEVOPS
#environment variable is used on the global level

1.3 docker build . -t apacheimg

2. docker volume create deploy-vol

3. docker container run --name assignment1 -v deploy-vol:/var/www/html -dit -p 80:80 apacheimg

4. curl localhost

5. echo "<h1> Welcome to test.html page! </h1>" > /var/lib/docker/volumes/deploy-vol/_data/test.html

6. curl localhost/test.html

7. docker exec -it assignment1 bash

7.2 in container:

echo "<h1> This is newtest page and NOT test page! </h1>" > /var/www/html/newtest.html

7.3 exit container:

exit

7.4 curl localhost/newtest.html


ASSIGNMENT 2:-

1. Attach a docker volume to multiple containers and add or modify the files in any of these containers and check that the changes are getting reflected in all the containers or not.

2. Point #1 is to be repeated for Bind Mount

3. Delete the Bind mount directory which is mapped to a container's destination directory and check the destination behavior means try to create some file or list the files on the destination folder.

4. Continue to Point 3, you may get some error that the source directory does not exist. Create source directory again and check the destination folder and find out whether you are able to create new files in this folder or not.


ANSWERS:
1. yes

2. yes

3. for bind mount: 
touch: cannot touch '/app1/devops3fromc3.txt': No such file or directory
3.2 for volume (means prune the docker volume):

4. for bind mount: 
touch: cannot touch '/app1/devops3fromc3.txt': No such file or directory (but if you create a container after that, it can sync the files) this means that by using bind, once your source is changed, your target will never find the source again even if its the same name.
4.2 for volume (means create a docker volume with same name after pruning it):

5. Restart the container which you are using for #3 and #4 and again check the destination folder to store some data and find out whether you are able to see it in the source folder or not.

Wednesday, February 23, 2022

ASSIGNMENT: Docker Container *IMPORTANT

 

Assignment


1. Create a container called webserver with ubuntu docker image.
2. Install apache server in the container(webserver)
3. Start apache service in the container
4. Access apache default page on the web browser
5. Create a new webpage myapp.html on the host machine and copy it to /var/www/html folder in webserver container.
6. Access myapp.html page on the browser
7. Check how much memory and cpu is consumed by web server containers.
8. Stop the container and verify that you are not able to access apache website on browser.
9. Start container and now you should be able to access the apache website.
10. Remove  webserver container

Tuesday, February 22, 2022

ASSIGNMENT: Ansible Playbook


 

Create a setup of 3 ubuntu Servers where one of the servers is the Master server where the Ansible is installed whereas the other 2 webservers are managed nodes.

1. Create a playbook to install apache on the webservers

2. Create a playbook to start an apache service on webservers

3. Create a playbook to create a file /tmp/status with dynamic contents on dbservers.(vars_prompt)

4. Create a playbook to copy /tmp/status.txt file to web servers /tmp/status.txt

5. Create a playbook to Stop the apache service and delete /tmp/status.txt and also uninstall the apache service ( create a separate play for uninstalling the apache service).

6. Create a playbook where you define a variable called testvar and the value of the variable should be entered at run time if the value of a variable is Testing then create a file /tmp/testfile.txt and write the content that "Testing is in progress" on webservers.

7. A series of tasks in one playbook:
7.1 Create a playbook to install apache (apache2 for Ubuntu and httpd for CentOs) on webservers ( consider webservers are either CentOs or Ubuntu System).

7.2. Start httpd service on webservers which are CentOs.

7.3. Remove apache from Webserver if the OS family is Debian and OS is Ubuntu.

7.4. Create a user John on Debian based OS webservers. (use user module) and verify that user created.(cat /etc/passwd | grep John| wc -l)


ANSWER:

1. install apache
2. start apache

---
- name: Play for webservers (node2, node3)
  hosts: webservers
  tasks:
        - name: installing apache2 on webservers
          apt: 

                name:apache2 

                state:present


        - name: starting apache2 service on webservers
          service:
                name: apache2
                state: started


3. create file and dynamic value
---
- name: Play for dbservers (node1)
hosts: dbservers
vars_prompt:
        name: data
        prompt: Enter a value
tasks:
        - name: create a .txt file in /tmp
          command: touch /tmp/status.txt

        - name: please add a dynamic text in the .txt file
          copy:
                content: "{{ data }}"
                dest: /tmp/status.txt


4. copy file
---
- name: Play for pushing dbservers file to webservers
hosts: webservers
tasks:
        - name: copying .txt file from dbservers to webservers
          copy:
                src: /tmp/status.txt
                dest: /tmp/status.txt


5.1. stop apache and delete .txt file
---
- name: Play for webservers (node2, node3)
hosts: webservers
tasks:
        - name: stopping apache2 service from webservice
          service:
                name: apache2
                state: stopped
        - name: deleting /tmp/status.txt from webservice
          shell: rm /tmp/status.txt


5.2. uninstall apache
---
- name: Play for webservers(node2, node3)
hosts: webservers
tasks:
        - name: uninstall apache2 service from webservers
          apt: 

                name:apache2 

                state:absent 

                purge:yes


6. prompt in runtime

---
- name: play for assignment playbook 6
  hosts: webservers
  vars_prompt:
            name: testvar
            prompt: enter a value
  tasks:
            - name: creating testfile.txt in /tmp if testvar is Testing
              command: touch /tmp/testfile.txt
              when: testvar == "Testing"

            - name: write content in the .txt file
              shell: echo 'Testing is in progress' >> /tmp/testfile.txt
              when: testvar == 'Testing'



7. A series of tasks in a playbook

---
- name: play for assignment playbook 7
  hosts: webservers
  tasks:

        - name: install apache2 (if Debian family OS)
          apt:
                name: apache2
                state: present
          when: ansible_facts['os_family'] == "Debian"

        - name: install httpd (if Redhat family OS)
          yum:
                name: httpd
                state: present
          when: ansible_facts['os_family'] == "RedHat"

        - name: start httpd service
          service:
                name: httpd
                state: started
          when: ansible_facts['os_family'] == "RedHat" and ansible_distribution=="CentOS"

        - name: remove apache if Debian - Ubuntu
          apt:
                name: apache2
                state: absent
                purge: yes
          when: ansible_facts['os_family'] == "Debian" and ansible_distribution=="Ubuntu"

        - name: create a user (John) on Debian based webserver
          user:
                name: John
          when: ansible_facts['os_family'] == "Debian"

        - name: verify added user
          shell: cat /etc/passwd | grep John| wc -l
          register: output

        - name: printing verification of added user
          debug:
                msg: "A user is added"
          when: output.stdout == "1"

        - name: printing verification if user is not added
          debug:
                msg: "No user is added"
          when: output.stdout == "0"

Monday, February 21, 2022

ASSIGNMENT: Ansible Ad-Hoc Commands by Raman 21.2.2022



Assignment:
Create a setup of 3 ubuntu Servers where one of the servers is the Master server where Ansible is installed whereas the other 2 webservers are managed nodes.

Perform the below tasks by using Ansible Adhoc commands:

1. Install Apache server on webservers using shell module
2. Stop Apache service on webservers using service module
3. Restart Apache service on webservers using service module.
4. Uninstall Apache service using apt module
5. Run date command on webservers.
6. Create a file call app.java under /tmp/java folder
7. Add some content to app.java file.
8. Read app.java file using shell module.
9. Delete app.java file.
10. Install tree command using apt module.

Answer:
  1. ansible webservers -m shell -a "apt install apache2 -y"
  2. ansible webservers -m service -a "name=apache2 state=stopped"
  3. ansible webservers -m service -a "name=apache2 state=restarted"
  4. ansible webservers -m apt -a "name=apache2 state=absent purge=yes"
  5. ansible webservers -m shell -a "date"
  6. Answer for 6:
    1. ansible webservers -m shell -a "mkdir /tmp/java/"
    2. ansible webservers -m shell -a "touch /tmp/java/app.java"
  7. ansible webservers -m copy -a "content='Hello World' dest=/tmp/java/app.java"
  8. ansible webservers -m shell -a "cat /tmp/java/app.java"
  9. ansible webservers -m shell -a "rm -ifr /tmp/java/app.java"
  10. ansible webservers -m apt -a "name=tree state=present"

Sunday, February 20, 2022

ASSIGNMENT: Ansible Ad-hoc Commands (ping module, shell module, apt/yum module)



Reference: 


Challenge Part 1:
  1. To check web servers are reachable or not using Adhoc commands.
  2. To check all hosted servers are reachable or not using Adhoc commands.
  3. To check webserver1 is reachable or not using Adhoc command.
  4. To check all hosted servers are reachable or not using Adhoc commands when the hosts file is in a different location (/home/vagrant/mydir/hosts)

Solution Part 1:
The module used: ping
Run the below ansible adhoc command with ping module:
  1. ansible webservers -m ping
  2. ansible all -m ping
  3. ansible 192.168.33.11 -m ping
  4. ansible -i /home/vagrant/mydir/hosts all -m ping

Challenge Part 2:
  1. Install apache on webservers
  2. Uninstall apache on webservers
  3. Create a file in /tmp/1.txt on dbservers and webservers
  4. Change the permission of /tmp/1.txt file by give rw permission to owner, r permission to group, and other users.
  5. Copy /tmp/1.txt file to /tmp/2.txt file

Solution Part 2:
The module used: shell
Run the below ansible adhoc command with shell module:
  1. ansible webservers -m shell -a " apt install apache2 -y"
  2. ansible webservers -m shell -a " apt purge apache2 -y"
  3. ansible webservers,dbservers -m shell -a "touch /tmp/1.txt"
  4. ansible webservers,dbservers -m shell -a "chmod 644 /tmp/1.txt"
  5. ansible webservers,dbservers -m shell -a "cp /tmp/1.txt /tmp/2.txt"

Challenge Part 3:
  1. To install apache2 on webservers using apt module.
  2. To uninstall apache2 on webservers using apt module.

Solution Part 3:
The module used: apt/yum (apt=debian, yum=redhat)
Run the below ansible adhoc command with apt/yum module:
  1. ansible webservers -m apt -a "name=apache2 state=present"
  2. ansible webservers -m apt -a "name=apache2 state=absent purge=yes"


Challenge Part 4:
  1. Start apache server on webservers
  2. Stop apache server on webservers
  3. Restart apache server on webservers
  4. Reload apache server on webservers

Solution Part 4:
The module used: service
Run the below ansible adhoc command with service module (apache2 is required to be installed first):
  1. ansible webservers -m service -a "name=apache2 state=started"
  2. ansible webservers -m service -a "name=apache2 state=stopped"
  3. ansible webservers -m service -a "name=apache2 state=restarted"
  4. ansible webservers -m service -a "name=apache2 state=reloaded"


Challenge Part 5:
  1. create a file /tmp/status.txt in master system and copy it to agent system using copy module with the destination having the same name.
  2. create a file /tmp/status.txt in master system and copy it to agent system using copy module with the destination having a different name (newstatus.txt).
  3. create a file with text: "Hello World" in agent system by using copy module from master system.

Solution Part 5:
The module used: copy
Run the below ansible adhoc command with copy module (apache2 is required to be installed first):
  1. ansible webservers -m copy -a "src=/tmp/status.txt dest=/tmp/status.txt"
  2. ansible webservers -m copy -a "src=/tmp/status.txt dest=/tmp/newstatus.txt"
  3. ansible webservers -m copy -a "content='Hello World' dest=/tmp/helloworldcontent.txt"


Thursday, February 17, 2022

ASSIGNMENT: creating a JIRA project (Epic - Story - ChildIssue - Sprint - Bug - Sprint)

 

Assignment by Raman, 18 Feb 2022, Friday

  1. Create a JIRA Project with Scrum template and Name it College Hostel
  2. Create an epic for Managing the Hostel and name it as Hostel Room Management
  3. Create 2 user stories in the above epic ( Top 1 to 10 floors, Arrange Beds for each room) and assign to a user.
  4. Create 2 subtasks in "Top 1 to 10 floors" user story
    1. Arrange each room equipment
    2. Test all the utilities
  5. Create 2 subtasks in "Arrange Beds for each room"
    1. Arrange single Bed
    2. Arrange Mattress
  6. Create a sprint for both tasks and change the status form To Do to progress and once the work is completed then it should be "Done"
  7. Check the Backlogs and Boards for each activity.

Wednesday, February 16, 2022

ASSIGNMENT: SonarQube with GitLab (Long, Revise This!!)


ASSIGNMENT: Git Release Preparation Steps with SonarQube (CLI method)

1. Create a branch release (dev branch --> build branch-->release branch) from the build branch of your code.

2. Install and Configure SonarQube.

3. Add/Modify the changes in the dev branch and update the build and release branch.

4. Analyze the code which is in the release branch with SonarQube (here we need to use Maven Integration with sonarqube).

5. Once Analysis is done then merge the release branch to the master branch.

6. For CICD pipeline point of view use Gitlab/Jenkins/Bamboo integration with SonarQube.

7. Once the Analysis is done then it Git Release closure.


ANSWER TO ASSIGNMENT:

// Create the below steps on a local system, result will be local repo.

1. Create a branch release (dev branch --> build branch-->release branch) from the build branch of your code.

a. go to any folder and cmd.

b. type in mvn archetype:generate to create a maven project. go through the procedures (1865, groupID, artifactID, etc, etc..)
        mvn archetype:generate
    -> a folder (named with artifactID) will be created.

c. git init (this will initialize git in the folder, it will create some required files)
      -> to check, git status
 
d. prepare to add the files into git local repo
        git add .
        git commit -m "maven proj added for sonar in gitlab"

e. create a dev branch (as by default, you are now in the main/master branch) and checkout into that branch.
        git branch dev
        git checkout dev

f. IN THE DEV BRANCH, create a build branch and checkout into that branch.
        git branch build
        git checkout build

g. IN THE BUILD BRANCH, create a release branch.
        git branch release

2. Install and Configure SonarQube.
a. install SonarQube.
        www.sonarqube.com

b. configure in pom.xml by runing maven package and sonar:sonar. Then check in sonarqube web portal.
        mvn package
        mvn clean package sonar:sonar

c. check what is modified.
        git status

d. you dont want the target/ folder so you need to create a .gitignore file and put in ".gitignore" and "target/".
        echo ".gitignore" >> .gitignore
        echo "target/" >> .gitignore
(this will result in an error cause in the .gitignore file, there are still double quotes. so open it using notepad and delete the double quotes).

e. add and commit all changes.
        git add .
        git commit -m "sonar is installed with maven"


3. Add/Modify the changes in the dev branch and update the build and release branch.
a. Make the changes in dev branch code and merge the changes to build branch and merge build branch to release branch (only edit pom.xml in release branch later).
???

b. add sonar dependencies in release branch code by opening Eclipse IDE and search for the pom.xml file and add in properties, dependencies, profile. Don't forget to put in a new token from SonarQube web portal also.

        <properties>
     <maven.compiler.source>1.8</maven.compiler.source>
     <maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.sonarsource.scanner.maven/sonar-maven-plugin -->
<dependency>
    <groupId>org.sonarsource.scanner.maven</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>3.9.1.2184</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.12.1</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.12.1</version>
</dependency>
</dependencies>
<profiles>
<profile>
            <id>sonarassignment</id> 
            <activation>
            <activeByDefault>true</activeByDefault>
            </activation>   
            <properties>
               <sonar.host.url>http://localhost:9000</sonar.host.url>
               <sonar.login>64b7e75d5cc938c72b007e340ddb9e654fcd64c8</sonar.login>
            </properties>   
        </profile>

4. Analyze the code which is in the release branch with SonarQube (here we need to use Maven Integration with sonarqube).
a. go to SonarQube web portal (localhost:9000) and check if the release branch code is in the sonarqube project list.
        localhost:9000

5. Once Analysis is done then merge the release branch to the master branch.
a. merge release code into master branch
        git checkout master
        git merge release

b. now master branch will have the same pom.xml config as per release (where the config has the sonarqube dependencies). Thus you will have to ensure that dependency, profiles is not present in the pom.xml in master.
        type pom.xml (to check)
        edit in notepad or something..lol



// Now this is for pushing from local repo into remote repo

6. For CICD pipeline point of view use Gitlab/Jenkins/Bamboo integration with SonarQube.

a. create remote repo in GitLab

b. give remote access

        git remote add origin https://gitlab.com/ifanrahman/sonargitlab.git

    //if for example, you used SSH, and want to change to HTTPS, in the .git folder, click on config file and change from there. (p/s: .git folder is hidden btw)

        git push origin main

c. check in GitLab if the files have been added.

d. go to sonarcloud

        https://sonarcloud.io/login

e. create a new organization
        enter key
        choose free plan
        create

f. create a new project MANUALLY
        add in project key

g. click on Analyze on GitLab CICD. There will be several steps:

steps 6.1: - 

Add environment variables

a. Define the SonarCloud Token environment variable

In GitLab, go to Settings > CI/CD > Variables to add the following variable and make sure it is available for your project:
  1. In the Key field, enter SONAR_TOKEN 
  2. In the Value field, enter 853728a0ead4599ab5509eb6df0f325954556e8e 
  3. Make sure that the Protect variable checkbox is unticked
  4. Make sure that the Mask variable checkbox is ticked

b. Define the SonarCloud URL environment variable

Still in Settings > CI/CD > Variables add a new variable and make sure it is available for your project:
  1. In the Key field, enter SONAR_HOST_URL 
  2. In the Value field, enter https://sonarcloud.io 
  3. Make sure that the Protect variable checkbox is unticked
  4. No need to tick the Mask variable checkbox this time

Step 6.2:-

Create or update a .gitlab-ci.yml file

What option best describes your build?

so what you have to do is create a new .gitlab-ci.yml file in GitLab.


Step 6.3:- click on maven and this will appear:

Update your pom.xml file with the following properties:
<properties>
  <sonar.organization>irfansonarorg</sonar.organization>
</properties>
Create or update your .gitlab-ci.yml  yaml file with the following content:
variables:
  SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"  # Defines the location of the analysis task cache
  GIT_DEPTH: "0"  # Tells git to fetch all the branches of the project, required by the analysis task
sonarcloud-check:
  image: maven:3.6.3-jdk-11
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script:
    - mvn verify sonar:sonar -Dsonar.projectKey=newkeysonarcloud
  only:
    - merge_requests
    - master
    - develop

Note that this is a minimal base configuration to just run a SonarCloud analysis on your master branch and merge requests.

If you already have a pipeline configured and running you might want to just add this new step to your existing yaml file. 

so basically 2 things:

1. edit pom.xml

2. edit .gitlab-ci.yml (p/s in the script, update to mvn clean package sonar:sonar -Dsonar.projectKey=newkeysonarcloud)


7. Once the Analysis is done then it Git Release closure.

Fluentd

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