Friday, March 21, 2025

Jenkins (2)

 


Chapter 2. Create Freestyle Jobs

Chapter 3. CI/CD project


Tip:

Unexpected situation in real life occur. Default language in Jenkins was set as Polish. Since way more educational material is in English, I wanted to switch to English.

To change language in Jenkins, You need install plugin: Locale

After instalation plugin, new options appeared.



To fix visibility project, I change theme to dark. To do, go to MANAGE JENKINS. Secondly go to APPEARANCE. In theme tab select DARK theme, and approve selection by SAVE button.



After theme is selected, select PROJECT <my-job> (Freestyle project). In next printscreen we can see project details. In Permalinks section are listed hyperlinks accroding description.


In second step we click CONFIGIRE button. In GENERAL tab,  we can see details of project.


To execute shell in Jenskins, go to BUILD SETPS, and click <add build step>. In drop-down menu I selected EXECUTE SHELL. In EXECUTIVE SHELL we can applly all bash  commands. 




To run next build, click button BUILD NOW. After we click BUILD NOW, we see screen like below.





To see detailed information in You need to select CONSOLE OUTPUT.



Buidls was done successfully, information about this build status is in last line "SUCCESS".

In Execute shell, we can perform command LS -LTR, to show list of all files in Jenkins Workspace.


Results of EXECUTE SHELL are present in CONSOLE OUTPUT.


All action has inpact on Workspace. If we create any file it will be present in WORKSPACE. Content of Workspace is consistent with Console output.



Good practice, is to clear worldpace. Any file present in Workspace may cause incertain results in next build. 



When get into into docker, You find directory Workspaces inside docker (with folder) - More info I will share in chapter 5.


To clear workspace before next, checkbox show below need to be selected.


See You in chapter 3.






Monday, March 17, 2025

JENKINS (1)

 


I was thinking a lot, what shoudl be next post. I already started draft of usage of Docker advanced topics (I will post it in the future). I wanted to create real life example. I came up with idea, to connect Docker usage and Jenkins learning. I realize despite Jenkins simiplicity, in right hands, it is very powerfull tool.

I have plan to divide Jenkins post in few step real life usage.


Plan:

Chapter 1. Install Jenkins (with Docker)

Chapter 2. Create Freestyle Jobs

Chapter 3. CI/CD project


Chapter 1. Install Jenkins


Before we begin, I need set reservation, Docker need to installed.

Before installation, I woudll like to confirm, that Jenkins is not installed.

Command docker image ls  -all and docker ps, show status before installation.



One of core feature in Docker is networks. It is 5 type of Docker network. For Jenkins we will user network type: bridge.(1

Containers in the network can communicate with each other using their own IP addresses and DNS names, but they’re isolated from those outside the network(2)(3).

    docker network create jenkins



Dockerfile

FROM jenkins/jenkins:2.492.2-jdk17

USER root

RUN apt-get update && apt-get install -y lsb-release ca-certificates curl && \

    install -m 0755 -d /etc/apt/keyrings && \

    curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc && \

    chmod a+r /etc/apt/keyrings/docker.asc && \

    echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \

    https://download.docker.com/linux/debian $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" \

    | tee /etc/apt/sources.list.d/docker.list > /dev/null && \

    apt-get update && apt-get install -y docker-ce-cli && \

    apt-get clean && rm -rf /var/lib/apt/lists/*

USER jenkins

RUN jenkins-plugin-cli --plugins "blueocean docker-workflow"

    

Dockerfile build command:

docker build -t myjenkins-blueocean:2.492.2-1 .


Initial run localhost:8080, show information how unlock Jenkis.


To unlock Jenkins, initial password is needed. To get password, I enter inside Docker container. There are CLI commands, but I wanted to do this way.

I have to know container ID. To get container ID , I run command: docker ps



When I have container ID, I run command below, to get into container with bash shell.

docker exec -it 988c18960248 /bin/bash


I run pwd, to confim my location in Docker container. 
Then I go to location /var/jenkins_gome/secrets/ and cat file initialAdminPassword
I have small typos, but finally I get initial Admin password.


When I have password, I paste it to unclock Jenkins.







Password was correct, so I continued to configure Jenkins. There was information to install suggested plugins. I click it.


Jenkins installation was completed.







Docs:

1. https://www.jenkins.io/doc/book/installing/docker/

2. https://spacelift.io/blog/docker-networking

3. https://docs.docker.com/engine/network/drivers/bridge/


PS. Jenkins can be made in Docker compose:

https://dev.to/msrabon/step-by-step-guide-to-setting-up-jenkins-on-docker-with-docker-agent-based-builds-43j5






Thursday, March 13, 2025

Docker - beginings



Who knew, that idea of 3 gentelmens during summer 2010 invent something that will have change the world. It take 21 months of development to go public on conference PyCon in Santa Clarita, but now, it is core of microservices. Docker is core element in Cloud. 

Best was of learining, is by doing (practice). Let's start of learning...

Step 1. Install Docker

For docker presentation, I created VM with Ubuntu24.04.2 LTS in VMware Player.



To confirm, that Docker is not present, snapshoot for the record.


All commands are from official Docker website.

In first step I added GPG keys and repository to apt sources:


# Add Docker's official GPG key:

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:

echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update



In next step Docker is installed.

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

After instalation, I verified if docker is installed.

docker --verison



Summary:

Docker is software to create separated enviroment from opertation system.

Docker file is a text file having instructions and commands necesary to build docker image.

Docker image it is template , which is used to build containers. It can be stored local or remote.

Docker container is lightweight enviroment which contains, application  and necesarry libraries, builded from docker image.

Docker Hub it is online repetytory for storage of Docker images.

Docker Desktop is Docker software with grafical UI.

Docker compose create docker containers form sigle docker file. Docker compose text file contains instruction, commands and relations between future containers.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Docu:

1: https://docs.docker.com/engine/install/ubuntu/

2: https://supportfly.io/docker-swarm-vs-docker-compose/







Saturday, March 8, 2025

Homelab begins

 

Always before journey begin, destination has to be known. My goal is learn K8s. This approach helps learn/test new configuration on-prem without hight costs in cloud.

Before I choose optimal path for I will test few configuration. I will verify also what my hardware is able to handle. At first is what we want, but it has to be achivable at current date/time.


Range for test will be adapted (I want also share my impresion  later - this post will be update).

Tests:

K8s + Fedotra

K8s + ??

K3s + Rocky

K3s + ??


After optimal coombination will be selected, next stage will occur ( deplyment of aplications).

Stay tuned.




Install Helm

 



I was thinking who to start this entry. I have several ideas, to write first paragraf. What is final goal of everything we are doing. For whom is all our work - custromer. Custromer is happy when, his problem will be solved. Customer will happier when this solution will be cheap. Custromer will be the happiest, when his problem will be sovled, cheap and on time (or asap).
To do tasks faster, it has to be automated. 
Kubernetes, also known as K8s, is a system for automating deployment, scaling, and management of containerized applications. 
Helm is package manager for Kubernetes. Helm simplifies this process by automating the distribution of your applications using a packaging format called a Helm chart

In first set I connect via SSH to my master node.


First set before instalation, we need to update and upgrade system. 



To install helm in terminal command below need to be executed:


curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

chmod 700 get_helm.sh




To confirm  that instalation is succesfull, run command helm version. If result is like below, instalation was succesfull.



More info:
  •     https://helm.sh/docs/


K8s cluster - bash install

     In my homelab, I testes another method of installation of Kubernetes. Average time of installation of Kubernetes via Ansible was 15 min...