Devops Flashcards
What is devops?
It’s a practice or culture adopted by your organization, that would increase your organization’s ability to deliver applications(Continuous delivery)
But is devops only about improving delivery? No
1. Improving delivery
2. Automation - Deliver more chips
3. Quality - Customer cares about this
4. Monitoring - How do you make sure automation and quality is being maintained? You have to build in monitoring. So whenever there’s an issue, someone has to report back to us. This is done by monitoring.
5. Testing - Without testing, we cannot ensure that the quality or automation is correct.
So the proper definition is - Devops is a process of improving your application delivery by ensuring that there is a proper automation, the application quality is maintained, ensure there is continuous monitoring and continuous testing in place. So this is devops.
What do we achieve with all these things? - As a devops engineer, your goal is to ensure there should not be any manual process or during your application delivery, you have to fasten your delivery process.
Why Devops?
To improve the process of delivery. when there were bare metal servers, it used to take many days to deploy and multiple people were involved in the process. It’s a manual process with server admin, system admin, build and release engineer and few other people. To speed up and automate this process, we adopted devops.
As a devops engineer, I’m focused on automating and improving the building, testing and deployment phase. There should not be any manual intervention.
How to introduce yourself as a devops engineer?
- Im working as a java + devops engineer from 5 yrs.
- Current Roles and responsibilities - I take care of automation, quality, monitoring. I have automated the testing process into the devops lifecycle.
What is SDLC?
It’s a culture/ methodology to design, develop and test the application. The end goal is to deliver a high quality product.
Stages:
Planning - Requirements. BA does this
Defining - Documenting
Designing - High level and low level design
Building
Testing
Deploying
What is hypervisor?
A software that can install VM’s on your computer/bare metal servers.
It does logical isolation/separation on the server.
Each VM has its own portion of CPU, hardware and memory
You can automate the creation of VM’s or EC2 instances through AWS CLI. What are other ways?
- AWS API. In Python, using Boto3 module you can directly make a request to the AWS API.
- AWS CFT - Cloud Formation Template. If you provide this template to AWS, it will return you with 1 to n number of VM’s you’ve requested.
- AWS CDK - Cloud Development Kit
- There’s a great competitor available in market to automate your resource creation - Terraform.
1 terraform - multiple cloud providers
How do you create 10 vm’s at once/ what is the automation that you’re using in your organization for infrastructure creation?
Terraform or AWS. Look at your organization and determine what you use. If your org is completely focused on AWS, the you don’t have to use terraform. You can either use AWS CLI, API, CFT or CDK
When is Terraform used?
Orgs these days are using hybrid cloud pattern. So they have their VM’s in one cloud platform, other resource infrastructure in other cloud platform. In this model, terraform is best for you, coz you have to automate the infra across different cloud platforms
What is Kernel?
Kernel is heart of the OS. Its responsibility is to establish a communication between your hardware and software. It has 4 responsibilities.
1. Device Management
2. Memory Management
3. Process management
4. Handling system calls
It cascades the requests from s/w to h/w and back to h/w.
Components in Linux
Down to Top
OS - Kernel - System Libraries - compilers| User processes | system software
Why Linux is preferred in Prod?
Lightweight, so Fast
Free (OSS)
Secure
Shell commands
! - this is called shebang. This is the first thing you write in a shell script.
Rename or move - mv file file
free -g : see memory of your server
nproc : count of CPU’s
df/df -h : disk size
Top : see all the above info with one command
man ls/ man touch : open manual for any command you want to reference .
chmod- grants permissions to a file
chmod. What are the permissions for admin user, What are the permissions for group, What are the permissions for all users?
chmod 777 - access for everybody
Find command - important command used in devops. It searches entire system.
sudo find / -name pam
Kill Java process - kill -9 processId
Linux uses 421 - 4 for read, 2 for write, 1 for execute.
What’s the purpose of writing a shebang? - to tell the kernel which interpreter should be used to run the commands present in the file.
What is shell scripting?
A process for automating your daily activities on your Linux computer
Command to execute a shell script
./file.sh
Or
sh file.sh
Where is shell scripting used?
As a devops engineer, you maintain all the Infrastructure, code repositories and do a lot of configuration management. For all these activities, on a day to day basis, you use shell scripting.
On a single automation, what a user expects is, you have to login to a specific machine where ansible automation is present and you have to execute the ansible automation.
Why are you using shell scripting?
To automate node health of my VM’s. We have close to 1000 VM’s and every time it is difficult to monitor the health or status of these VM’s, so I write shell scripts for that.
There are many automated tools, so why do you want to write shell scripting?
You can say ‘In our org, we’re not using any such tools
Or
These tools are restricted have restricted number of parameters, but the scripts can fetch more parameters that are not provided by these tools.
Other Shell scripting use cases
Infrastructure automation
Configuration management
Amazon example
Day to day activities monitoring - you want to monitor specific tools and send email notifications - we can use shell scripting
I/Q: How do you write script to monitor node health? / How do you monitor node health?
I can use the ‘top’ command or I can write custom shell scripts that monitor CPU and Ram usage.
Good practices and how to write shell script in a scructured manner.
- Start with shebang followed by the executable that we want to use- #!/bin/bash
- Metadata of the file like author name, date etc.
- Set -x #debug mode
- Set -e #exit script when there is error (set -e has a drawback. It doesn’t error out when there’s a pipe. So we have to use the below command when using pipe.
- Set -o #pipefail when there is a pipe
Shell command to find processes and process id’s?
ps
ps -ef
To filter for Amazon processes only - use grep
ps -ef | grep “Amazon”
What does the pipe parameter do?
To use it with grep command -
ps -ef | grep “Amazon”
./test.sh | grep 1
Pipe parameter sends the output of first command to second command.
I/Q: What will be the output of
date | echo “this” ?
It will print “this”, coz date is a system default command. It sends the output to stdin. And pipe won’t receive output from stdin. Pipe can only receive information if the command is not sending information to stdin and if the command is ready to pass the information to the next command .
Awk command
If you want to retrieve only a specific column from the result, then use awk.
It can filter out information from the output.
cat test.sh | grep Sandeep | awk -F” “ ‘{print $2}’
Difference b/w grep and awk:
Grep command gives you the entire sentence with all columns as a result.
Awk only give you a particular column from the output