KK DevOps Interview Prep Flashcards
Your EC2 instance is running out of disk space on the root/OS volume. What actions will you take to mitigate the issue? #4
EC2 Disk space means we are speaking of EBS volumes
1. Identify which directories or files are taking up the most space on the root/OS volume using du
command.
2. Free up disk space by removing unnecessary files, using rm
and find
commands.
3. Optimize disk usage by moving large files to another instance or storage service using rsync
command.
4. Increase disk space by resizing the instance or attaching an additional EBS volume to the instance.
What is a bastion host or gateway server and what role do they play? 2
- A bastion host is a server that allows secure access to servers or resources in a private network from and external network.
What are some scernarios that would warrant the use of a bastion host?
- Accessing an RDS instance or other database server that is not publicly accessible.
- Accessing a web server or other application server that is behind a load balancer or firewall.
- Accessing a server or resource in a private subnet within a VPC.
How would an external user connect to a Bastion host? 2
- Users connect to the bastion host using SSH or RDP.
- Then, they use that connection to access other servers or resources in the private network.
From a Security standpoint what is an advantage of using a bastion host or gateway server.
You can cut off all access to your internal workout at one source
You can monitor and control the flow of who can access your internal network
Multiple EC2 instances in an ASG are getting terminated and this is causing downtime on the application. EC2 pricing and quota limits all look good. When you begin debugging what are the possible causes? #3
There are many reasions for this but I will cover the top 3.
* High CPU utilization
* Disk Space is Full (EBS)
* No Free Memory Available
Multiple EC2 instances in an ASG are getting terminated and this is causing downtime on the application. EC2 pricing and quota limits all look good. Now that you’ve identified the causes what remedies do you suggest to fix the top 3 possible causes?
- High CPU utilization based on CPU. Run the
top
command to look for a process that is occupying cpu. If its the application I would connect with the Developer team to resolve the issue. - Run the
df -h
to confirm there is no free disk space. Create a snapshot of the current EBS volume and increase the size, or add a volume. - The memory could be at it max. Run
free -mt
to confirm. I would suggest using a different type of instance that is more memeory intensive in the ASG.
Multiple EC2 instances in an ASG are getting terminated and this is causing downtime on the application. How would you begin debugging this issue in AWS? #2
- Check ASG configuration for scaling policies or other settings causing termination.
- Review ASG activity history and CloudWatch metrics for spikes in CPU or Disk usage, network traffic, or other metrics.
Multiple EC2 instances in an ASG are getting terminated, and this is causing downtime on the application. EC2 pricing and quota limits all look good. What are some advanced debugging techniques? #3
- If the issue remains, use advanced troubleshooting techniques like packet captures, system and application profiling, or debugging tools (strace or gdb).
Which command would you use to check the free and used memory in a system?
The free -mt
command is used to display the amount of free and used memory in the system
The du
and df -h
commands are useful when looking into disk space issues. What are the differences and when should each be used?
The du
command shows the disk usage of a directory and its subdirectories, whereas the df -h
command shows the disk space usage of the file system containing a file or directory.
Breakdown the use of the free -mt
command and it’s flags?
The free -mt
command is used to display the amount of free and used memory in the system, in Megabytes (MB).
The -m
option displays the output in MB
The -t
option adds a total line at the end of the output, which shows the total amount of memory, both physical and swap, in the system.
How would you create a script that will push certain logs to S3 automatically? From a high level explain all the steps you’d take to achieve this. The script should run at a particular time. #5
- Install and configure the AWS CLI on the instance
- Use and IAM Role or Access Keys to grant the server access to S3
- Write a bash script that copies & uploads logs to S3 using the AWS CLI, specifying credentials, bucket, and path.
- Save file, make executable and Test the script.
- Use a cron job to schedule the script to run automatically at desired intervals.
Set S3 bucket and path
Explain whats happening in each section of this script.
~~~
#!/bin/bash
s3_bucket=”my-logs-bucket”
aws –profile my-iam-role s3 cp /var/log/myapp/ s3://$s3_bucket/$s3_path –recursive```
- The first line, shebang,
#!
tells the system that this is a bash script and should be executed. - The next section sets variables that contain the name of the S3 bucket and the path within the bucket where the logs will be uploaded to.
- The fifth line is the command that uploads the logs to S3. It uses the
aws
command, to copy the contents of the/var/log/myapp/
directory to the specified S3 bucket and path. The-profile
option specifies the AWS CLI profile to use, and the-recursive
option tells theaws
command to upload all files and directories within the/var/log/myapp/
directory. The$s3_bucket
and$s3_path
variables are used to specify the destination of the logs.
What are the steps to using a cron job to schedule the script to run automatically at desired intervals?
- Open the cron tab by running the
crontab -e
command - Add a line to the file to schedule the script to run automatically at a specified interval.
- Save the file and exit the editor. The script will now run automatically at the specified interval.
For example, if you want the script to run every day at midnight, you would use the following line: 0 0 * * * /path/to/script
What is logging and why is it important for applications? #4
Logging:
- Records important events and error messages in an application.
- Provides insight into the behavior of an application.
- Can help in debugging and troubleshoot issues.
- Facilitates collaboration between developers, operations, and support teams.