In my previous article, I delved into the fascinating world of microservices -Ā Microservice Architecture Patterns Part 1: Decomposition Patterns. This was the beginning of my comprehensive article series on microservices and their patterns.
While the logical step would be to continue with Part 2 of this series, I have decided that the next thing that I would like to explore and tell you about is the vital process of delivering these microservices to the end user seamlessly.
Content Overview
- Motivation
- [Module 1]: AWS EC2 Virtual Server
- [Module 2]: Jenkins Server
- [Module 3]: Git and Github
- [Module 4]: Apache Maven
- [Module 5]: Docker
- [Module 6]: Ansible
- [Module 7]: Kubernetes
- Conclusion
- About the Author
Motivation
CI/CD is a technique for delivering apps to customers, achieved by adding automation to different stages of app development. I believe that grasping CI/CD (Continuous Integration and Continuous Deployment) can empower developers to gain a better understanding of how backend project artifacts exist beyond the boundaries of the project repository. This comprehension can also create a fundamental shift in a developer's perspective. Instead of merely viewing their work as lines of code, they can start to embrace the broader context of their project as a valuable product.
In this article, we aim to demystify the CI/CD process through practical application. We'll take you through a step-by-step tutorial, breaking it down module by module, where you'll build a CI/CD pipeline manually. To do this, we'll harness the power of contemporary DevOps tools like AWS, Docker, Kubernetes, Ansible, Git, Apache Maven, and Jenkins. So, let's begin this journey!
[Module 1]: AWS EC2 Virtual Server
This module is dedicated to the creation of an AWS EC2 Virtual Server instance. As part of this article, you will be setting up three EC2 instances for Jenkins, Ansible, and Kubernetes. For now, you can proceed with the next modules and revisit this module in "[module 2]: Jenkins", ā[module 6]: Ansible" and "[module 7]: Kubernetes" sections.
Step 1: Create an AWS Account
Go toĀ https://aws.amazon.com.
Click the buttonĀ Create an AWS Account.
Follow the instructions on the create account web page.
Step 2: Sign In to your AWS Account
Go toĀ https://console.aws.amazon.com/console/home. Click the Sign In button.
Enter all necessary credentials on this web page.
Step 3: Find EC2 Virtual Server
Find EC2 in the search box.
Choose EC2 Virtual Server by clickingĀ EC2 Service.
Click the buttonĀ Launch Instance.
Step 4: Configure āName and tagsā section
Go to theĀ āName and tagsāĀ section.
Provide a name for a new AWS EC2 Virtual Server instance in theĀ āNameāĀ section.
You can also add additional tags for your virtual server by clickingĀ āAdd additional tagsā.
Step 5: Configure āApplication and OS Images (Amazon Machine Image)ā section
Go to theĀ "Application and OS Images (Amazon Machine Image)"Ā section.
To play with the virtual server forĀ FREE:
- Select the operating system for your virtual server -Ā Amazon Linux.
- In theĀ Amazon Machine Image (AMI)Ā section, select a machine with theĀ Free tier eligible tag.
Step 6: Configure āInstance typeā section
Go to theĀ āInstance typeāĀ section.
To play with the virtual server forĀ FREE:
Select a type with theĀ Free tier eligible tagĀ in theĀ Instance typeĀ section.
For me it isĀ t2.micro (Family: t2 1cCPU 1 GiB Memory Current generation:true).
Step 7: Configure āConfigure storageā section
Go to theĀ āConfigure storageāĀ section.
To play with the virtual server forĀ FREE:
Do not change default settings. Free tier eligible customers can getĀ 30 GB of EBS General Purpose (SSD) or Magnetic storage.
Step 8: Configure āNetwork settingsā section
Go to theĀ āNetwork settingsāĀ section.
You need to set up the security of your virtual server. To do this,
- Click on theĀ āCreate security groupāĀ button.
- Add the name of your new security group in theĀ āSecurity group nameāĀ section.
- Add a description of your new security group in theĀ āDescriptionāĀ section.
By default, your virtual server is accessible via (Type - SSH, Protocol - TCP, Port - 22). If you need additional connection types, add them by adding additional inbound security group rules.
Step 9: Configure āKey pair (login)ā section
Go to theĀ āKey pair (Login)āĀ section.
Create a new key-pair if you haven't created it yet.
If you haven't createdĀ ākey-pairāĀ yet:
- Click theĀ āCreate new key pairāĀ button.
- Give your new key-pair a name in theĀ āKey pair nameāĀ section.
- Select key-pair typeĀ RSAĀ orĀ ED25519. I choose theĀ RSAĀ type.
- Select Private key file format. Choice ofĀ .pemĀ andĀ .ppk. I choose theĀ .pemĀ format.
- Click on theĀ āCreate key pairāĀ button.
- You will get a pop-up window that will prompt you to download the Private key file. Agree and download the file to your computer.
Step 10: Launch the EC2 Virtual Server Instance
Launch the EC2 Virtual Server instance by clicking the buttonĀ āLaunch instanceā.
After the completion of the EC2 Virtual Server instance creation process, you will see the following.
Then you should go to theĀ āInstancesāĀ section by clickingĀ āView all instancesāĀ button.
Now you can see that your AWS EC2 Virtual Server instance is running.
[Module 2]: Jenkins Server
Now, letās configure JenkinsServer on the EC2 Virtual Server instance.
Step 1: Create an AWS EC2 Virtual Server instance
You need a virtual server to run Jenkins.
Follow instructions fromĀ [Module 1]: AWS EC2 Virtual ServerĀ section of this tutorial to finish this step and create an EC2 virtual server instance with the name JenkinsServer.
Do not forget to add a security group setup. It allowsĀ JenkinsĀ andĀ SSHĀ to work on portĀ 8080Ā andĀ 22Ā respectively.
Use the nameĀ āJenkinsServerāĀ to distinguish your EC2 Virtual Server instance.
CreateĀ āCI_CD_PipelineāĀ security group andĀ āCI_CD_Pipeline_Key_PairāĀ for a newĀ āJenkinsServerāĀ AWS EC2 instance. You can reuse them further in the article.
Step 2: Connect to an AWS EC2 Virtual Server instance
Go toĀ AWS Console home pageĀ āĀ EC2 Management Console DashboardĀ āĀ Instances.
Then you should chooseĀ JenkinsServerĀ and then click theĀ āConnectāĀ button.
Then you will see this web page. You should again click theĀ āConnectāĀ button.
Now you can see EC2 virtual server instance online terminal.
Step 3: Download the Jenkins repository
Now you need to download Jenkins on your EC2 virtual server instance.
Follow these instructions:
-
Go to Jenkins downloadĀ webpage.
-
You can see Stable (LTS) and Regular releases (Weekly)Ā options. ChooseĀ Red Hat/Fedora/Alma/Rocky/CentOSLTS option.
You will see this web page.
- CopyĀ āsudo get..āĀ command and execute it to download Jenkins files from the Jenkins repository on the Internet and save them to the specified location on your EC2 virtual server instance.
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
Now Jenkins is downloaded.
Step 4: Import Jenkins key
To finish the Jenkins installation, we need to import the Jenkins key.
To import the Jenkins key we need to copyĀ the āsudo rpm..āĀ command and execute it.
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
This wayĀ ārpmāĀ package manager can verify that the Jenkins packages you install are exactly the ones published by the Jenkins project, and that they haven't been tampered with or corrupted.
Step 5: Install Java
To run Jenkins, we need to installĀ JavaĀ on our EC2 virtual server instance.
To installĀ Java, use this command.
sudo amazon-linux-extras install java-openjdk11 -y
Verify whether Java was installed correctly using this command:
java -version
You will see something like that.
Step 6: Install fontconfig
To run Jenkins, you need to installĀ fontconfigĀ on our EC2 virtual server instance.
Use this command.
sudo yum install fontconfig java-11-openjdk -y
Fontconfig is a library designed to provide system-wide font configuration, customization and application access. It's required by Jenkins because Jenkins has features that render fonts.
Step 7: Install Jenkins
In earlier steps, you configured your EC2 virtual server instance to use a specific Jenkins repository and then you imported the GPG key associated with this repository. Now, you need to run the command that will search all the repositories it knows about, including the Jenkins one you added, to find the Jenkins package. Once it finds the Jenkins package in the Jenkins repository, it will download and install it.
Letās run this command.
sudo yum install jenkins -y
Step 8: Start Jenkins
You can start Jenkins using this command.
sudo systemctl start jenkins
To check that Jenkins is running use this command.
sudo systemctl status jenkins
You will see the output as it is on the screenshot below:
Jenkins should now be up and running.
Step 9: Access Jenkins
To access the Jenkins application, open any web browser and enter your EC2 instanceās public IP address or domain name followed by port 8080.
http://<your-ec2-ip>:8080
The first time you access Jenkins, it will be locked with an autogenerated password.
You need to display this password using the following command.
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Copy this password, return to your browser, paste it into the Administrator password field, and click "Continue".
Then you will be able to see this web page.
Now, you can use your Jenkins Server.
Step 10: Create new Jenkins pipeline
Now, as Jenkins is working fine, you can start creating the Jenkins pipeline. To create Jenkins pipeline you need to create a new āFreestyle projectā. To create a new āFreestyle projectā you need to go to the Jenkins dashboard and click theĀ āNew ItemāĀ button.
Enter the name of the Github āFreestyle projectā (āpipelineā name is going to be used further) and then click the buttonĀ āOKā.
Then provide theĀ DescriptionĀ of the pipeline.
Then click the button āApplyā and āSaveā. After that, it means you created the fundament of the pipeline which is going to be built in this tutorial.
[Module 3]: Git and Github
Now as Jenkins is running on AWS EC2 Virtual Server instance, you can configure Git with the pipeline.
Git is aĀ free and open sourceĀ distributed version control system (VCS) designed to help software teams keep track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members. VCS is especially useful forĀ
Git as the most popular version control systemĀ enables us to pull the latest code from your project Github repository to your EC2 virtual server instance where your Jenkins is installed.
Step 1: Install Git
Use this command to install Git.
sudo yum install git -y
Now verify Git is working, using this command.
git --version
Now Git is working fine on EC2 Virtual Server instance.
Step 2: Open Jenkins dashboard
As Git is working fine on EC2 Virtual Server instance, we can integrate Jenkins with Git now.
To start this integration letās install Jenkins Github plugin.
Go to Jenkins dashboard section.
Step 3: Open Jenkins Plugin Manager
Click the buttonĀ āManage JenkinsāĀ and then click the buttonĀ āManage Pluginsā.
Step 4: Find Github Jenkins plugin
Click the buttonĀ āAvailable pluginsā.
Find theĀ GithubĀ plugin Search box.
SelectĀ GithubĀ plugin.
Step 5: Install Github Jenkins plugin
SelectĀ GithubĀ plugin. And then click the buttonĀ āInstall without restartā.
Wait for the end of the Github plugin downloading.
Yes! The Jenkins Github plugin is installed.
Step 6: Configure Github Jenkins Plugin
Now as the GitHub Jenkins plugin is installed, you can configure this plugin to integrate Jenkins with Git finally. To do that you need to return to the main page by clicking the button āGo back to the top pageā.
Then on the main page, you need to click the buttonĀ āManage JenkinsāĀ and then click the buttonĀ āGlobal tool configurationā.
Then on the Global Tool Configuration web page you should go to the Git section.
In the Git section, you need to configure Git by providing the name and path to Git on the computer.
Then clickĀ the āApplyāĀ andĀ āSaveāĀ buttons**.**
Here, you have finished configuring the Jenkins Github plugin.
Step 7: Integrate Git into the pipeline
Now, as the Jenkins Github plugin is installed and configured, you're now able to utilize this plugin within your pipeline. This will allow your pipeline which you created in module 2 to pull your project code from the specified GitHub repository.
Well, to integrate this plugin into your pipeline you need to go to the Source Code Management section and choose Git in your pipeline. Then you need to provide your project repository URL. If your project repository is public on Github, you do not need to provide credentials. If the project repository is private on Github, you need to provide credentials.
You can use my project with the next Repositiry URL:Ā https://github.com/Sunagatov/Hello.git.
Just copy and paste it to the āRepository URLāĀ input. Then clickĀ the āApplyāĀ andĀ āSaveāĀ buttons to finish the integration Git with the pipeline.
Step 8: Test Git integrated into the pipeline
Now you can use your updated pipeline to pull a project from Github. To do that you need to click theĀ **āBuild Nowā**button. As a result, you will see a successful build in the build history.
Open the first build from the build history.
Now you can see the successful job result of the first build. If you open your AWS EC2 terminal. You can check that the pipeline works well.
Just use this command.
cd /var/lib/jenkins/workspace/{your pipeline name}
This way you can see that your project from Github was pulled to your AWS EC2 virtual server instance.
[Module 4]: Apache Maven
Apache MavenĀ is a widely used build automation and project management tool in software development. It streamlines the process of compiling, testing, and packaging code by managing project dependencies and providing a consistent build lifecycle. Maven employs XML-based configuration files (POM files) to define project structure, dependencies, and tasks, enabling developers to efficiently manage and deploy complex software projects.
Now that you have integrated Git into the pipeline, you can enhance the pipeline further by incorporating Apache Maven which enables you to build, test, and package your project. To do that you need to install Apache Maven on your AWS EC2 Virtual Server instance where Jenkins and Git were installed.
Step 1: Download Apache Maven
To download Apache Maven go toĀ the ā/optāĀ directory.
cd /opt
And then use this command.
sudo wget https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz
This command will download the latest official Apache Maven (check the latest version on the official Apache Maven website). To find the latest official Apache Maven release, use the linkĀ https://maven.apache.org/download.cgi.
Step 2: Extract Apache Maven from the archive
Use this command, to extract Apache Maven from the downloaded archive:
sudo tar -xvzf apache-maven-*.tar.gz
Step 3: Add JAVA_HOME and M2_HOME
Move to the root folder using this command.
cd ~
EditĀ .bash_profileĀ file using this command.
vi .bash_profile
AddĀ JAVA_HOMEĀ and M2_HOME variables.
Assign the path to JDK11 forĀ JAVA_HOMEĀ and path to the maven directory forĀ M2_HOMEĀ variable.
To find JDK path, use this command.
sudo find / -name java
How to use VIM
- ToĀ editĀ the file press the keyboard buttonĀ ā I āĀ to insert data.
- ToĀ saveĀ the file press the keyboard button ā esc ā and enter ā:wā.
- ToĀ exitĀ from the file press the keyboard buttonĀ ā esc āĀ and enterĀ ā:qā.
Save the changes.
Then, execute this command to refresh system variables.
source .bash_profile
To verifyĀ $PATH, use this command.
echo $PATH
To verifyĀ Apache Maven, use this command.
mvn -v
If you have done everything correctly, you will be able to view the version of Apache Maven.
Step 4: Install Apache Maven Jenkins plugin
Since Apache Maven can be used on an EC2 instance, you can install the Apache Maven plugin to integrate it with the pipeline.
To achieve this, follow these steps:
- Navigate toĀ āDashboardāĀ ā āManage Jenkinsā ā āManage Pluginsā ā āAvailableā.
- In the search box, enterĀ āMavenā.
- ChooseĀ āMaven IntegrationāĀ plugin.
Wait for the end of the downloading process.
And then click the buttonĀ āGo back to the top pageā.
Step 5: Configure Apache Maven Jenkins plugin
With the successful installation of the Apache Maven Jenkins plugin, you are now able to utilize this plugin within the pipeline which you created and updated in modules 2 and 3.
To do so, follow these steps:
- Go toĀ āDashboardāĀ ā āManage Jenkinsā ā āGlobal Tool Coonfigurationā ā āJDKā
- Click the buttonĀ āAdd JDKā.
- UncheckĀ āInstall automaticallyā.
Then go toĀ āMavenāĀ section. Click the buttonĀ āAdd Mavenā. UncheckĀ āInstall automaticallyā.
Then addĀ nameĀ andĀ MAVEN_HOMEĀ path.
ClickĀ the āApplyāĀ andĀ āSaveāĀ buttons.
Here, you have finished configuring the Apache Maven Jenkins plugin.
Step 6: Integrate Apache Maven into the pipeline
Now as the Apache Maven GitHub plugin is installed and configured, you're now able to utilize Apache Maven within your pipeline. This will allow your pipeline which you created in the ā[module 2]: Jenkins Serverā to build your project code to create a jar artifact.
To integrate Apache Maven into the pipeline you need to follow these steps:
- Navigate toĀ āDashboardāĀ ā āCI_CD_Pipelineā ā āConfigureā ā āBuild Stepsā.
- ClickĀ āAdd build stepāĀ button.
- ChooseĀ āInvoke top-level Maven targetsāĀ option.
- ChooseĀ āApache-MavenāĀ asĀ āMaven Versionā.
- AddĀ āclean packageāĀ command toĀ āGoalsāĀ input.
- ClickĀ āAdvancedāĀ button.
- Add āpom.xmlā toĀ āPOMāĀ input.
Finally, you should clickĀ āApplyāĀ andĀ āSaveāĀ buttons to finish the integration of Apache Maven with the pipeline.
Step 7: Test Apache Maven integrated into the pipeline
Now you can use your updated pipeline to build your Github project. To do that you need to click theĀ **āBuild Nowā**button. As a result, you will see a successful job result in the build history.
If you open your AWS EC2 terminal. You can check that the pipeline works well.
Just use this command.
cd /var/lib/jenkins/workspace/{your pipeline name}/target
This way you can see the JAR artifact, indicating the successful build of your project from GitHub.
[Module 5]: Docker
Now letās create a new EC2 instance with the name "Ansible Server" where you are going to install Docker and Ansible.
Step 1: Launch an AWS EC2 Virtual Server instance
Use instructions from āLaunch an AWS EC2 Virtual Server instanceāĀ section of this tutorial to finish this step. Do not forget to add a security group setup. It allows Docker and SSH to work on ports 8080 and 22 respectively.
Step 2: Connect to an AWS EC2 Virtual Server instance
Click the āConnectā button.
Now you can see the EC2 Virtual Server instance online terminal.
sudo chown ansible-admin:ansible-admin /opt/docker
Step 3: Install Docker on the Ansible EC2 virtual server.
Now you need to install docker on your Ansible EC2 instance. To do that you need to create a new docker folder.
sudo mkdir /opt/docker
Then, install docker by executing the next command.
sudo yum install docker -y
Step 4: Add current user to Docker group on Ansible EC2 virtual server
You need to add the current userĀ āansible-admināĀ to the Docker group onĀ the āAnsibleServerāĀ EC2 virtual server to give Docker admin privileges.
sudo usermod -a -G docker ansible-admin
You will need to logout and log back in for these changes to take effect.
Then you can execute the next command
id ansible-admin
to see that the new docker user exists.
Step 5: Launch Docker
Now as Docker is installed on the Ansible EC2 instance you can launch it by executing the next command.
sudo systemctl start docker
As Docker is started you can execute the next command
sudo systemctl status docker
to see that docker is active and running now.
Step 6: Create Dockerfile
In the final version of the pipeline, the process will involve creating a new Docker image from your GitHub project and pushing it to Docker Hub. To accomplish this, your GitHub project should contain a Dockerfile.
If you used the projectĀ āHelloāĀ which was offered in ā[Module 3]: Git and GithubāĀ module, then you donāt need to create a new Dockerfile as this project repository has already contained Dockerfile.
FROM eclipse-temurin:17-jre-jammy
ENV HOME=/opt/app
WORKDIR $HOME
ADD hello-0.0.1-SNAPSHOT.jar $HOME
ENTRYPOINT ["java", "-jar", "/opt/app/hello-0.0.1-SNAPSHOT.jar" ]
If you used your own project repository and it didn't contain a Dockerfile, you will need to create a new Dockerfile.
To create a new Dockerfile, execute the following command, which will create the new file.
sudo touch Dockerfile
Then you can fill this file with a sequence of commands that describe how to build a containerized application environment. These commands include actions like copying files into the image, installing software, setting environment variables, and configuring the container.
To fill the Dockerfile with these commands, execute the following command.
vim Dockerfile
The Dockerfile is ready to use.
Step 7: Login Docker
Now that your Dockerfile is prepared for use, proceed by copying your project's JAR artifact from theĀ **"JenkinsServer"**EC2 instance and pasting it onto theĀ "AnsibleServer"Ā EC2 instance. It is important to note that this transfer will be automated through the pipeline further.
By completing this step, you'll be ready to test your Dockerfile along with the Docker environment you've set up.
Before you begin testing, make sure to authenticate yourself on Dockerhub. Execute the following command.
docker login
This command will prompt you to provide your Dockerhub login credentials, including your username and password.
With this, you have completed the process of logging into Docker and are now ready to proceed with testing.
Step 8:Ā Testing the Docker environment and Dockerfile
With your successful login to Dockerhub completed, you are now ready to begin testing the Dockerfile you have prepared.
Execute this command to create a docker image.
docker build -t hello:latest .
Next, execute the subsequent command to establish a tag that will facilitate the image's upload to Dockerhub:
docker tag hello:latest zufarexplainedit/hello:latest
Finally, proceed to push the Docker image to Dockerhub through the execution of this command.
docker push zufarexplainedit/hello:latest
Following these steps, navigate to your Dockerhub account to verify whether you can see a new image or not.
You should now observe that the image has been effectively added. This outcome confirms the successful installation of the Docker environment and that your Dockerfile is correct.
[Module 6]: Ansible
Now let us configure the Ansible Server on the EC2 Virtual Server instance.
Step 1: Create an AWS EC2 Virtual Server instance
You need a virtual server to run Ansible.
Follow instructions fromĀ [Module 1]: AWS EC2 Virtual ServerĀ section of this tutorial to finish this step and create an EC2 virtual server instance for Ansible.
Do not forget to add a security group setup. It allowsĀ AnsibleĀ andĀ SSHĀ to work on portĀ 8080Ā andĀ 22Ā respectively.
Use the nameĀ āAnsibleServerāĀ to distinguish your EC2 Virtual Server instance.
You can reuseĀ āCI_CD_PipelineāĀ security group andĀ āCI_CD_Pipeline_Key_PairāĀ for a newĀ āAnsibleServerāĀ EC2 instance.
Step 2: Connect to an AWS EC2 Virtual Server instance
Go to AWS Console home page ā EC2 Management Console Dashboard ā Instances ā AnsibleServer.
Then click theĀ āConnectāĀ button.
Then you will see this web page. You should again click theĀ āConnectāĀ button.
Now you can see the EC2 virtual server instance online terminal.
Now letās configure Ansible Server on EC2 virtual server instance.
Step 3: Change the hostname of āAnsibleServerā AWS EC2 Virtual Server instance
The first thing you need to do when you want to configure AnsibleServer on EC2 virtual server instance is changing its hostname.
Letās do it. Execute this command to open hostname file:
sudo vi /etc/hostname
You should see something like this:
Replace this hostname withĀ āansible-serverā. Then, reboot it.
sudo init 6
Step 4: Add and configure a new user in āAnsibleServerā AWS EC2 Virtual Server instance
Now letās add a newĀ ansible-adminĀ user to the AWS EC2 Virtual Server instance.
To do that use this command:
sudo useradd ansible-admin
Then, set the password forĀ ansible-adminĀ user.
sudo passwd ansible-admin
Also, you need to configure user privileges by editing theĀ sudoersĀ file.
sudo visudo
AddĀ āansible-admin ALL=(ALL) ALLāĀ to thisĀ sudoersĀ file.
Also, you need to editĀ /etc/ssh/sshd_configĀ file to enable PasswordAuthentication.
sudo vi /etc/ssh/sshd_config
Then you need to reload the service to confirm these changes.
sudo service sshd reload
As a result of executing this command, you will see:
Now you can use this command to avoid adding sudo for all further commands.
sudo su - ansible-admin
Step 5: Generate key in an AWS EC2 Virtual Server instance
You are planning to manage remote servers such as K8s EC2 virtual server instances further in this article. That is why you need to set up SSH keys.
ssh-keygen
As a result of executing this command, you will see:
Now SSH keys are generated and ready to use.
Step 6: Install Ansible
Now you can install Ansible on yourĀ āAnsibleServerāĀ EC2 virtual server instance.
Letās do it.
Execute this command to install Ansible.
sudo amazon-linux-extras install ansible2
To verify Ansible, use this command:
ansible --version
As a result of executing this command, you will see:
Step 7: Install Jenkins āPublish over SSHā plugin on JenkinsServer EC2 instance
As Ansible is installed on yourĀ āAnsibleServerāĀ EC2 virtual server instance, you can configure Jenkins to integrate it with Ansible. You need to install theĀ āPublish over SSHāĀ plugin to integrate Jenkins with the EC2 Virtual Server instance where Ansible is installed and with other EC2 Virtual Server instances where Kubernetes is installed.
Go toĀ āDashboardāĀ ā āManage JenkinsāĀ āĀ āConfigure SystemāĀ āĀ āAvailable pluginsā.
Then enterĀ āPublish over SSHāĀ in the search box.
Click the buttonĀ āInstall without restartā. Wait for the end of the downloading process.
Now the āPublish over SSHā plugin is installed on the Jenkins EC2 Virtual Server instance.
Step 8: Configure Jenkins āPublish over SSHā plugin
With the successful installation of the Apache Maven Jenkins plugin, you are now able to utilize this plugin within the pipeline which you created and updated in modules 2 and 3.
To do so, follow these steps:
Go toĀ āDashboardāĀ āĀ āManage JenkinsāĀ āĀ āConfigure SystemāĀ āĀ āPublish over SSHā.
Enter all required data as it is on the screenshot, including hostname, username, and private key (or password if applicable).
Then clickĀ the āApplyāĀ andĀ āSaveāĀ buttons.
Here you have finished configuringĀ the āPublish over SSHāĀ Jenkins plugin.
Next, click āTest Configurationā to validate that the plugin is working correctly.
On the left side you can see that the test plugin configuration status is āSuccessā. It means the plugin configuration is correct.
Step 9: Create new Docker directory in AnsibleServer
You need to make a new folder on the AnsibleServer EC2 instance where the project JAR will be stored. This jar will be used for creating a Docker image later.
Letās start.
Go toĀ ā/optāĀ folder in AnsibleServer EC2 instance.
cd /opt
Create a new folderĀ ādockerāĀ there.
sudo mkdir docker
Give privileges to thisĀ ādockerāĀ folder.
sudo chown ansible-admin:ansible-admin docker
Now, check theĀ ādockerāĀ folder privileges by executing this command.
ll
You can see thatĀ the ādockerāĀ folder is accessible withĀ the āansible-admināĀ user.
Step 10: Integrate āPublish over SSHāĀ Github plugin intoĀ the pipeline
Now asĀ āPublish over SSHāĀ Github plugin is installed and configured, you're now able to integrate it into the pipeline which you created in the ā[module 2]: Jenkins Serverā to transfer a project jar artifact from āJenkinsServerāĀ toĀ āAnsibleServerā.
Well, to integrateĀ āPublish over SSHāĀ Github plugin into the pipeline you need to follow these steps:
- Navigate toĀ āDashboardāĀ ā āCI_CD_Pipelineā ā āConfigureā ā āPost-build Actionsā.
- ClickĀ āAdd post-build actionāĀ button.
- ChooseĀ āSend build artifacts over SSHāĀ option.
- AddĀ āAnsibleServerāĀ intoĀ āNameāĀ input inĀ āSSH ServerāĀ section**.**
- AddĀ Ā ātarget/*.jarāĀ intoĀ āSource filesāĀ input inĀ āTransfer SetāĀ section**.**
- AddĀ Ā ātarget/āĀ intoĀ āRemove prefixāĀ input inĀ āTransfer SetāĀ section**.**
- AddĀ Ā ā//opt/docker/āĀ intoĀ āRemote directoryāĀ input inĀ āTransfer SetāĀ section**.**
- For now, simply put an empty string in the 'Exec command' input under the 'Transfer Set' section.
Finally, you should clickĀ āApplyāĀ andĀ āSaveāĀ buttons to finish the integrationĀ āPublish over SSHāĀ plugin with the pipeline.
Step 11: Test āPublish over SSHāĀ Github pluginĀ integrated into the pipeline
Now you can use your updated pipeline to transfer a project jar artifact from āJenkinsServerāĀ toĀ āAnsibleServerā. To do that you need to click theĀ āBuild NowāĀ button. As a result you will see a successful job result in the build history.
If you open yourĀ āAnsibleServerāĀ AWS EC2 terminal. You can check that the pipeline works well.
Just use this command.
cd /opt/docker
This way you can see the JAR artifact, indicating the successful build of your project from GitHub.
Step 12: Configure Ansible hosts
When you run an Ansible playbook, you specify the hosts it should run on. You can do this in two ways:
- Specify hosts directly in the playbook:Ā In your playbook, you can set theĀ
hosts
Ā parameter to a list of IP addresses or hostnames. - Use an inventory file:Ā Ansible allows you to define a list of hosts in an inventory file and reference this file when running your playbook. The default inventory file isĀ
/etc/ansible/hosts
.
By editingĀ /etc/ansible/hosts
, you can easily manage groups of hosts without having to write out their IP addresses each time you run a playbook.
Letās find out the AnsibleServer EC2 instance host by executing the following command.
sudo ifconfig
After you find out AnsibleServer EC2 instance host, you can add it to the Ansible hosts file by executing the following command.
sudo vi /etc/ansible/hosts
You can also add ā[ansible]ā as a reference
If you're managing a cluster of servers and you want to apply a playbook to all of them, instead of specifying each server's IP address in the playbook, you can simply add all the servers to a group in the inventory file and then specify the group in the playbook.
Step 13: ConfigureĀ Passwordless SSH authentication to localhost for Ansible
Ansible is designed for automating tasks on remote servers. Passwordless SSH authentication empowers Ansible to connect to those servers without the need for manual password entry.
Execute this command to create a secure connection from your computer to another computer (like the one at IP address 172.31.34.41), using the ansible-admin user's SSH key.
sudo ssh-copy-id -i /home/{your user name}/.ssh/id_rsa.pub {your user name}@{your host address}
In my case, it looks like this.
sudo ssh-copy-id -i /home/ansible-admin/.ssh/id_rsa.pub [email protected]
Now you can seeĀ āNumber of key(s) added: 1ā. It means that the passwordless SSH authentication installation was successfully completed.
Step 14: Create a new Ansible playbook for Docker tasks
Now that Ansible is all set up and good to go, you can make a new Ansible playbook for your pipeline. This playbook will let Ansible create and send a new Docker image to Dockerhub.
Here's how you can do it:
- Start by creating a new Ansible playbook file. Just use this command.
touch hello-app.yml
- Then, edit the newly madeĀ
hello-app.yml
Ā file. Open it up for editing with this command.
vi hello-app.yml
- Inside the file, type in the following stuff.
---
- hosts: ansible
user: root
tasks:
- name: create docker image
command: docker build -t hello:latest .
args:
chdir: /opt/docker
- name: create tag to push image onto dockerhub
command: docker tag hello:latest zufarexplainedit/hello:latest
- name: push docker image onto dockerhub
command: docker push zufarexplainedit/hello:latest
The Ansible playbook for Docker tasks is ready to use.
Step 13: Test the Ansible playbook with Docker tasks
With Ansible, Ansible playbook, AnsibleServer, and JenkinsServer all properly configured, it is time to test the Ansible playbook.
Navigate to the location of your Ansible playbook.
cd /opt/docker
Then, execute the following command.
sudo -u ansible-admin ansible-playbook /opt/docker/hello-app.yml
Upon completion, you will see the successful execution outcome of your Ansible playbook.
Furthermore, take a moment to visit your Dockerhub account and verify whether a new image is now visible.
You should see the newly added image. This outcome confirms that your Ansible playbook is correct.
Step 14: Integrate Ansible Docker tasks intoĀ the pipeline
Now asĀ āPublish over SSHāĀ Github plugin, Ansible and Docker are installed and configured, you're now able to integrate them all into the pipeline which you created in the ā[module 2]: Jenkins Serverā to transfer a project jar artifact from āJenkinsServerāĀ toĀ āAnsibleServerā and then build a new Docker image from your project and then push this Docker image onto Dockerhub.
To achieve it you need to follow these steps:
- Navigate toĀ āDashboardāĀ ā āCI_CD_Pipelineā ā āConfigureā ā āPost-build Actionsā ā āSend build artifacts over SSHā .
- AddĀ āsudo -u ansible-admin ansible-playbook /opt/docker/hello-app.ymlāĀ command into āExec commandā input.
Finally, clickĀ āApplyāĀ andĀ āSaveāĀ buttons to finish the integrationĀ Ansible Docker tasks with the pipeline.
Step 15: Test āAnsible playbook with Docker tasksāĀ integrated into the pipeline
Now you can test your upgraded pipeline to seamlessly transfer a project jar artifact from āJenkinsServerāĀ toĀ āAnsibleServerā then build a new Docker image from your project and then push this Docker image onto Dockerhub. To do that you need to click theĀ āBuild NowāĀ button. As a result you will see a successful job result in the build history.
Furthermore, take a moment to visit your Dockerhub account and verify whether a new image is now visible.
You should see the newly added image. This outcome confirms that your Ansible playbook with Docker tasks was successfully integrated into the pipeline.
[Module 7]: Kubernetes
Now letās configure K8s on the EC2 instance. You are going to create a new EC2 instance and install their kubectl command-line tool for interacting with a Kubernetes cluster further.
Step 1: Launch an AWS EC2 Virtual Server instance
Use instructions from āLaunch an AWS EC2 Virtual Server instanceāĀ section of this tutorial to finish this step.
Do not forget to add a security group setup. It allowsĀ all toolsĀ andĀ SSHĀ to work on portĀ 8080Ā andĀ 22Ā respectively.
Use the nameĀ āK8sServerāĀ to distinguish your EC2 Virtual Server instance.
You can reuseĀ āCI_CD_PipelineāĀ security group andĀ āCI_CD_Pipeline_Key_PairāĀ for a newĀ āK8sServerāĀ EC2 instance.
Step 2: Connect to an AWS EC2 Virtual Server instance
Click the āConnectā button.
Now you can see the EC2 Virtual Server instance online terminal.
Step 3: Change the hostname of āKubernetesServerā AWS EC2 Virtual Server instance
The first thing you need to do when you want to configure KuberenetesServer on EC2 virtual server instance is to change its hostname.
Letās do it. Execute this command to open hostname file:
sudo vi /etc/hostname
You should see something like this.
Replace this hostname withĀ ākubernetes-serverā and then reboot it.
sudo init 6
You will hostname was changed.
Step 4: Check AWS CLI version
Use this command to check the AWS version.
aws --version
This way you can see your current aws-cli version.
If you can see versionĀ aws-cli/1.18, you should download the latest version.
Step 5: Update AWS CLI
Now as you found out that you have an old aws-cli version on your EC2 instance you need to update it. To that go to AWS ā Documentation ā AWS Command Line Interface ā User Guide for Version 2.
Copy-pasteĀ the curl command.
First, execute this command to download awscli version 2.
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
Wait for the downloading process to commence.
You should see something like this.
Second, you need to execute this command to unzip awscli version 2 archive.
unzip awscliv2.zip
Third, you should execute this command to install awscli version 2.
sudo ./aws/install
Then, reload the Kubernetes EC2 Virtual Server instance online terminal.
Next, use this command to check the AWS version
aws --version
You can see that aws cli has aws-cli/2.
Step 6: Install kubectl
KubectlĀ is a fundamental command-line tool for interacting with any Kubernetes cluster, regardless of the underlying infrastructure. It allows you to manage resources, deploy applications, configure networking, access logs, and perform various other tasks within a Kubernetes cluster.
Now you need to install kubectl command-line tool for interacting with a Kubernetes cluster further. To that you need to go to AWS ā Documentation ā Amazon EKS ā User Guide ā Installing or updating kubectl ā Linux.
Or just click the linkĀ https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html.
First, execute this command to download kubectl.
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.27.1/2023-04-19/bin/linux/amd64/kubectl
Wait for the downloading process.
You will see something like this.
Give permission to kubectl.
chmod +x kubectl
Move kubectl to /usr/local/bin folder.
sudo mv kubectl /usr/local/bin
Check the version of kubectl.
kubectl version --output=yaml
Step 7: Install eksctl
EksctlĀ is an another command-line tool which is tailored specifically to the Amazon EKS service. Eksctl can be used to create AWS EKS clusters, manage node groups, and perform tasks specific to EKS, such as integrating with IAM roles and other AWS services by abstracting away much of the AWS infrastructure setup and management.
Execute the command to download kubectl.
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
Move eksctl to /usr/local/bin folder.
sudo mv /tmp/eksctl /usr/local/bin
Check the version of eksctl.
eksctl version
You should see the version
Step 8: Create IAM Role for eksctl
You need to create an IAM role and attach it to your āKubernetesServerā EC2 instance.
To do that you need to find EC2 in the search box.
Choose EC2 Virtual Server by clicking the linkĀ https://us-east-1.console.aws.amazon.com/ec2/.
Go to IAM Dashboard ā Roles.
Click the button āCreate roleā on the IAM roles web page.
Then chooseĀ āAWS serviceā , āEC2ā.Ā And the clickĀ āNextāĀ button.
Then, findĀ āAmazonEC2FullAccessā, āAmazonEC2FullAccessā, āIAMFullAccessā, āAWSCloudFormationFullAccessā in the search box and then click the āAdd permissionsā button.
And then clickĀ the āNextāĀ button.
Then typeĀ āEksctl_Roleā into āRole nameā input.
And the clickĀ āCreate roleāĀ button.
The role is created finally.
Step 9: Connect IAM Role with eksctl
Go to the AWS EC2 instance web page. ChooseĀ āKuberbetesServerā. Then click āActionsāĀ āĀ āSecurityāĀ āĀ āModify IAM Roleā.
ChooseĀ āEksctl_RoleāĀ and then clickĀ the āUpdate IAM roleāĀ button.
Now your IAM Role is connected with your āEKS_Serverā and eksctl tool.
Step 10: Create eksctl cluster
An Amazon EKS (Elastic Kubernetes Service)Ā cluster is a managed Kubernetes environment on AWS, automating intricate infrastructure tasks like setup, scaling, and maintenance. It's essential as it provides an efficient, secure, and AWS-optimized platform for deploying, managing, and scaling containerized applications, streamlining operations and freeing developers to focus on coding rather than managing underlying infrastructure.
Now, it's time to set up your EKS cluster.
To achieve this, follow these steps:
- Modify the following command with your specific information.
eksctl create cluster --name cluster-name \
--region region-name \
--node-type instance-type \
--nodes-min 2 \
--nodes-max 2 \
--zones <AZ-1>,<AZ-2>
For example, in my case, it looks like this.
eksctl create cluster --name zufarexplainedit \
--region eu-north-1 \
--node-type t3.micro
-
Execute the modified command and patiently await the completion of the cluster creation process. You will notice that the EKS cluster status is indicated as "creating" on the AWS CloudFormation web page.
The cluster creation procedure typically takes around 20 minutes. Once completed, the terminal will display the outcome of the process.
Furthermore, you can verify the successful EKS cluster creation status on the AWS CloudFormation web page.
Step 11: Create Kubernetes Deployment yaml file
A Kubernetes Deployment YAML file is a configuration script written in YAML format that defines how to manage and maintain a specific application or service within a Kubernetes cluster. It encapsulates instructions for orchestrating the deployment, scaling, updating, and monitoring of containers running the application. This file includes details such as the container image, the desired number of replicas, resource limits, environment variables, networking settings, and more. When applied to a Kubernetes cluster, the Deployment YAML file ensures the desired state of the application, automatically managing the creation, scaling, and recovery of containers to maintain the desired level of availability and reliability.
Now, as Kubernetes cluster, eksctl, kubectl are installed and configured, you can create a Kubernetes Deployment yaml file.
You can do that by executing the following command.
touch hello-app-deployment.yaml
Then, edit this file by executing the following command.
vi hello-app-deployment.yaml
Add this content to the hello-app-deployment.yaml.
apiVersion: apps/v1
kind: Deployment
metadata:
name: zufarexplainedit-hello-app
labels:
app: hello-app
spec:
replicas: 2
selector:
matchLabels:
app: hello-app
template:
metadata:
labels:
app: hello-app
spec:
containers:
- name: hello-app
image: zufarexplainedit/hello
imagePullPolicy: Always
ports:
- containerPort: 8080
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
Now hello-app-deployment.yaml is created and ready to use.
Step 12: Create Kubernetes Service yaml file
A Kubernetes Service YAML file is a configuration script written in YAML format that defines a network abstraction for a set of pods, allowing them to be accessed consistently within a Kubernetes cluster. This file outlines how the service should be discovered, accessed, and load-balanced by other services or external clients. It includes specifications like the service type (ClusterIP, NodePort, LoadBalancer), port numbers, selectors to identify pods, and more. When applied to a Kubernetes cluster, the Service YAML file creates a virtual IP and port that routes traffic to the appropriate pods, abstracting the underlying pod changes and providing a stable endpoint for communication, enabling seamless connectivity and dynamic scaling.
As Kubernetes cluster, eksctl, kubectl are installed and configured, you can create Kubernetes Service yaml file.
To do that you need to create a Kubernetes Service yaml file by executing the following command.
touch hello-app-service.yaml
Then, edit this file by executing the following command.
vi hello-app-service.yaml
Add this content to the hello-app-deployment.yaml.
apiVersion: v1
kind: Service
metadata:
name: zufarexplainedit-hello-app-service
labels:
app: hello-app
spec:
selector:
app: hello-app
ports:
- port: 8080
targetPort: 8080
type: LoadBalancer
Now hello-app-service.yaml is created and ready to use.
Step 13: Test Kubernetes cluster using kubectl
With your Kubernetes EKS cluster successfully installed, and configured, and your Kubernetes service and deployment files ready, it's time to put things to the test using kubectl commands.
-
Apply Deployment.
Use the following command to apply the deployment configuration.
kubectl apply -f hello-app-deployment.yaml
This will create a deployment with the specified number of replicas and a rolling update strategy, ensuring your application's availability and manageability.
2. Apply Service.
Next, apply the service configuration.
kubectl apply -f hello-app-service.yaml
This will set up a LoadBalancer type service, exposing your application to the internet.
Note that it might take a short while for the LoadBalancer to be provisioned and acquire an external IP address.
-
Check LoadBalancer Status.
Monitor the status of your service using.
kubectl get service zufarexplainedit-hello-app-service
When an external IP is assigned, you're almost ready to access your application.
-
Access Your Application.
Using a web browser, enter the assigned external IP address followed by :8080. After a brief moment, the page will load, displaying the "HelloWorld" message. Keep in mind that the initial loading might take a few seconds.
Cleaning Up with kubectl Commands
When you need to tidy up resources within your Kubernetes environment, you can use the following kubectl commands to effectively remove deployments, pods, and services.
1. Delete All Deployments.
To delete all deployments, you can use the following command.
kubectl delete deployments --all
This action ensures that no active deployment instances are left in your cluster.
2. Delete All Pods.
If you need to delete all pods, whether they are managed by a deployment or not, you can use the following command.
kubectl delete pods --all
Clearing pods can help reset your cluster state or prepare for new deployments.
3. Delete All Services.
To clean up services that expose your applications to the network, you can use the following command.
kubectl delete services --all
Removing services may involve downtime, so consider the implications before proceeding.
Deleting an Amazon EKS Cluster
To remove all the resources associated with the specified Amazon EKS cluster created with eksctl
, including worker nodes, networking components, and other resources, you can use the following command.
eksctl delete cluster --name {your cluster name} --region {your region name}
For me it is.
eksctl delete cluster --name zufarexplainedit --region eu-north-1
Make sure you are certain about stopping the cluster, as this action is irreversible and will result in data loss.
Step 14: Add and configure a new user in āKubernetesServerā AWS EC2 Virtual Server instance
Now letās add a newĀ ansible-adminĀ user to āKubernetesServerā AWS EC2 Virtual Server instance.
To do that use this command.
sudo useradd ansible-admin
Then, set the password forĀ ansible-adminĀ user.
sudo passwd ansible-admin
Also, you need to configure user privileges by editing theĀ sudoersĀ file.
sudo visudo
AddĀ āansible-admin ALL=(ALL) ALLāĀ to thisĀ sudoersĀ file.
Also, you need to editĀ /etc/ssh/sshd_configĀ file to enable PasswordAuthentication.
sudo vi /etc/ssh/sshd_config
Then you need to reload the service to make these changes.
sudo service sshd reload
As a result of executing this command, you will see:
Now you can use this command to avoid adding sudo for all further commands.
sudo su - ansible-admin
Step 15: Generate key in an AWS EC2 Virtual Server instance
You are planning to manage remote servers such as K8s EC2 virtual server instance further in this article. That is why you need to set up SSH keys.
ssh-keygen
As a result of executing this command, you will see:
Now SSH keys are generated and ready to use.
Step 16: ConfigureĀ Passwordless SSH authentication to localhost for Ansible
Ansible is designed for automating tasks on remote servers. Passwordless SSH authentication empowers Ansible to connect to those servers without the need for manual password entry.
Execute this command to create a secure connection from your computer to another computer (like the one at IP address 172.31.34.41), using the ansible-admin user's SSH key.
sudo ssh-copy-id -i /home/{your user name}/.ssh/id_rsa.pub {your user name}@{your host address}
In my case, it looks like this.
sudo ssh-copy-id -i /home/ansible-admin/.ssh/id_rsa.pub [email protected]
Now you can seeĀ āNumber of key(s) added: 1ā. It means that the passwordless SSH authentication installation was successfully completed.
Step 17: Configure Ansible hosts in AnsibleServer EC2 instance
When you run an Ansible playbook, you specify the hosts it should run on. In this step you need to specify KubernetesServer EC2 instance host. To do that you need to repeat the same steps which you passed in ā[Module 6]: Ansibleā.
Letās find out the KubernetesServer EC2 instance host by executing the following command.
sudo ifconfig
After you find the KubernetesServer EC2 instance host, you can add it to the Ansible hosts file by executing the following command.
sudo vi /etc/ansible/hosts
You can also add ā[kubernetes]ā as a reference
Step 18: Create a new Ansible playbook for Kubernetes tasks
Now that Kubernetes is all setup and good to go, you can make a new Ansible playbook with Kubernetes tasks for your pipeline. This playbook will let Ansible run your app on the Kubernetes cluster with kubectl commands.
Here's how you can do it:
- Start by creating a new Ansible playbook file. Just use this command.
touch kubernetes-hello-app.yml
- Then, edit the newly madeĀ
hello-app.yml
Ā file. Open it up for editing with this command.
vi kubernetes-hello-app.yml
- Inside the file, type in the following:
---
- hosts: kubernetes
tasks:
- name: deploy regapp on kubernetes
command: kubectl apply -f hello-app-deployment.yaml
- name: create service for regapp
command: kubectl apply -f hello-app-service.yaml
- name: update deployment with new pods if image updated in docker hub
command: kubectl rollout restart deployment.apps/zufarexplainedit-hello-app
The Ansible playbook for Kubernetes tasks is ready to use.
Step 19: Integrate a new Ansible playbook for Kubernetes tasks with Jenkins
Now that Kubernetes, Ansible, and Ansible playbook for Kubernetes tasks are all set up and good to go, you can integrate it with Jenkins.
-
Go to JenkinsServer ā Jenkins dashboard ā New Item.
-
Create new Jenkins Freestyle project with the name āCD-Jobā.
-
Click āOKā button.
-
Go to āPost-build Actionsā section.
-
Click the āAdd post-build actionā button.
-
Choose āSend build artifacts over SSHā option.
-
Choose āAnsibleServerā as SSH Server.
-
Add this command to āexec commandā input.
sudo -u ansible-admin ansible-playbook /opt/docker/kubernetes-hello-app.yml
-
Click āApplyā and āSaveā buttons.
-
Go to Jenkins dashboard ā āCI_CD_Pipelineā ā Configure ā āPost-build Actionsā section.
-
Click the āAdd post-build actionā button.
-
Choose āBuild other projectsā option.
-
Go to āBuild other projectsā section.
-
Choose āTrigger only if build is stableā option.
-
Add āCD-Jobā to āProject to buildā input.
-
Click āApplyā and āSaveā buttons.
Now you can consider that the pipeline is completely finished and ready to use.
Step 20: Testing the Final Pipeline Version
Now is the time to put the final pipeline version to the test.
Navigate to Jenkins ā Jenkins dashboard ā "CI_CD_Pipeline".
Click the "Build Now" button.
To see the results, review the build console logs.
You will notice that the "CD-Job" was triggered in the build console logs, and the final status is marked as SUCCESS.
4
Moreover, you can head to Dockerhub to confirm the addition of the new Docker image.
And finally, you can access your application using a web browser. Enter the assigned external IP address followed by ":8080". After a brief moment, the page will load, showing the "HelloWorld" message.
Conclusion
Well done on setting up this modern CI/CD pipeline!
You've done an awesome job, and you're a real hero!
Thanks for all your effort!
About the author
Zufar Sunagatov is an experienced senior software engineer who is passionate about designing modern software systems.
- Developed high-performance distributed systems using Java, Kotlin, AWS, Docker, and Kubernetes for companies like Citi (London), MTS (Moscow) and others (you can follow Zufar's LinkedIn profile for more information).
- Founded Ice Latte, an open-source online marketplace from scratch (you can join Zufarās team and contribute to his project on GitHub: https://github.com/Sunagatov/Online-Store).
- Established the ZufarExplainedIT community to share his knowledge and experience with others (you can follow Zufar's IT Telegram community: https://t.me/zufarexplained).
- Mentored for over 3000 minutes and conducted 60 sessions on ADPlist, nurturing aspiring talents (you can get mentored by Zufar on ADPlist).
- Engaged audiences as a speaker at conferences and IT YouTube channels, sharing invaluable insights (examples of his YouTube videos include: āŠ¢ŠµŃŃŠ¾Š²Š¾Šµ ŃŠ¾Š±ŠµŃеГование Java ŃŠ°Š·ŃабоŃŃŠøŠŗŠ° #27 - ŠŃŃŠ°Ń Š”ŃŠ½Š°Š³Š°Ńовā, āAspiring Speakers Lunchtime Lightning Talks May 28thā).
- Authored highly popular IT articles with 7000+ views each (examples of his articles are: āMicroservice Architecture Patterns Part 1: Decomposition Patternsā, āŠ§ŃŠ¾ Š·Š½Š°ŃŠøŃ Ā«Š²Š°ŃŠøŠ°ŃŠøŠ²Š½ŃŠ¹Ā»? ŠŠ±ŃŃŃŠ½Ńем ŠæŃоŃŃŃŠ¼Šø ŃŠ»Š¾Š²Š°Š¼Šøā).