Posts

Jenkins

In How many ways can we launch an agent in Jenkins? Launch agent by connecting it to master. Agent Connects to master Launch agent via SSH Controller initiates the connection to the SSH. How do we login into AWS? How do we pass and login AWS in Jenkins pipelines or Jenkins file? We can use assume role and get credentials. We can use AWS plug-in to configure cloud. In the cloud, we can provide our AWS access key or secret key. We can add our EC2 End point, region, et cetera Now in Jenkins credential provider, we can give our username and provide key credentials. This will give us a credential ID. We can use this credential ID in Jenkins pipelines. Can we write git clone in pipeline? No, we can use checkout instead. What is the difference between scripted and declarative pipeline? Declarative pipelines uses declarative model and scripted uses imperative model.Declarative breaks the stages into multiple steps.Scripted Does not require this. Scripted pipelines permit developer to inject a ...

GIT

  What is the difference between git pull and git fetch? Git fetch command tell our local gate to Vihar, the latest meta data information from original repository.(There is no file transferring. It is just like checking to see if there are any changes available.) Git pull is used To download latest changes from central repository To local repository.(File transfer happens here). I have same history and want to commit in four branches. What should I use? Git worktree helps to create parallel repository so that we can work on them in parallel.

CICD

  How the process of pushing application to container happens in CICD pipeline? Push is to github. Github is hooked to Jenkins, which listens to an SSH. Whenever code is pushed, it triggers a build, and this artefact goes to Kubernetes cluster. The cluster then take it as an image and runs it on the container in some port.

Some Devops Tools

Git GitHub Maven Nexus Sonarcube Docker Kubernetes Ansible Confluence. Eraser app TL Draw Exlclidraw Draw.io

Setup Devops in AWS

To set up and environment in CICD in In AWS, we require Following components Application load balancer(ALB) We create Different of ALB’s for frontend and backend Services. For all the services(ECS) and ALB, we have only one security group. Developers push their code on Code repository Like GitHub. Each micro service has a docker file In its root directory, which is used to create a customised image Of that micro service Which is deployable and executable in All docker supported Environments. We create a package, build an image using AWS code build Which reads instruction form a file In root directory Called as buildspec.yml. We deploy image in ECS clusters using Pipeline. We can define the CFT file of our ECS clusters, target service and cloud watch log groups. We have details about the container, the taskdefinition, file, and details about services. Under the ECS cluster, we have services under the services we have tasks. The task is the image, deployed and container running the same....

Using SSH keyfile for launching agents via ssh

Image
We use known hosts file strategy as Host key verification strategy here. Create the following Directory mkdir -p /var/lib/jenkins/.ssh Copy entries for your ssh host in the known_hosts directory ssh-keyscan -H hostname >> /var/lib/jenkins/.ssh/known_hosts Change the ownership of .ssh folder to jenkins user chown -R jenkins /var/lib/jenkins/.ssh

Setup Flyway,Postgres in Jenkins using Docker

Recently I was trying to setup Flyway on Jenkins for my db in Postgres. The required files can be found here https://github.com/gauravmatta/devops/tree/main/jenkins_flyway The basic files you will need will be  The configuration file in conf folder The sql files in the sql folder The pipeline file "jenkinsfile-2" Here is the sample configuration file flyway.url= jdbc:postgresql://localhost:5432/flyway flyway.user = postgres flyway.password = postgres flyway.schemas= flyway flyway.locations=filesystem:../sql flyway.driver=org.postgresql.Driver Create DB Credentials in Jenkins with ID  "db-creds" We are using this in our sample you may change it but be sure to change it in jenkins pipeline file too. Here is the sample jenkins pipeline file https://github.com/gauravmatta/devops/blob/main/jenkins_flyway/jenkinsfile-2 My postgres is installed on localhost so I am using "--network=host" in my docker command for example docker run --rm --networ...