Thursday, 15 January 2026

11 JavaScript Extensions for VS Code


VS Code has many extensions and tools to help developers write and work with JavaScript more easily. 


Quokka - Centuplex (Ctrl + Shift + P)

Prettier - Code formatter(enable from settings format on save)

GitHub Copilot - GitHub

(Legacy) Tabnine - TabNine

Postman - Postman

Thunder Client - Thunder Client

ES7+ React/Redux/React-Native snippets - dsznajder

Turbo Console Log - Anas Chakroun

Astro - Astro

Live Server - Ritwick Dey

James Q Quick VS Code Theme - James Quick


DotENV - mikesteadv (default with nodejs)

npm Intellisense - Christian Kohler (built in VSCode now)

Auto Rename Tag - Jun Han 


10 HTML and CSS Extensions for VS Code


VS Code has some extensions for managing HTML and CSS, as well as helping with editing HTML and CSS files more efficiently. 


Enable Extensions: 

Live Server - Ritwick Dey

Auto Rename Tag - Jun Han

Prettier - Code formatter (Enable from settings - format on save)

IntelliSense for CSS class names in HTML - Zignd

CSS Peek - Pranay Prakash

CSS Grid Snippets - ohansemmanuel

CSS Flexbox Cheatsheet - Dzhavat Ushev

<p>loream3000<p/>

vscode-icons - VSCode Icons Team

GitLens — Git supercharged - GitKraken


Sunday, 3 November 2024

Installing R and RSTUDIO

Installing R

Go to https://www.r-project.org/  

download R

to get the closest mirror, and select

0-Cloud https://cloud.r-project.org/ Automatic redirection to servers worldwide

Download and Install R by Choosing the operating system

 

Installing R Studio

https://posit.co/

Download IDE using DOWNLOAD RSTUDIO

 

Environments for R

https://posit.cloud/

https://colab.research.google.com/notebooks/intro.ipynb

https://www.jamovi.org/

Wednesday, 19 April 2023

xsos Tool in Linux


#install xsos

yum install http://people.redhat.com/rsawhill/rpms/latest-rsawaroha-release.rpm

yum install xsos rsar


xsos --help

xsos


xsos -m

xsos -c

xsos -d


sudo xsos --ethtool

xsos --cpu --lspci --netdev


sudo xsos --bonding

xsos --ps


xsos --kdump

xsos --sysctl


xsos --cpu --intrupt

xsos --softirq


Ref:- access.redhat.com/discussions



Tuesday, 11 April 2023

Install Terraform on CentOS Stream 9 Server


Install Terraform from the Terraform Repository


sudo dnf install dnf-utils


sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Adding repo from: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo


sudo dnf repolist

repo id              repo name

appstream            CentOS Stream 9 - AppStream

baseos               CentOS Stream 9 - BaseOS

extras-common        CentOS Stream 9 - Extras packages

hashicorp            Hashicorp Stable - x86_64


sudo dnf install terraform -y


sudo dnf --showduplicate list terraform


terraform version

Terraform v1.4.4

on linux_amd64


Ref:- install-terraform-on-centos-stream-9-server


Sunday, 19 February 2023

Linux Basic Commands - Tips and Tricks


#find the file responsible for ssh

which ssh

/usr/bin/ssh

rpm -qf /usr/bin/ssh


#find the rpm file and search for the config file.

rpm -qa | grep ssh

rpm -ql openssh-server-8.7p1-28.el9.x86_64


#set the port number

sudo vim /etc/ssh/sshd_config

#Port 22

systemctl reload sshd


#if not working disable SELinux

sudo cat /var/log/secure

getenforce

setenforce 0

systemctl reload/start sshd


#deny user

sudo vim /etc/ssh/sshd_config

DenyUsers tom


#list files with size

du -sch * | sort

du -sch * | sort -rn

du -sch * | sort -rn | head


#check the open port on the server

nmap -A 8.8.8.8


#to print all files in dir except 1st and 2nd files:  

ls -l | sed '1,3d'


#for deleting before 15 days file

find path_name -type f -mtime -15 -exec rm -rf {} +


#largest file in the directory

ls -lhS

ls -lhS | awk "NR==2"


#to delete blank lines of a file

sed  -i '/^$/d' file_name


#find a file with particular permission

sudo find /home/devops/ -type f -perm 775


#to see the hard-linked files in different locations

find / -xdev -samefile /tmp/abc.txt

sudo find / -xdev -inum 17375669


#to see the hard-linked files in pwd

ls -li

find -type f -links +1

 sudo find /home/devops/test/ -xdev -type f -links +1 -ls | sort -n


#7 fields in the password file

tail -n1 /etc/passwd

tom:x:1002:1003::/home/tom:/bin/bash

username:password hash:userid:groupid:info about user:home path: user shell


#reset tom user password, next login time

sudo chage -l tom

chage -d 0 tom


#change the shell of a user

tail -n1 /etc/passwd

tom:x:1002:1003::/home/tom:/sbin/nologin


sudo usermod -s /bin/bash tom


 cat /etc/passwd | grep tom

tom:x:1002:1003::/home/tom:/bin/bash


#change the home directory for a user

cat /etc/passwd | grep tom

tom:x:1002:1003::/home/tom:/bin/bash


sudo mkdir --mode=700 /opt/tom

sudo chown tom:tom /opt/tom/

sudo usermod -d /opt/tom tom


cat /etc/passwd | grep tom

tom:x:1002:1003::/opt/tom:/bin/bash


#change the default home directory for the future user

sudo vim /etc/default/useradd

HOME=/opt


sudo useradd nik

cat /etc/passwd | grep nik

nik:x:1003:1004::/opt/nik:/bin/bash


blkid - It can determine the type of content (e.g., filesystem or swap) that a block device holds.

lsblk - list block devices


Wednesday, 15 February 2023

Packaging Source Code inside the RPM Packages


Prepare build environment


yum install rpm-build

mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

tree rpmbuild

rpmbuild

├── BUILD

├── RPMS

├── SOURCES

├── SPECS

└── SRPMS


5 directories, 0 files


 echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros


Pull down the source code


cd rpmbuild/SOURCES/

curl -LO https://github.com/open-iscsi/rtslib-fb/archive/refs/tags/v2.1.74.tar.gz

tar -xzvf v2.1.74.tar.gz


yum install python-rtslib

mv rtslib-fb-2.1.74/ python-rtslib-2.1.fb74/

rm -rf v2.1.74.tar.gz

tar -zcvf python-rtslib-2.1.fb74.tar.gz python-rtslib-2.1.fb74/


#edit setup.py

setup (

    name = 'python-rtslib',

    version = '2.1.fb74',


yum install python-setuptools

python setup.py bdist_rpm --packager="Jojan Paul <jpmolekunnel@gmail.com>" --spec-only

cp dist/python-rtslib.spec ../../SPECS/

cd ../../SPECS/


#edit file

vim python-rtslib.spec

%description

python-rtslib


Build RPM


cd ~/rpmbuild/

rpmbuild -ba SPECS/python-rtslib.spec

cd RPMS/noarch

ls

python-rtslib-2.1.fb74-1.noarch.rpm


#test

yum install python-rtslib-2.1.fb74-1.noarch.rpm


Build RPM From Scratch in RHEL 9


cat /etc/redhat-release

CentOS Stream release 9


RPM:- Package Manager and the package format used by many Linux distributions such as Fedora, RedHat, and CentOS to manage and distribute software in binary form.


rpmbuild directory is known as the root directory for the rpm build environment

tree rpmbuild

rpmbuild

├── BUILD

├── RPMS

├── SOURCES

├── SPECS

└── SRPMS


BUILD        - directory, where the source code of the program want to package, is built

RPMS         - where the rpm packages generated

SOURCES   - have compressed source code of the software inthe form of a tarball or a zip file.

SPECS   - have a .spec file with instructions to build the package

SRPMS   - same as RPMS, but for source RPMS. these special packages contain the original source code of the application.


the spec file is where all instructions and information needed to build an rpm package are defined.


 Build RPM: Example to build an RPM Create a local yum repo.

#as root

yum repolist

yum install -y rpmdevtools rpm-build

mv /etc/yum.repos.d/centos.repo /tmp

yum repolist

ls -l /etc/yum.repos.d/


#su to user account (recommended)

rpmdev-setuptree

ls -l rpmbuild

tree rpmbuild

rpmbuild

├── BUILD

├── RPMS

├── SOURCES

├── SPECS

└── SRPMS


5 directories, 0 files


cd rpmbuild/SOURCES/

ls

mkdir -p localrepo-1/etc/yum.repos.d/

ls

localrepo-1


Mount RHEL 9 ISO File or DVD

sudo mkdir /var/repo

sudo mount -o loop rhel-baseos-9.0-x86_64-dvd.iso /var/repo/

sudo mount /dev/sr0 /var/repo/

vim localrepo-1/etc/yum.repos.d/RHEL9local.repo

[Local-BaseOS]

name=Red Hat Enterprise Linux 9 - BaseOS

metadata_expire=-1

gpgcheck=1

enabled=1

baseurl=file:///var/repo/BaseOS/

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[Local-AppStream]

name=Red Hat Enterprise Linux 9 - AppStream

metadata_expire=-1

gpgcheck=1

enabled=1

baseurl=file:///var/repo/AppStream/

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


 tar -cvzf localrepo-1.tar.gz localrepo-1/

localrepo-1/

localrepo-1/etc/

localrepo-1/etc/yum.repos.d/

localrepo-1/etc/yum.repos.d/RHEL9local.repo


cd ../SPECS/

ls

#create spec file

rpmdev-newspec localrepo.spec

localrepo.spec created; type minimal, rpm version >= 4.16.


 vim localrepo.spec

Name:           localrepo

Version:        1

Release:        0

Summary:        Local Repo For RHEL 9


Group:          System Environment/Base

License:        GPL

URL:            https://www.linuxmissive.com/

Source0:        localrepo-1.tar.gz

BuildArch:      noarch

BuildRoot:      %{_tmppath}/%{name}-buildroot


%description

Create a local yum repo file in /etc/yum.repos.d/ directory.


%prep

%setup -q


%install

mkdir -p "$RPM_BUILD_ROOT"

cp -R * "$RPM_BUILD_ROOT"


%clean

rm -rf $RPM_BUILD_ROOT


%files

%defattr(-,root,root,-)

/etc/yum.repos.d/RHEL9local.repo


%changelog

* Wed Feb 15 2023 Jojan Paul <jpmolekunnel@gmail.com>

-


cd 

#build now

rpmbuild -v -bb rpmbuild/SPECS/localrepo.spec

rpm -qpl rpmbuild/RPMS/noarch/localrepo-1-0.noarch.rpm 

/etc/yum.repos.d/RHEL9local.repo


#install rpm as root

su -

 rpm -ivh /home/devops/rpmbuild/RPMS/noarch/localrepo-1-0.noarch.rpm


rpm -qa | grep localrepo

localrepo-1-0.noarch


 cd /etc/yum.repos.d/

 ls

centos-addons.repo  RHEL9local.repo


#check yum repo working after installing rpm package

yum repolist

repo id                      repo name

Local-AppStream              Red Hat Enterprise Linux 9 - AppStream

Local-BaseOS                 Red Hat Enterprise Linux 9 - BaseOS

extras-common                CentOS Stream 9 - Extras packages


#test

yum install httpd


Monday, 23 January 2023

Install Chocolatey for Individual Use in Windows 11 PowerShell

 

Chocolay - Machine-level command line package manager


#set execution policy for powershell

PS C:\WINDOWS\system32> Get-ExecutionPolicy -List


        Scope ExecutionPolicy

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

MachinePolicy       Undefined

   UserPolicy       Undefined

      Process       Undefined

  CurrentUser       Undefined

 LocalMachine      Restricted


PS C:\WINDOWS\system32> Set-ExecutionPolicy AllSigned


Execution Policy Change

The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose

you to the security risks described in the about_Execution_Policies help topic at

https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y

PS C:\WINDOWS\system32> Get-ExecutionPolicy -List


        Scope ExecutionPolicy

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

MachinePolicy       Undefined

   UserPolicy       Undefined

      Process       Undefined

  CurrentUser       Undefined

 LocalMachine       AllSigned


Now run the following command:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

choco --version


Ref:- chocolatey.org


Sunday, 25 December 2022

Add Swap Space on CentOS 9 Stream


To Add 1GB Swap Space 


#create swap file

 sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

1048576+0 records in

1048576+0 records out

1073741824 bytes (1.1 GB, 1.0 GiB) copied, 19.8022 s, 54.2 MB/s


#set permission

sudo chmod 600 /swapfile


#set up swap area file

sudo mkswap /swapfile

Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)

no label, UUID=53c7c8d2-ed2d-4f61-b263-79a4dcd94304


#activate swap

 sudo swapon /swapfile


sudo swapon --show

NAME      TYPE       SIZE USED PRIO

/dev/dm-1 partition  2.1G   4M   -2

/swapfile file      1024M   0B   -3


sudo free -h

               total        used        free      shared  buff/cache   available

Mem:           1.7Gi       898Mi        69Mi        12Mi       970Mi       852Mi

Swap:          3.1Gi       4.0Mi       3.1Gi


#make permenant entry

sudo vim /etc/fstab

/swapfile swap swap defaults 0 0



Monday, 19 December 2022

How Kube-Proxy handles the traffic between the containers and the virtual machine by creating IP table rules in Kubernetes.


Demonstration


kubectl get svc





#to view any traffic sent to the IP sent to the following Rule

sudo iptables -S -t nat | grep IP





#inspect the rule





#the above rule diverts the traffic to the VM IP





#find the container using kube-apiserver

docker ps











#monitor kube-apiserver container

docker top container_id









#inspect the container to confirm IP used

docker inspect fcec33b58cbb | grep "address="

 





Tuesday, 13 December 2022

Configuring Jenkins ThinBackup and Restore


Create a backup directory 









Install Thinbackup Plugin










Navigate to ThinBackup and configure









Configure the settings


















Full backup happens every 5mins and Incremental backup every 2mins






Restore backup from the dropdown.








Backup any location

mkdir -p /opt/backup

chown -R jenkins:jenkins /opt/backup

ls -lsrt /opt/backup/

total 8

4 drwxr-xr-x 6 jenkins jenkins 4096 Dec 13 10:05 FULL-2022-12-13_10-05

4 drwxr-xr-x 3 jenkins jenkins 4096 Dec 13 10:06 DIFF-2022-12-13_10-06


Wednesday, 30 November 2022

Building Spring boot application manually and run it with the Docker Container


git clone https://github.com/callicoder/spring-boot-websocket-chat-demo.git

 cd spring-boot-websocket-chat-demo/

 cat Dockerfile

# Start with a base image containing Java runtime

FROM openjdk:11


# Add Maintainer Info

MAINTAINER Rajeev Kumar Singh <callicoder@gmail.com>


# Add a volume pointing to /tmp

VOLUME /tmp


# Make port 8080 available to the world outside this container

EXPOSE 8080


# The application's jar file

ARG JAR_FILE=target/websocket-demo-0.0.1-SNAPSHOT.jar


# Add the application's jar to the container

ADD ${JAR_FILE} websocket-demo.jar


# Run the jar file

ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/websocket-demo.jar"]


mvn clean package


sudo docker build -t webchat .


sudo docker images


sudo docker run -p 5000:8080 --name web_chat webchat


http://localhost:5000/


Building a Spring Boot application in Jenkins using pipeline Groovy script and run with Docker Container

 

This Jenkins job will be building the docker image from the Git repo.

Create a pipeline job with Jenkins and add Pipeline Script.

pipeline {

    agent any


    tools {

        // Install the Maven version configured as "M3" and add it to the path.

        maven "M3"

    }


    stages {

        

        stage('Preparation') {

            steps {

                // Get some code from a GitHub repository

                git 'https://github.com/callicoder/spring-boot-websocket-chat-demo.git'


            }

        }

        

        stage('Build') {

            steps {


                // To run Maven on a Windows agent, use

                sh "mvn -Dmaven.test.failure.ignore=true clean package"

            }

            


            post {

                // If Maven was able to run the tests, even if some of the test

                // failed, record the test results and archive the jar file.

                success {

                    junit '**/target/surefire-reports/TEST-*.xml'

                    archiveArtifacts 'target/*.jar'

                }

            }

        }

 stage('Docker Build') {

   

          steps {

          sh 'docker build -t spring-boot-websocket-chat-demo .'

          }

        }

        

         

        stage('Deploy') {

   

          steps {

               sh 'docker stop app_container'

               sh 'docker rm app_container'

          sh 'docker run -d -p 5001:8080 --name app_container spring-boot-websocket-chat-demo'

          }

        }

    }

}















Tuesday, 29 November 2022

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

 

Error: - While running pipeline groovy script to build a docker image for spring boot chat demo.

+ docker build -t spring-boot-websocket-chat-demo .
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&t=spring-boot-websocket-chat-demo&target=&ulimits=null&version=1": dial unix /var/run/docker.sock: connect: permission denied
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy)
Stage "Deploy" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
solution:- 
sudo chmod 777 /var/run/docker.sock

How to check a Linux system is Little endian or Big

Example from Ubuntu System

#lscpu

lscpu | grep Endian

lscpu | grep -i byte




#python3

python3 -c "import sys; print(sys.byteorder)"




#Example from a little-endian system

echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6

#using awk

echo -n I | od -to2 | awk '{ print substr($2,6,1); exit}'

echo -n I | od -to2 | awk 'FNR==1{ print substr($2,6,1)}'

#on all unix systems

echo I | tr -d [:space:] | od -to2 | head -n1 | awk '{print $2}' | cut -c6





#with hexdump

echo -n I | hexdump -o | awk '{ print substr($2,6,1); exit}'

hexdump -s 5 -n 1 -C /bin/busybox

hexdump -s 5 -n 1 /bin/sh





# apt install dpkg-dev on ubuntu

dpkg-architecture | grep -i end





#take advantage of ELF file format

xxd -c 1 -l 6 /bin/ls






Ref:- how-to-tell-if-a-linux-system-is-big-endian-or-little-endian


Wednesday, 23 November 2022

Build a Java Application with Jenkins in Docker


cat Dockerfile

from jenkins/jenkins:lts

USER root

RUN apt-get update -qq && apt-get install wget

RUN wget http://apache.cs.utah.edu/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz

RUN tar xzf apache-maven-3.8.6-bin.tar.gz -C /opt/

RUN ln -s /opt/apache-maven-3.8.6 /opt/maven

RUN ln -s /opt/maven/bin/mvn /usr/local/bin

RUN rm -f apache-maven-3.8.6-bin.tar.gz

ENV MAVEN_HOME /opt/maven

RUN chown -R jenkins:jenkins /opt/maven

RUN apt clean

USER jenkins


sudo docker image build -t jenkins-docker .


 sudo docker images

REPOSITORY        TAG       IMAGE ID       CREATED          SIZE

jenkins-docker    latest    ca1cb1129c7e   38 seconds ago   505MB

jenkins/jenkins   lts       25fa92c47840   8 days ago       463MB


sudo docker run -it -d -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock --restart unless-stopped jenkins-docker


sudo docker ps

CONTAINER ID   IMAGE            COMMAND                  CREATED         STATUS         PORTS                                                                                      NAMES

7333f25c2524   jenkins-docker   "/usr/bin/tini -- /u…"   4 minutes ago   Up 4 minutes   0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 0.0.0.0:50000->50000/tcp, :::50000->50000/tcp   silly_sanderson


http://localhost:8080/


#get the admin password




Jenkins global configurations

sudo docker exec -it 7333f25c2524 /bin/bash

jenkins@7333f25c2524:/$ mvn --version

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)

Maven home: /opt/maven

Java version: 11.0.16.1, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk

Default locale: en, platform encoding: UTF-8

OS name: "linux", version: "5.15.0-52-generic", arch: "amd64", family: "unix"

jenkins@7333f25c2524:/$ java --version

openjdk 11.0.16.1 2022-08-12

OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build 11.0.16.1+1)

OpenJDK 64-Bit Server VM Temurin-11.0.16.1+1 (build 11.0.16.1+1, mixed mode)































Execute shell commands in Jenkins by  Creating a Job



































Example using jenkins-docker-maven-github













    














Saturday, 2 July 2022

Basic Commands of Kubernetes


#Creating the Deployment

kubectl create deployment myapp2 --image=docker.io/openshift/hello-openshift

deployment.apps/myapp2 created


#Verify the Deployment and Pods’ states 

kubectl get po

NAME                      READY   STATUS    RESTARTS       AGE

myapp2-757cc77ff9-lnzwc   1/1     Running   0              8s


#describe Pod content

kubectl describe po  myapp2-757cc77ff9-lnzwc

Name:         myapp2-757cc77ff9-lnzwc

Namespace:    default

Priority:     0

Node:         node-2.example.com/172.31.55.63

Start Time:   Thu, 30 Jun 2022 22:52:42 +0000

Labels:       app=myapp2

              pod-template-hash=757cc77ff9

Annotations:  <none>

Status:       Running

IP:           10.36.0.5

IPs:

  IP:           10.36.0.5

Controlled By:  ReplicaSet/myapp2-757cc77ff9

Containers:

  hello-openshift:

    Container ID:   docker://f39e3bfb9b6b4cdf127dfd8368ec76610078d64c79516e70848b884d2e6e4be7

    Image:          docker.io/openshift/hello-openshift

    Image ID:       docker-pullable://openshift/hello-openshift@sha256:aaea76ff622d2f8bcb32e538e7b3cd0ef6d291953f3e7c9f556c1ba5baf47e2e

    Port:           <none>

    Host Port:      <none>

    State:          Running

      Started:      Thu, 30 Jun 2022 22:52:44 +0000

    Ready:          True

    Restart Count:  0

    Environment:    <none>

    Mounts:

      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-x5skk (ro)

Conditions:

  Type              Status

  Initialized       True 

  Ready             True 

  ContainersReady   True 

  PodScheduled      True 

Volumes:

  kube-api-access-x5skk:

    Type:                    Projected (a volume that contains injected data from multiple sources)

    TokenExpirationSeconds:  3607

    ConfigMapName:           kube-root-ca.crt

    ConfigMapOptional:       <nil>

    DownwardAPI:             true

QoS Class:                   BestEffort

Node-Selectors:              <none>

Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s

                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s

Events:

  Type    Reason     Age   From               Message

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

  Normal  Scheduled  98s   default-scheduler  Successfully assigned default/myapp2-757cc77ff9-lnzwc to node-2.example.com

  Normal  Pulling    98s   kubelet            Pulling image "docker.io/openshift/hello-openshift"

  Normal  Pulled     97s   kubelet            Successfully pulled image "docker.io/openshift/hello-openshift" in 827.570703ms

  Normal  Created    97s   kubelet            Created container hello-openshift

  Normal  Started    97s   kubelet            Started container hello-openshift


#to get running Deployment 

kubectl get deployment

NAME     READY   UP-TO-DATE   AVAILABLE   AGE

myapp2   1/1     1            1           4m14s


#to describe content

kubectl describe deployment myapp2

Name:                   myapp2

Namespace:              default

CreationTimestamp:      Thu, 30 Jun 2022 22:52:42 +0000

Labels:                 app=myapp2

Annotations:            deployment.kubernetes.io/revision: 1

Selector:               app=myapp2

Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable

StrategyType:           RollingUpdate

MinReadySeconds:        0

RollingUpdateStrategy:  25% max unavailable, 25% max surge

Pod Template:

  Labels:  app=myapp2

  Containers:

   hello-openshift:

    Image:        docker.io/openshift/hello-openshift

    Port:         <none>

    Host Port:    <none>

    Environment:  <none>

    Mounts:       <none>

  Volumes:        <none>

Conditions:

  Type           Status  Reason

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

  Available      True    MinimumReplicasAvailable

  Progressing    True    NewReplicaSetAvailable

OldReplicaSets:  <none>

NewReplicaSet:   myapp2-757cc77ff9 (1/1 replicas created)

Events:

  Type    Reason             Age   From                   Message

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

  Normal  ScalingReplicaSet  10m   deployment-controller  Scaled up replica set myapp2-757cc77ff9 to 1


#create a yaml file 

kubectl create deployment myhttpd --image=docker.io/httpd --dry-run=client -o yaml > mydep.yaml


cat mydep.yaml 

apiVersion: apps/v1

kind: Deployment

metadata:

  creationTimestamp: null

  labels:

    app: myhttpd

  name: myhttpd

spec:

  replicas: 1

  selector:

    matchLabels:

      app: myhttpd

  strategy: {}

  template:

    metadata:

      creationTimestamp: null

      labels:

        app: myhttpd

    spec:

      containers:

      - image: docker.io/httpd

        name: httpd

        resources: {}

status: {}


#Create the Deployment 

kubectl apply -f mydep.yaml 

deployment.apps/myhttpd created


kubectl get deployment

NAME                  READY   UP-TO-DATE   AVAILABLE   AGE

myhttpd               1/1     1            1           11s


#Expose the Deployment to create a service

kubectl expose deployment myhttpd --port=8080

service/myhttpd exposed


#Verify the created services

kubectl get svc

NAME                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE

kubernetes               ClusterIP   10.96.0.1        <none>        443/TCP        7d9h

myhttpd                  ClusterIP   10.110.234.236   <none>        8080/TCP       9s


#Describe the service 

kubectl describe svc myhttpd

Name:              myhttpd

Namespace:         default

Labels:            app=myhttpd

Annotations:       <none>

Selector:          app=myhttpd

Type:              ClusterIP

IP Family Policy:  SingleStack

IP Families:       IPv4

IP:                10.110.234.236

IPs:               10.110.234.236

Port:              <unset>  8080/TCP

TargetPort:        8080/TCP

Endpoints:         10.36.0.5:8080

Session Affinity:  None

Events:            <none>


Creating the namespaces


#create specific namespaces

kubectl create namespace mynamespace

namespace/mynamespace created


#Verify the namespace

kubectl get namespace

NAME              STATUS   AGE

default           Active   7d9h

kube-node-lease   Active   7d9h

kube-public       Active   7d9h

kube-system       Active   7d9h

mynamespace       Active   8s


Scaling and deleting the Deployment


#create a Deployment in a particular namespace

kubectl create deployment myhttpd --image=docker.io/httpd -n mynamespace

deployment.apps/myhttpd created


kubectl get deployment -n mynamespace

NAME      READY   UP-TO-DATE   AVAILABLE   AGE

myhttpd   1/1     1            1           2m39s


kubectl get pods -n mynamespace

NAME                       READY   STATUS    RESTARTS   AGE

myhttpd-78f86b45d5-pd2ph   1/1     Running   0          3m5s


#Scale the Deployment 

kubectl scale --replicas=3 deployment myhttpd -n  mynamespace

deployment.apps/myhttpd scaled


kubectl get deployment -n mynamespace

NAME      READY   UP-TO-DATE   AVAILABLE   AGE

myhttpd   3/3     3            3           4m49s


#get the endpoints

kubectl get endpoints

NAME                     ENDPOINTS                       AGE

kubernetes               172.31.54.141:6443              7d10h

myhttpd                  10.36.0.5:8080                  39m


kubectl describe endpoints

Name:         kubernetes

Namespace:    default

Labels:       endpointslice.kubernetes.io/skip-mirror=true

Annotations:  <none>

Subsets:

  Addresses:          172.31.54.141

  NotReadyAddresses:  <none>

  Ports:

    Name   Port  Protocol

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

    https  6443  TCP


Events:  <none>


Name:         myhttpd

Namespace:    default

Labels:       app=myhttpd

Annotations:  endpoints.kubernetes.io/last-change-trigger-time: 2022-07-03T01:32:13Z


Delete the created Pods, Deployment, service, and namespace 


kubectl delete deployment myhttpd

deployment.apps "myhttpd" deleted


kubectl delete svc myhttpd

service "myhttpd" deleted


kubectl get svc

NAME                     TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE

kubernetes               ClusterIP   10.96.0.1        <none>        443/TCP        7d10h


kubectl delete namespace mynamespace

namespace "mynamespace" deleted


#Verify the events 

kubectl get events

LAST SEEN   TYPE      REASON                    OBJECT                                          MESSAGE

57m         Normal    Starting                  node/main.example.com                         Starting kubelet.

57m         Normal    NodeHasSufficientMemory   node/main.example.com                         Node main.example.com status is now: NodeHasSufficientMemory

57m         Normal    NodeHasNoDiskPressure     node/main.example.com                         Node main.example.com status is now: NodeHasNoDiskPressure

57m         Normal    NodeHasSufficientPID      node/main.example.com                         Node main.example.com status is now: NodeHasSufficientPID

57m         Normal    NodeAllocatableEnforced   node/main.example.com                         Updated Node Allocatable limit across pods

<...>


#Verify the Nodes’ state 

kubectl get nodes

NAME                        STATUS   ROLES                  AGE     VERSION

node.example.com          Ready    control-plane,main   7d10h   v1.23.4

node-1.example.com   Ready    <none>                 7d10h   v1.23.4

node-2.example.com   Ready    <none>                 7d10h   v1.23.4


#describe Nodes’ 

kubectl describe node node-1.example.com

Name:               node-1.example.com

Roles:              <none>

Labels:             beta.kubernetes.io/arch=amd64

                    beta.kubernetes.io/os=linux

                    kubernetes.io/arch=amd64

                    kubernetes.io/hostname=worker-node-1.example.com

                    kubernetes.io/os=linux

Annotations:        kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock

                    node.alpha.kubernetes.io/ttl: 0

                    volumes.kubernetes.io/controller-managed-attach-detach: true

<...>


Thursday, 30 June 2022

Creating and Configuring the Deployment in Kubernetes using OpenShift


Creating the Deployment


kubectl create deployment myapp1 --image=docker.io/openshift/hello-openshift 

deployment.apps/myapp1 created


kubectl get deployment

NAME     READY   UP-TO-DATE   AVAILABLE   AGE

myapp1   1/1     1            1           14s


kubectl get po

NAME                     READY   STATUS    RESTARTS       AGE

myapp1-bcb89d7dd-hvxgk   1/1     Running   0              101s


Accessing the Pod


kubectl expose deployment myapp1 --port=8080

service/myapp1 exposed


kubectl get svc

NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE

kubernetes        ClusterIP   10.96.0.1       <none>        443/TCP        5d6h

myapp1            ClusterIP   10.111.40.120   <none>        8080/TCP       33s


curl 10.111.40.120:8080

Hello OpenShift!