Skip to main content

Command Palette

Search for a command to run...

Vish DevOpsMiniBytes

Vish's Quick BrainTuning to DevOps concepts

Updated
โ€ข4 min readโ€ขView as Markdown
Vish DevOpsMiniBytes
V

Hello reader, this is Vish currently working as a DevOps Engineer for the past 3+ years and a total of 9+ years of experience in the IT industry. Am passionate about learning DevOps and in the mission of enhancing my learning into container orchestration tools, monitoring and security.

Hi all, this blog consists of quick small concepts to revise/braintune the DevOps concepts. This blog can also be used for interview purposes where I would append with new content on regular basis.

1.โฐ๐—ฆ๐—ฒ๐˜/๐—–๐—ต๐—ฎ๐—ป๐—ด๐—ฒ ๐—ง๐—ถ๐—บ๐—ฒ ๐—ญ๐—ผ๐—ป๐—ฒ ๐—ผ๐—ณ ๐—ฎ ๐—Ÿ๐—ถ๐—ป๐˜‚๐˜… ๐— ๐—ฎ๐—ฐ๐—ต๐—ถ๐—ป๐—ฒ โฐ

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: timedatectl
๐Ÿ“ shows the current timezone with additional details related to datetime

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: timedatectl list-timezones
๐Ÿ“ used to list all the available timezones

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: timedatectl set-timezone Asia/Kolkata
๐Ÿ“ used to set the timezone Asia/Kolkata

No alt text provided for this image


2.๐Ÿ’ป ๐—Ÿ๐—ถ๐—บ๐—ถ๐˜ ๐—–๐—ฃ๐—จ & ๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜† ๐—ผ๐—ณ ๐——๐—ผ๐—ฐ๐—ธ๐—ฒ๐—ฟ ๐—–๐—ผ๐—ป๐˜๐—ฎ๐—ถ๐—ป๐—ฒ๐—ฟ โš™๏ธ

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ:
๐Ÿ’ป docker run -dt --name vish_cont --memory 100m --cpus 0.5 busybox
๐Ÿ“๐Ÿ“starts a container named ๐˜ƒ๐—ถ๐˜€๐—ต_๐—ฐ๐—ผ๐—ป๐˜ with ๐Ÿญ๐Ÿฌ๐Ÿฌ ๐— ๐—• of memory and ๐Ÿฌ.๐Ÿฑ ๐—ฐ๐—ผ๐—ฟ๐—ฒ๐˜€ of CPU

๐Ÿ”น๐—ฉ๐—ฎ๐—น๐—ถ๐—ฑ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ผ๐—ณ ๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†:
๐Ÿ’ป docker stats vish_cont
๐Ÿ“๐Ÿ“ shows the stats of the running container

๐Ÿ’ป docker exec -it vish_cont sh
๐Ÿ“๐Ÿ“ gets into the running container named vish_cont

๐Ÿ’ป cat /sys/fs/cgroup/memory.max
๐Ÿ“๐Ÿ“ shows the output max memory in bytes
๐Ÿ“๐Ÿ“๐Ÿ“ divide the number by 1024*1024 to get in MB

๐Ÿ”น๐—ฉ๐—ฎ๐—น๐—ถ๐—ฑ๐—ฎ๐˜๐—ถ๐—ผ๐—ป ๐—ผ๐—ณ ๐—–๐—ฃ๐—จ
๐Ÿ’ป docker exec -it vish_cont sh
๐Ÿ“๐Ÿ“ gets into the running container named vish_cont

๐Ÿ’ป cat /sys/fs/cgroup/cpu.max
๐Ÿ“๐Ÿ“ shows the output of the number of cores used
๐Ÿ“๐Ÿ“๐Ÿ“ divide the output first number with the second to get the number of cpu cores

No alt text provided for this image


3.๐Ÿ•’ ๐—–๐—ฟ๐—ผ๐—ป๐˜๐—ฎ๐—ฏ & ๐—–๐—ฟ๐—ผ๐—ป ๐—˜๐˜…๐—ฝ๐—ฟ๐—ฒ๐˜€๐˜€๐—ถ๐—ผ๐—ป๐Ÿ•’

๐Ÿ•’ ๐—–๐—ฟ๐—ผ๐—ป๐˜๐—ฎ๐—ฏ ๐Ÿ•’
๐Ÿ“๐Ÿ“ crontab aka ๐‘ช๐’“๐’๐’ ๐‘ป๐’‚๐’ƒ๐’๐’† is a configuration file to schedule & automate tasks

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: crontab -l
๐Ÿ“๐Ÿ“ used to list the available cron jobs scheduled

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: crontab -e
๐Ÿ“๐Ÿ“ used to list the available cron jobs scheduled

๐Ÿ•’ ๐—–๐—ฟ๐—ผ๐—ป ๐—˜๐˜…๐—ฝ๐—ฟ๐—ฒ๐˜€๐˜€๐—ถ๐—ผ๐—ป ๐Ÿ•’ - Refer post picture to understand the expression
๐Ÿ“๐Ÿ“ visit the website to generate cron expression - https://crontab.guru/

Cron Expression

* * * * * - Runs the command every minute


4.๐Ÿ” ๐—ค๐˜‚๐—ถ๐—ฐ๐—ธ๐—น๐˜† ๐—ฆ๐—ฒ๐—ฎ๐—ฟ๐—ฐ๐—ต ๐—™๐—ถ๐—น๐—ฒ๐˜€/๐—™๐—ผ๐—น๐—ฑ๐—ฒ๐—ฟ๐˜€ ๐˜‚๐˜€๐—ถ๐—ป๐—ด ๐—Ÿ๐—ผ๐—ฐ๐—ฎ๐˜๐—ฒ ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ ๐Ÿ”

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: sudo apt install plocate
๐Ÿ“๐Ÿ“ install the plocate on debian based systems

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: updatedb
๐Ÿ“๐Ÿ“ updates the database that locate uses
๐Ÿ“๐Ÿ“๐Ÿ“ locate is faster because it uses this prebuilt database instead of filesystem

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: locate <file/folder pattern>
๐Ÿ“๐Ÿ“ used to quickly find location of files and directories
๐Ÿ“๐Ÿ“๐Ÿ“ returns the absolute path of the file/folder mentioned
๐Ÿ“๐Ÿ“๐Ÿ“๐Ÿ“ example: locate add.txt, locate *.tar

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: locate -i <file/folder pattern>
๐Ÿ“๐Ÿ“ case insenstive search

No alt text provided for this image


5.๐Ÿ”ข ๐—ง๐—ฒ๐—ฟ๐—ฟ๐—ฎ๐—ณ๐—ผ๐—ฟ๐—บ ๐—ฉ๐—ฎ๐—ฟ๐—ถ๐—ฎ๐—ฏ๐—น๐—ฒ ๐—ข๐—ฟ๐—ฑ๐—ฒ๐—ฟ ๐—ผ๐—ณ ๐—ฃ๐—ฟ๐—ฒ๐—ฐ๐—ฒ๐—ฑ๐—ฒ๐—ป๐—ฐ๐—ฒ ๐Ÿ”ข

Terraform variables take the following precedence:
๐Ÿ”น Environment Variables
๐Ÿ“๐Ÿ“ terraform environment variables starts with TF_VAR_<variableName>

๐Ÿ”น Variable Defaults
๐Ÿ“๐Ÿ“ variable blocks consisting the default value

๐Ÿ”น Terraform tfvars (terraform.tfvars)
๐Ÿ“๐Ÿ“ seperate file named terraform.tfvars with variables defined

๐Ÿ”น CLI (using -var and -var-file)
๐Ÿ“๐Ÿ“ passing variable name (-var=<varName=varValue>)
๐Ÿ“๐Ÿ“ passing variable filename (-var-file=<fileNmae>)


6.โŒจ๏ธ ๐— ๐˜† ๐—ณ๐—ฟ๐—ฒ๐—พ๐˜‚๐—ฒ๐—ป๐˜๐—น๐˜† ๐˜‚๐˜€๐—ฒ๐—ฑ ๐˜ƒ๐—ถ ๐—ฒ๐—ฑ๐—ถ๐˜๐—ผ๐—ฟ ๐—ธ๐—ฒ๐˜†๐—ฏ๐—ผ๐—ฎ๐—ฟ๐—ฑ ๐˜€๐—ต๐—ผ๐—ฟ๐˜๐—ฐ๐˜‚๐˜๐˜€ โŒจ๏ธ

๐Ÿ“ ๐—–๐˜‚๐—ฟ๐˜€๐—ผ๐—ฟ ๐—ข๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€
๐Ÿ”นMove cursor to start of the line - "๐—ด๐—ด"
๐Ÿ”นMove cursor to end of the line - "๐˜€๐—ต๐—ถ๐—ณ๐˜ + ๐—ด"

๐Ÿ“ ๐—™๐—ถ๐—ป๐—ฑ & ๐—ฅ๐—ฒ๐—ฝ๐—น๐—ฎ๐—ฐ๐—ฒ ๐—ข๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€
๐Ÿ”นSearch for a pattern & move cursor to it - "/<๐˜€๐—ฒ๐—ฎ๐—ฟ๐—ฐ๐—ต๐—ฃ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ๐—ป>"
๐Ÿ”นFind & replace old text to new text - ":%๐˜€/๐—ผ๐—น๐—ฑ๐—ง๐—ฒ๐˜…๐˜/๐—ป๐—ฒ๐˜„๐—ง๐—ฒ๐˜…๐˜"

๐Ÿ“ ๐——๐—ฒ๐—น๐—ฒ๐˜๐—ฒ ๐—ข๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€
๐Ÿ”นDelete the current line - "๐—ฑ๐—ฑ"
๐Ÿ”นDelete all contents of file - "๐—ด๐—ด ๐—ฑ๐—š"
๐Ÿ”นDelete current line & next desired number of lines - "๐—ฑ<๐—ป๐˜‚๐—บ๐—ฏ๐—ฒ๐—ฟ๐—ข๐—ณ๐—Ÿ๐—ถ๐—ป๐—ฒ๐˜€>"

๐Ÿ“ ๐— ๐—ถ๐˜€๐—ฐ ๐—ข๐—ฝ๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐˜€
๐Ÿ”นUndo the operation - "๐˜‚"
๐Ÿ”นSet the line numbers - ":๐˜€๐—ฒ๐˜ ๐—ป๐˜‚"


7.๐Ÿ› ๏ธ ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ ๐—–๐—น๐—ผ๐˜‚๐—ฑ๐—ช๐—ฎ๐˜๐—ฐ๐—ต ๐—”๐—น๐—ฎ๐—ฟ๐—บ ๐—ณ๐—ผ๐—ฟ ๐˜๐—ฒ๐˜€๐˜๐—ถ๐—ป๐—ด ๐Ÿ› ๏ธ

๐Ÿ”น ๐—–๐—ผ๐—บ๐—บ๐—ฎ๐—ป๐—ฑ: Using AWS CLI
๐Ÿ“๐Ÿ“ aws cloudwatch set-alarm-state --alarm-name "VishCPU_70" --state-value ALARM --state-reason "Testing Vish Alarm"
๐Ÿ“๐Ÿ“๐Ÿ“ This helps in quickly testing the alarm when the threshold is not reached.
๐Ÿ“๐Ÿ“๐Ÿ“๐Ÿ“ Sets the VishCPU_70 alarm to ALARM state and can send notifications based on the alarm configured.

๐—˜๐˜…๐˜๐—ฟ๐—ฎ๐˜€:
๐—”๐—น๐—ฎ๐—ฟ๐—บ ๐—ฆ๐˜๐—ฎ๐˜๐—ฒ๐˜€:
๐—ข๐—ž ๐—ฆ๐˜๐—ฎ๐˜๐—ฒ - alarm is within the threshold defined
๐—”๐—Ÿ๐—”๐—ฅ๐—  ๐—ฆ๐˜๐—ฎ๐˜๐—ฒ - alarm crossed the threshold defined
๐—œ๐—ก๐—ฆ๐—จ๐—™๐—™๐—œ๐—–๐—œ๐—˜๐—ก๐—ง_๐——๐—”๐—ง๐—” ๐—ฆ๐˜๐—ฎ๐˜๐—ฒ - Dont have much data to trigger the alarm


#DevOpsMiniBytes#VishDevOpsMiniBytes #CICD#ContinuousIntegration#ContinuousDeployment#ContinuosDelivery #DevOps#DevSecOps#GitOps#Agile#DevOpsCommunity #AWS#Cloud#Azure#GCP#CloudComputing#CloudNative #Monitoring#Observability#SRE#Prometheus#Grafana #Nexus#Ansible#GitHub#GitHubActions#GitLab #Docker#Kubernetes#K8s#CloudNative#Helm #Linux#Bash#Shell#Scripting#Automation #Jenkins#Pipeline#JenkinsFile#Groovy #OWASP#Trivy#DependencyScan #Java#Python#NodeJS#Gradle #Terraform#InfraProvisioning #BrainTuning