Monday, September 5, 2022

helm commands


helm -h --- help command
helm completion bash --- to display the output of
helm list ---- to display the version
helm create (name) ---- to create the helm chart
helm depandency build (folder name) ---- to build the
helm dep list (name) ---- to list the dependency
helm dep update (dir name) --- it will update
helm dep update (dir name) ---- it will update
helm env ----- to display the helm environment
helm get (all,hooks,values,notes,manifest) (name) ---- to display the information
helm install (name) (dir helm name) (opction --set (name=value))
helm history (name) ---- to display the history
helm del (kube-name) (helm name) ---- delete the chart
helm lint (chart name) ---- check the error to
helm ls ---- to list the helm pakages
helm pakage (name) ----- to convert into compressed file
helm diff upgrade (kub name) ( helm name) --
helm pull (chart name) ---- to pull the helm
helm repo add
helm repo update
helm repo remove
helm rollback (name) 1 ---- to create another one
helm search hub (name) --- to search the chart
helm search repo (name) --- to search the chart
helm status name
helm install --debug --dry-run (relese-name) (chart folder) ---- to
helm get manifest (relese-name) ---- to display the set
helm install --dry-run --debug --set costCode=SS45877
sai ./mychart/ --- to set from input using set

--set (name=value)
sprig library to use function on helm

{{ .Values.data}} ---- to pass the value from the

{{- if eq .Values.data "us-e" }}
style: true
{{- end }} ---- to use (-) in starting


{{- with .Values.tags }}
{{- toYaml . | nindent 2 }} --- to
machine: {{ .machine }}
{{- end }}
------ doesn't use the multiple line

notes.txt ---- is used to write a commands in
helm template sai ./mychart --- to display the template
helm get values name --- to get a used
helm history name --- to display error and log
--atomic ---- when chat goes error it forward to
--timeout 7m3s ---- to control the time out
--fource --- when upgrade happend it will stop all
--cleanup-on-failure --- when upgrade goes fail total fail log

chart.yaml {
apiVersion:
name:
description:
icon:
keywords:
home:
sources:
maintainers:
}
helm package name ----- to convert into zip file
helm lint name ---- to check the error log

functions{
- to avoid a blank spaces
include --- to use pipeline
qoutes
template
upper
default
nindent 4 --- new line with indent of 4
}

define variable
{{ $myValue := "sai" }} --- assign a value
{{ $myValue = "gok" }} --- reassign a value
{{-if myValue }}

for loop
{{- range .Values.mychart.contry }}
{{ . | upper | qoutes }}
{{- end }}

for loop disnory
{{ - range $key, $value := .Values.image }}
- {{ $key }}: {{ $value }}
{{- end }}

helm get manifest name ---- to see the detail
helm depandency update name ---- to update depandencny on

kubernets commands


kubectl run ngix --image=(img name) --- run the pods

kubectl get pods ---- to check the pod's details

kubectl describe pod (image name) --- details the pod

kubectl get nodes --- to display the nodes

kubectl get pods -o wide ---- to display the

kubectl create deployment (name) ---- create deployment

kubectl edit deployment (name) --- edit deployment

kubectl delete deployment (name) --- delete deployment

status of different k8s components
kubectl get nodes | pod | services | replicaset

kubectl delete pod (podname) --- to delete a single

kubectl logs (pod name) --- log to console

kubectl exec -it (pod name) --- bin/bash -- get

yml:
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app:
spec:
container:
- name: nginx-con
image: nginx

kubectl create -f pod-definition.yml ---- to create k8s yml

kubectl apply -f pod.yml ---- same as create command

kubectl run nginx --image=nginx --- to create an image

kubectl describe pod (pod name) ---- to check the

kubectl delete pod (pod name) --- to delete the

kubectl run nginx --image=nginx --dry-run=client -o yaml > pod.yaml

kubectl edit pod (name) --- to edit the configuration

kubectl get replicationcontroller ------ to see the replication on

kubectl replace -f replica.yml ------ to replace the file

kubectl scale --replicas=6 -f replica.yml ----- another way to

kubectl get rs ----- to display the replicasets

kubectl describe pods ----- to display the error on

kubectl create -f /root/replicaset-definition-1.yaml ---- to locate in root

kubectl scale rs new-replica-set --replicas=5 ---- to replica 5

kubectl get all --- to see all commands thats

kubectl get deployments ---- to get the deployments

kubectl set image deployment

kubectl rollout status deployment ----- to check the status

kubectl rollout history deployment ----- to check the history

kubectl rollout undo deployment ----- to undo the rollout

kubectl get svc ---- to list the service where

kubectl describe svc kubernetes ----- to display the port

master node
-api server ---- for all communication
-scheduler ----- schedules pods on nodes
-controller manager ---- runs controllers
-etcd --- open source , distributed key-value database from

worker node
-kubelet
-kube-proxy
-container runtime

use kind commends
kind create cluster --name (sai)
kind delete cluster --name (sai)

minikube service (name) --url ---- to print the ip

kubectl get pod name -o yaml | more -----

kubectl get pod name -o wide ----- to display

kubectl exec -it name -- /bin/sh ----- to run

kubectl delete pod name ---- to delete the pod

container communicate with another container using localhost:port using network

pod communicate with another pod using eathernet device using

node communicate with another node using route table with

nodeePort range --- 30000 to 32767

clusterip ---- used to communicate with application a and

application a call from node port application b send

ingress is used to connect with nodeports on mapping

networking{
cluster-ip ----- is a virtual ip
node port

docker commands


con = container
Docker run con name ---- run the container
docker create con name --- create a con
docker start -a con name ---- to start a
docker system prune ---- to show the stop, build
docker ps --- current running container
docker ps -a --- all docker container
docker stop con name --- stop the container
docker kill con name --- kill the container
docker rm con name --- remove the container
docker images -- display all images
docker rmi con name ---remove the docker images
docker pull image name --- pull the docker image
docker exec con name --- execute the docker container
docker run con name --name (defult) --- to mentain
docker run -d con name --- run the con
docker attach name --- attach the docker id uniq
docker run -d con name sleep (sec) --- to
docker version --- to identify the version of the
docker run -p 8080:3456 con name -- port mapping
docker inspect con name --- display the details in
docker logs con name --- display the logs of
docker run img name: version --- to run the
docker build. --- build the docker images
docker build. -t image name --- build and mention
docker history con name ---- to see the history
cat /root/{app-name}/Dockerfile --- to see the image of the
docker run redis --- to run the server
docker exec -it con id redis-cli ---- to run
docker exec -it con name sh, bash, Powershell, zsh
docker commit -c 'CMD ["comment"]' con id ---- to
docker run -t -d -v /home/Krrish/Desktop/sampledir/:/var/www/html --name good day
WORKDIR /usr/app --- work dir app
docker-compose up -d ---- to start a multiple containers
docker-compose down ---- to stop a multiple containers
docker-compose up --build ---- to rebuild the container
restart type = no, always, on-failure, unless-stoped
docker build -f Dockerfile.dev . --- to build any
docker run -p 3000:3000 -v $(pwd):/app con name ----
docker run -p 3000:3000 -v /app/node_modeules -v $(pwd):/app con


network{
default bridge ---- default 172.17.0.1
custom bridge ---- 172.18.0.1 isolated
host ----- connect with host ip without define ports
macvlan ---- it also asign like a vm and
ipvlan --- connect with host and the macvlan
}

Shell Scripting


cat /etc/shells ---- to display total shells in our
sleep (sec) ----- to sleep and run
$? --- when code is succesfull it return 0
$1 ---- to get a input in same line
echo ${#variable} ---- to display the string count
set -x ---- to print with an command
set -n ---- to debug the code while running
set -e ---- to stop the while code in

grep{
grep -v "#" ---- to grep the details except
grep -i string ---- to remove the case sencitive
grep -w ---- match exact word
grep -v --- to print execpt that line
grep -o --- to print exact word only
grep -n --- to match the line number
grep -c ---- to match the line count
grep -A "string" 1 --- the string is match
grep -B "string" 2 --- the string is match
grep -C 1 "string" --- before and after print
grep -r "string" * --- to search n a
grep -l "string" --- to print only file names
grep -h "sting" --- to hide the file name
grep -f file filename --- to search from a
grep -E "string|srting|string" --- check with a multiple string
grep "^string" --- to print the starting line with
grep "string$" ---- to printthe match word with the
grep "^$" filename --- to match with an empty
grep "\^" --- print the exact word on it
grep "t...e" --- to match with first and last
grep "\bline\b" --- to print the word and end
grep "yf?" --- the f in the string is
grep "yf*" ---- have f or mor time
grep "[yft]" ---- split with an multiple char
grep "yf+" --- the f in the string is
grep "[a-f]" --- to search with a char to
grep "[a-dp-r]" --- to print with a secquance word
grep "^[xy]" --- to print the line it starting
grep "x{4}" --- check with 4 times
grep "gf{3,4}\b" --- 3 , 4 time only
grep "[[:digit:]] filename --- to print the number where
grep "[[:upper:]] filename --- to print the upper case
grep "[[:lower:]] filename --- to print the lower case
}

jq{
cat filename | jq '.' --- display in a
cat filename | jq -c '.[]' --- display output
}

cut{
cut -f 2 filename ---- to seprate with the
cut -d ':' -f 2,4 filename ---- to filter
cut -d ':' -1,4 filename --output-delimiter=" " ---- to
cut -sf 1 filename ---- to execute with wich

}
awk{
awk ' /version/ { print $4 } ---- to
awk ' NR==1 { print $4 } ---- to
awk -F '[ /]' '/version { print $4 }
awk 'BEGIN { OFS="_" } { print $1,$3 }
awk ' { print NR,$4 } ---- to print
awk ' { print NR,$4,NF } ---- to print
awk ' { print $NF } ---- to print
awk '{ print substr( $1, 3, 1 ) }'
}

tr{
tr '[:upper:]' '[:lower:]' < filename ---- convert upper to
tr 'i' 'I' < filename ---- change the letter
tr -d ',' ---- to delete a command
tr -d '[()]' ---- to delete a multiple command
}

sed {
sed ' ' filename ---- to work like a
sed -n '3p' filename ------- to print exact line
sed -n '3,10p' filename ---- to print in a
sed -n '3,+7p' filename ---- to print a count
sed -n '3~7p' filename ---- to print 3,7,10,13 count
sed '4d' filename ----- to delete 4 line doesn't
sed -i '4,6d' filename ---- to remove the value

}
if [ $num1 -gt $num2 -o $num3 -lt $num4
if [[ $num1 -gt $num2 || $num3 -lt $num4
if (( $num1 > $num2 )) --- use simples

$(whoami) ----- to use the defalt command method
echo $SHELL --- to display the current shell is
ps $$ --- to display the current shell is
ctrl + u ---- to erase the complete line
ctrl + w --- to remove the particular word
type -a (command name) --- to identify the command
#!/bin/bash --- to mention the execute path
chmod +x filename ---- to change the permission of
./filename ---- to execute the file from the terminal
#!/usr/bin/env bash --- to create a env on our
# ---- single line command
<<(mention any word ending with the same name) -----
example
< dkgjkndklgj
dogged
SAMPLE ---- to end it
variables two type
-system
upper case
env
- user-defined
lowercase
var="sai"
echo $var --- to print the output
don't use space to declare the variable
case sensitive
${var}var ---- use { } to decular the variable
echo "hello world $(whoami)" --- to execute the shell
echo 'hello world $HOME' --- doesn't execute the script
\ --- to work like a single qoutes
ls \ && pwd --- to use a multi
unset SAMPLE --- to un set delete variable
read -p "ENTER USER NAME:" (variable) --- to input
(-p) -- prompt
(-t) --- time out input
(-s) --- password input doesn't input
echo $variable ---- to print the user name
echo $(( 1+1 )) --- to use operation +,-
declare -i int=100 ---- to decule a integer data
readony variable ----- used to doesn't change the value
${newvariable?errormessage} ---- to identiye a decular variable
alias --- to set our own command
PS1="TERMINAL" ---- to change our own terminal command
PS1="\u@defined name" ---- to custom our terminal
echo $? --- to check the previes command state
test 10 -gt 5 && echo "10 is greater"
[ 10 -gt 15 ] ---- same like a
((10<15)) --- same like that

if and elif condition
if [ 10 -gt 5 ]
then
echo "10 is greater"
elif [ 10 -gt 20 ]
then
echo "equal"
else
echo "not"
fi

number comparisons
gt --- gather than <
lt---- less than >
ge --- greater or equal to <=
le --- less than or equal to >=
eq ---- equal to =
ne ---- not equal to !=
-a --- and &
-o --- or |

array
x=(1 3 5 "sai")
echo "${x[*]}" ---- print all number

string comparisons
=
!=
-z ---- not null value check

file comparisons
-b
-c
-d ---- to check a directory
-f ---- to check a regular file

cli position
echo $0 --- correct script variable
echo $IFS ---- tab char
cat -stv <<< $IFS --- to display non printable

case statements switch case

case $var in
"sai") echo "in side " ;;
"nmap") "scan tool" ;;
*) echo "no value" ll
esac

loops

for
in
(())
for x in 1 2 3 4 5 6
do
echo $x
done

for (( i=1; i < 10 ; i++ ))
do
for(( j=1 ; j < 10 ; j++ ))
do
echo ${i}${j} || printf "\n"
done
done
-----------
while
while [ expression ]
do
....
done

while :
do
.....
done ----- infinity loop syntex
-------------
--function--

function sai(){
echo good boy;
}
sai;
sai;
------------


my=0
while :
do
read -p "value : " my
if [[ $my -eq 0 ]]
then
echo "running"
else

-----
while get input from another file
while IFS="," read f1 f2 f3 f4
do
echo "$f2"
done < filename
----
input two value and print it
read x;
read y;
echo $((x+y));
echo $((x-y));
echo $((x*y));
echo $((x/y));

Sunday, May 8, 2022

Linux-Bash commands


cd -- change dir
ls -- list
command -- --- stdin
command -- --- stdout
command -- --- stderr
PWD -- present working dir
ln -- hard and soft link
rm -- remove
mv -- move,rename
cp -- copy
more -- to see file in screen size
more -- --- to see first two numbers
more -- --- to see after 4 numbers
chmod -- change the read-write execute permission
grep -- seprate the same value
whoami -- what user
whatis -- to known the command discription
man -- to know how to use the
wget -- create an HTTP link and download
exit -- exit from the terminal
zip -- file ---- zip the file
unzip -- --- unzip the file
ifconfig -- ipaddressoo
nano -- open the text editor
touch -- create a normal file
cat -- read the text file
mkdir -- create directory
ping -- check IP live or dead
sudo -- --- root user
ps -- a run process
top -- running task
head -- ---- to display first 5 number
tail -- --- to print last 4 line
sed -- '6,12p' filename --- to print condition
locate -- locate the path
nslookup -- domain IP address
whois -- domain name
file -- file type
mkdir -- make dir
rmdir -- remove dir
\ -- create a file with space
Alt+F -- move between words
Alt+B -- move back between words
ctrl+c -- copy
ctrl+v -- paste
ctrl+L -- clear
Alt+u -- change capital
Alt+l -- change lower
ctrl+k -- cut letter
ctrl+y -- paste the words
ctrl+r -- to suggest the recent values
cal -- calendar
date -- current date
poweroff -- shutdown
reboot -- system reboot
vi -- text edit
gedit -- grapical text editer
history -- history commands
less -- same as cat
tac -- same as a cat
head -- to display the top 10 line
tail -- to display the bottom 10 line
WC -- line num, word num, byte num
type -- command type
which -- to mention the part of the
help -- to help the command process
man -- it is used to listing the
• -- everything
alias -- to create a new command alias
hostname -- IP address
netstat -- network connection, routing tables
traceroute -- routes and hops used by packet
time -- --- user and system time used
& -- to do more than one operation
; -- one operation completes then the other
echo -- --- status of last executed command
&& -- if the first operation success the
// -- if the first operation fails also
| -- op of one command is passed
> -- to pass op of one to
sudo -- --- display current run level(0-6)
mount -- to attach external filesystem to filesystem
umount -- detaches the external file system from
awk -- scripting language for file modification and
ping -- name) ---- ping and find the
nc -- address port num ---- to get
[GET -- HTTP/1.1] --- to enroll the data
[HEAD -- --- to enroll the head data
[OPTIONS -- HTTP/1.1] ---- to see the options
dig -- name ---- to identify the IP
sudo -- -m (name) --- to add a
sudo -- (name) ---- to set the password
sudo -- (name) --- to create a group
sudo -- -a -G (group-name) (user-name) ----- to
getfacl -- --- to display the all deatils
sudo -- ---- to display the network speed
sudo -- - username --- to change the
sudo -- allow/status/enable (port-nun)
sudo -- -tupln ---- to see the active
"$(date --
chsh -- to change the shell
vi -- number --- to display number in
cat -- filename --- to display the number
dir{ --
/ -- root dir
/home -- to split the different user home
/var -- to store the log fille
/etc -- to store the configu file
/temp -- to store the temp files
/opt -- storing thrid pary app
/lib -- store library file
/root -- admin/high privilages
/bin -- binary files
/dev -- show extral device
} --

Tuesday, January 11, 2022

Bash script to automate and detect and scan your local networks

# Bash-Script-to-Automatically-Detect-and-Scan-Your-Local-Network

Using bash script to find the open ports in the local networks


using nmap and shell 

How to run the code


-> sudo apt-get install git

-> git clone https://github.com/krishnansai/Bash-Script-to-Automatically-Detect-and-Scan-Your-Local-Network


-> cd Bash-Script-to-Automatically-Detect-and-Scan-Your-Local-Network

-> chmod +x *


-> sudo ./network_scan.sh




Thursday, January 6, 2022

How To Disable Unwanted ports in linux using Terminal

kill the open ports in the linux First We want to install nmap tool for scaning the open port on the terminal => sudo apt-get install nmap After install the nmap on terminal and scan the open port using this commands => nmap -vvv localhost
After that u can see the all open ports for example i can kill the 9050 port using this commands =>sudo nmap -k 9050/tcp it will kill the port
have a Great Day

Argocd with rollouts examples

examples in My github https://github.com/krishnansai/argocd-rollouts.git ArogoCd with ArgoRollouts Rollouts.yml # This example demonst...