Docker & kubernetes example – Full project for free

Okay, I love to post free examples/projects on my github from while to while, i choose docker and kubernetes this time, the project idea it’s very nice and easy to implement.

What this project do ?

This can be a simple web app that reads a ‘hello world’ string from the MySQL database.Run a database app. Data volume should be persistent.Application from step 1 needs to discover the database from step 2 using Kubernetes native features.
Database credentials should NOT be hardcoded in application or helm chart code.The application should be accessible from the outside of Kubernetes.Create a helm chart which implements all these steps

  • Create an application that connects to a database, reads some data, and returns this data upon HTTP request, This can be a simple web app that reads a ‘hello world’ string from the MySQL database.
  • Run a database app. Data volume should be persistent.
  • Application from step 1 needs to discover the database from step 2 using Kubernetes native features, Database credentials should NOT be hardcoded in application or helm chart code.
  • The application should be accessible from the outside of Kubernetes.
  • Create a helm chart which implements all these steps

I Choose to use Java as programing language because the springboot framework it’s already defined and easy to use.

Please follow the readme file and everything will working fine without any issue, if you have any question comment below and i will answer

GitHub Link HERE

Enjoy the free learning

Osama

DevOps Overview, Cloud Version this time Azure

DevOps is the union of people, process, and products to enable continuous delivery of value to your end users. Azure DevOps is a set of services that gives you the tools you need to do just that. With Azure DevOps, you can build, test, and deploy any application, either to the cloud or on premises. DevOps practices that enable transparency, cooperation, continuous delivery and continuous deployment become embedded in your software development lifecycle.

Azure DevOps provides several tools you can use for better team collaboration. It also has tools for automated build processes, testing, version control, and package management. That’s quite a bit to cover! We’ll get to all the tools eventually. For now, let’s follow the team as they begin with an overview of what Azure DevOps is and how they can get started.

Azure DevOps ServicesDescriptions
Azure Boardsagile tools that help us plan, track, and discuss our work, even with other teams.
Azure Pipelines build, test, and deploy with CI/CD that works with any language, platform, and cloud.
Azure Test Plansmanual and exploratory testing tools.
Azure Reposprovide unlimited, cloud-hosted private, and public Git repos.
Azure Artifacts create, host, and share packages.

What is Agile?

Agile is a term that’s used to describe approaches to software development, emphasizing incremental delivery, team collaboration, continual planning, and continual learning. Agile isn’t a process as much as it is a philosophy or mindset for planning the work that a team will do. It’s based on iterative development and helps a team better plan for and react to the inevitable changes that occur in software development. Let’s listen in on Mara’s discussion with Andy after the latest release.

Recommendations for adopting Agile

  • Create an organizational structure that supports Agile practices
  • Mentor team members on Agile techniques and practices
  • Enable in-team and cross-team collaboration:- If collaboration is the key to becoming successful at Agile, what are some of the ways you can encourage it? Here are some ideas.

What is Azure Boards?

Azure Boards is a tool in Azure DevOps to help teams plan the work that needs to be done. The Tailspin team will use this tool to get a better idea of what work needs to be done and how to prioritize it.

Set up Azure Boards using the Basic process

  • Create the project
  1. Sign into your account at dev.azure.com.
  2. Select + Create project.
  3. In the Project name field, type Space Game – web.
  4. In the Description field, type The Space Game website.
  5. Under Visibility, you choose whether to make your project public or private. For now, you can choose private.
  6. Select Advanced.
  7. Under Version control, make sure that Git is selected. Under Work item process, make sure that Basic is selected.
  8. Select Create.
  • Create a team
  1. Select Project settings in the lower-left corner.
  2. On the Project details page, under General, select Teams.
  3. Select Space Game – web Team.
  • Add team members
  1. Under Members, select + Add.
  2. Enter the email address of the user you’d like to add. Then select Save changes.
  3. Repeat the process for any other members you’d like to add.
  • Create the board
  1. In the column on the left, point to Boards and select Boards from the menu that appears.
  2. Select Space Game – web Team boards. A blank board appears.
  3. In the To Do column, select the green + button next to the New item field.
  4. Enter Stabilize the build server and then press Enter.
  5. Select the ellipsis (), and then select Open.
  6. In the Description field, enter this text (The build server keeps falling over. The OS, Ubuntu 16.04, requires security patches and updates. It’s also a challenge to keep build tools and other software up to date.)
  7. Select Save & Close.
  8. Follow the same steps for the next two items.
TitleDescription
Create a Git-based workflowMigrate source code to GitHub and define how we’ll collaborate.
Create unit testsAdd unit tests to the project to help minimize regression bugs.

Drag Stabilize the build server to the top of the stack. Then, drag Create a Git-based workflow to the second item position. Your final board looks like this.

  • Define a sprint
  1. In the left-side column, select Sprints.
  2. Select Set dates from the upper right.
  3. Leave the name as Sprint 1.
  4. In the Start date field, select the calendar and pick today’s date.
  5. In the End date field, select the calendar and pick the date two weeks from today.
  6. Select Save and Close.

Assign tasks and set the iteration

  1. Under Boards, select Work items.
  2. Select Stabilize the build server.
  3. In the Iteration drop-down list, select Sprint 1.
  4. From the same window, select Unassigned and set yourself as the task owner.
  5. Repeat the process for the other two work items.
    1. Create a Git-based workflow
    2. Create unit tests

Cheers
Osama

integrate jenkins with github “Method POST required” Error

This post for error trying to integrate Jenkins with github, i will post about that for sure as video and Blog post, but for this error i will like the following :-

This is when you try to to do any changes from the github side, it’s not reflecting on Jenkins side, this is simple because of the webhook (payload) not including the “/” at the end

it should be like the below :-

Add “/” at the end of your Payload URL

Cheers

Osama

Auto Closing Trigger in Zabbix

There are different problems category in zabbix which is like the below:-

  • Disaster
  • High
  • Average
  • Warning
  • Information
  • Not classified

I will focus in this post on Information and Not Classified Issues.

These two Problem category to inform users about some change in the operating system for example, such as Updating the operating system, or You have CPU utilization, this is not the issue, the problem with these two category they never disappeared from Zabbix Dashboard, and to be honest for me it’s annoying 😅

Therefore, i was trying to find a way to hide these issues, i don’t want to disabled the trigger because in that case it will never appeared and this is not the goal for me,I just want them to be on Dashboard for certain amount of time.

I found two ways for that after investigation, the one will be done from Database level, for example MySQL in my case, the other one via Zabbix Dashboard ( Trigger part) this is the right one and what i want.

Method #1 

To fix this issue from the database , you have to follow the below : –

  • You should have access to MySQL
  • Use Zabbix Database
  • Knowledge of database and Zabbix table, you don’t want to corrupt the database.
  • there are different tables we need to deal with
triggers table
problem table
alerts table
  • You have to know, inside trigger table value column contains two number which 0 (you don’t have any error) and 1 (you have problem)
select * from triggers where description like '%Operating%' and value = 1;
update triggers set value = 0 where  description like '%Operating%' and value = 1;

The above Select search for trigger called Operating system and the trigger should have issue, then update this trigger to 0 to assign this issue to ok.

Method #2

This method i preferred but i had to mentioned the previous one so in case someone wants to use it, in this one you don’t have to access to the database at all.

  • From The upper panel –> Choose configuration –> Host –> search for your host –> Press on Trigger –> Search for the trigger.
  • Once you press on the trigger you want, it will show couple of Options , we will care only about “problem expression”
  • From problem expression press add button and choose the item that related to this trigger.
  • There is Function inside the zabbix ( Built-in) called nodata takes second as parameter, you can put the item and choose the function then set the time for 10 sec same as the below picture.

Enjoy 👊

Cheers 🍻

Osama

Install Docker on ubuntu 18.04.3 LTS

What is Docker ?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

Why Docker ? 

  • Agility
  • Simplicity
  • Choice

Docker Installation on ubuntu 18.04.3 LTS

In this post, i will show you step by step to install docker on Ubuntu operating system, i prefer to create account on docker hub here.

Step#1 :-

update the existing list of packages using

sudo apt update

Step #2 :

install prerequisite packages which will let apt use packages over HTTPS

sudo apt install apt-transport-https ca-certificates curl software-properties-common

Step #3: –

add GPG key for the official Docker repository to your system

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Step #4 :-

Add the Docker repository to APT sources

sudo add-apt-repository  "deb [arch=amd64] https://download.docker.com/linux/ubuntu  $(lsb_release -cs)  stable"

Step #5: –

Install Docker

sudo apt-get install docker-ce

Step #6: –

Verify that Docker CE is installed correctly by running the hello-world image.

sudo docker run hello-world

You can could face an issue related to Hello-world Command when you are trying to verify the installation which is

permission denied while trying to connect to the docker daemon socket at unix
/var/run/docker.sock: connect: permission denied 

You can solve this issue by fire the below command and try again

sudo chmod 666 /var/run/docker.sock

Also you can list all the available docker version By running the below command

apt list -a docker-ce

Check if the services is up and running: –

sudo systemctl status docker

Reference 

Docker documentation here

Cheer and enjoy the docker

Osama

Step by Step – Zabbix 4.4.2 Installation and configuration on ubuntu 18.04.3 LTS

What is Zabbix ?

Zabbix is Open Source software used for monitoring the application, Server and networking, and cloud services, zabbix provide metrics, such as network utilization, CPU and disk space .. etc.

What Zabbix 4.4.2 can monitor

In this post i will try to mention everything for Zabbix installation and configuration, include to this some of the issues that you will face during the installation with screenshots, the idea of this post to help people and allow them to understand and simplify the installation/configuration.

You can Refer always to Zabbix documentation which include different versions, remember this post is for Zabbix 4.4.2 and maybe will work on other versions, but never tested before. The documentation HERE.

You can Download Zabbix From HERE, Depends on your operating system and version, Zabbix supporting two different databases during the installation which is MySQL & PostgreSQL.

Zabbix Installation

Step#1:- Install Apache, MySQL and PHP

sudo apt-get update
sudo apt-get install apache2 libapache2-mod-php
sudo apt-get install mysql-server
sudo apt-get install php php-mbstring php-gd php-xml php-bcmath php-ldap php-mysql

Once the installation is done, you have to update the timezone for PHP, you can do this by edit the file

/etc/php/php<version>/apache2/php.ini

Search for the line include word “Date”, remember when you edit the file you will find “;” at start of the line, in php this is comment , so you have to remove and update the timezone, the List of Supported Timezones in php HERE, once you find yours edit the file.

[Date]
;http://php.net/date.timezone
date.timezone = 'Asia/Amman'

I also attached pictures to show you how the file will look like

php.ini from the inside

Step #2: Before Install Zabbix Server

before install Zabbix server, there are one required step should be done first which is enable the zabbix repository, the download Link (HERE)that mentioned above gave you the steps , again you can find the link here and choose which Operating system Zabbix will be installed on

Zabbix Download Link shows our setup

From the above, once you choose everything, scroll down to find the repository.

wget https://repo.zabbix.com/zabbix/4.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.4-1+bionic_all.deb
dpkg -i zabbix-release_4.4-1+bionic_all.deb
apt update

Step #3: Install Zabbix Server

sudo apt-get update
sudo apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-agent

Now all the necessary packages has been installed on the operating system, the configuration start from the base which is the database.

Step #4: Create Zabbix Database Schema

Login to MySQL by the below commands to create the database and user.

mysql -uroot -p
Enter the password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> quit;

Now we have to import the data into the schema we just create, to do this we should run the below command, notice these steps should be done in order otherwise an issue will be appeared, You will be prompted to enter your newly created password.

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -u zabbix -p zabbix

Step #5: Configure Zabbix file to access the database.

Edit the following file

 /etc/zabbix/zabbix_server.conf

Search for the following Lines using your favorite editor either vi, vim , nano .. etc

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password

Step #6:- Restart the services to make everything ok

Start Zabbix server and agent processes and make it start at system boot.

systemctl restart zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2

OR

sudo service apache2 restart
sudo service zabbix-server restart

After starting the Zabbix service, let’s go to Zabbix web installer and finish the installation.

Connect to your newly installed Zabbix frontend: http://server_ip_or_name/

Before doing this, which is access to above Link, i faced an issue, which is i was 100% everything is Ok, but everytime i access the link, HTTP response code with 404 NOT FOUND, i was searching about this, and the solution was like the following

Change the directory to

/etc/apache2/sites-available

Under this location, you will find two file

  • 000-default. conf
  • default

Edit these two file to change the following Line

Change DocumentRoot /var/www/html -- > DocumentRoot /usr/share/zabbix

Restart the Apache again, Now the Link will work.

Step #7: complete the configuration via Zabbix Web Installer.

  • Zabbix Setup Welcome Screen
Zabbix Welcome Screen
  • Check for pre-requisites
pre-requisites everything should be OK

to solve the above you have to fix the value from one file which is

/etc/php/php<version>/apache2/php.ini

and search for the option, for example, post_max_size the current value is 8M just change to 16M and So on, remember after you change the value you have to restart the Apache to take the effect and then check the pre-requisites again.

after fixing the Values.
  • Configure DB Connection

Enter database details created in Step #4 and click next to continue.

Database Details in Step #4
  • Zabbix Server Details

This is the host and port of running Zabbix server, Don’t change the values of the port and host, no need to do that, since it’s running on the same server, for the Name, you can give name for the instance.

Zabbix Server Details
  • Pre-Installation Summary
Summary
  • Done

Enjoy the zabbix ☠🍻

Osama

How to setup GitHub for the first time

Make your life easier by using one Repository you can either do it for your indiviusal use or for company, Github consider as one of the most common DevOps tools.

In this post i will show how to create GitHub and use it for the first time, for more advance topics about it please review the documentation that i already mentioned in the document.

Access to document from here

Enjoy

Osama

Configure LB Using Nginx

Happy New Year Everyone

This is the first blog post for the 2020, i Wish everyone will have healthy and wonderful year, may your dreams come true.

I post recently or let’s say Last Year about Full automation project using DevOps tools, and i didn’t to be honest except that much download and questions on that post. you can read it from here.

I decided to create new project but this time to show the power of DevOps and how to use it more in your daily Job, task or even configuration.

The idea of this project like the following:-

  • You have two code, one Go based application, one Java-based application. Both are providing an HTTP service with the same endpoints.
  • The Endpoints which is :-
RouteDescription
/A static site. Should not appear in the final setup as it is but redirect to /hotels.
/hotelsJSON object containing hotel search results
/healthExposes the health status of the application
/readyReadiness probe
/metricsExposes metrics of the application

We have to setup Load Balancer for this application to be like the following :-

traffic distribution should be as follows: 70% of the requests are going to the application written in Go, 30% of the requests are going to the application written in Java, also i will do it using Docker

I upload the code, and the application ( the two part which is Go application and Java) to my Github HERE, all the configuration has been uploaded to my github,

The Solution files like the below;

  • docker-compose.yml file in root directory is the main compose file for setting up containers for all services
  • go-app directory contains binary of Golang Application and Dockerfile of relavant setup
  • java-app directory contains binary of Java Application and Dockerfile of relavant setup
  • load-balancer directory contains nginx.conf file which is configuration file of Nginx and have load balancer rules written in it. And containers a Dockerfile for setting up Nginx with defined configurations

The final architecture will be like this instead of the image you saw above

Enjoy And Happy New Year

Osama Mustafa (The Guy who known as OsamaOracle)

Complete Automation DevOps Project Deployed on kubernetes

## Problem definition

The aim of test is to create a simple HTTP service that stores and returns configurations that satisfy certain conditions. Since I love automating things, the service should be automatically deployed to kubernetes.

You can read more about the project, once you access to my GitHub using the README.MD, I explained the project step by step also the documentation explained every thing.

the code has been uploaded to GitHub, include to this, the documentation uploaded to Slide-share.

The code configuration here

The documentation here

Enjoy

Osama