KK DevOps Interview Prep Flashcards

1
Q

Your EC2 instance is running out of disk space on the root/OS volume. What actions will you take to mitigate the issue? #4

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a bastion host or gateway server and what role do they play? 2

A
  • A bastion host is a server that allows secure access to servers or resources in a private network from and external network.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are some scernarios that would warrant the use of a bastion host?

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would an external user connect to a Bastion host? 2

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

From a Security standpoint what is an advantage of using a bastion host or gateway server.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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?

A
  1. 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.
  2. 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.
  3. 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A
  1. Check ASG configuration for scaling policies or other settings causing termination.
  2. Review ASG activity history and CloudWatch metrics for spikes in CPU or Disk usage, network traffic, or other metrics.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A
  • If the issue remains, use advanced troubleshooting techniques like packet captures, system and application profiling, or debugging tools (strace or gdb).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which command would you use to check the free and used memory in a system?

A

The free -mt command is used to display the amount of free and used memory in the system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The du and df -h commands are useful when looking into disk space issues. What are the differences and when should each be used?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Breakdown the use of the free -mt command and it’s flags?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A
  1. Install and configure the AWS CLI on the instance
  2. Use and IAM Role or Access Keys to grant the server access to S3
  3. Write a bash script that copies & uploads logs to S3 using the AWS CLI, specifying credentials, bucket, and path.
  4. Save file, make executable and Test the script.
  5. Use a cron job to schedule the script to run automatically at desired intervals.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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```

A
  1. The first line, shebang, #! tells the system that this is a bash script and should be executed.
  2. 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.
  3. 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 the aws 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the steps to using a cron job to schedule the script to run automatically at desired intervals?

A
  • 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is logging and why is it important for applications? #4

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is centralized logging?

A

Centralized logging simplifies log data analysis and troubleshooting by collecting data from various sources into one location. This enables identification of patterns and trends across different systems and applications

18
Q

In what scenario would you use centralized logging?

A

In a production, when applications are running in a scalable manner, centralized logging is required since you lose the data associated with any instance terminated.

19
Q

What tools helps to achieve centralized logging within AWS and outside of AWS?

A

AWS: S3, Cloudwatch Logs, ElasticSearch
Splunk & Graylog

20
Q

What is branch protection in GitHub?

A
  • A feature that allows repository administrators to set rules for branches like:
  • Block force pushes or require pull request reviews.
21
Q

What does branch protection in GitHub help prevent?

A
  • It helps prevent accidental or malicious changes to the codebase.
22
Q

How can I view the logs of my Docker container and limit the output to only the last 200 lines?

A

docker container logs --tail 200 <container_id or container_name>

23
Q

What will happen to docker logs if you stop, start, restart, or remove a container?

A

If you stop, start, or restart a Docker container, its logs will still be available. However, if you remove the container using the command docker rm its logs will be deleted permanently.

24
Q

Why would a Docker image that is 2.7 GB in size, be a cause for concern?

A

Larger images have longer build times and increased storage requirements.

25
Q

If you encounter a Docker image that is 2.7 GB in size, how would you resolve it?

A
  • Use a base image that is smaller in size. (alpine)
  • Removing unnecessary files, dependencies and binaries
  • Use a multistage build, which can significantly reduce the size of the final image.
26
Q

What is the difference between a docker image and docker layer?

A

Docker, images are read-only templates that create containers.
They use stacked, immutable layers to optimize image creation and reduce data duplication.

27
Q

What is kubernetes kOps?

A
  • Kops is a tool that allows you to automate the process of creating and managing the underlying AWS resources needed for a Kubernetes cluster, such as EC2 instances, security groups, and load balancers.
28
Q

In Kubernetes, PV stands for Persistent Volume, which is a

A

storage resource that can be used by pods.

29
Q

PVC stands for Persistent Volume _____ , which is a request for ________ by a pod. A PVC can be used to request a PV or to dynamically ________ a new one.

A

PVC stands for Persistent Volume Claim, which is a request for storage by a pod. A PVC can be used to request a PV or to dynamically provision a new one.

30
Q

A persistent volume is required in scenarios where data needs to be stored __________________ of the lifecycle of the ____________ that created it. Some examples include ____________, ____ _________ , and __________ for stateful applications.

A

A persistent volume is required in scenarios where data needs to be stored independently of the lifecycle of the container that created it. Some examples include databases, file servers, and storage for stateful applications.

31
Q

A pod is attempting to access a volume, but it receives an access error. How would you resolve this? #4

A
  • Check the status of the volume to ensure it is healthy and available.
  • Check the access mode of the pod and ensure it matches the access mode of the volume.
  • Check the permissions and ownership of the files and folders within the volume to ensure they allow access to the pod.
  • Check the logs of the pod and the volume to identify any errors or issues that may be causing the access error.
32
Q

A sidecar container runs alongside a primary container in the same pod in Kubernetes. It provides additional functionality such

A

as logging, monitoring, or security features.

33
Q

How does a sidecar container communicates with the primary container?

A

It communicates with the primary container using a shared filesystem or network interface.

34
Q

How can we ensure that certain pods are launched only on specific nodes that are explicitly designated for them?

A

You can accomplish this using node affinity or nodeSelector.

35
Q

Define Node affinity

A

Node affinity can be used to ensure that your pods are scheduled on nodes in a specific region or with certain CPU or memory capacity.

36
Q

Define Node Selector

A

NodeSelector allows you to match the labels on nodes with the labels specified in the pod spec.

37
Q

Define Taints in Kubernetes

A

taints are used to mark nodes as unsuitable for scheduling pods, unless the pods have tolerations that match the taints.

38
Q

Some scenarios where a taint might be used include: #3

A
  • Reserve nodes for specific workloads/teams.
  • Mark nodes as unsuitable for CPU/Memory-intensive workloads.
  • Mark nodes as unsuitable for workloads requiring access to sensitive data/resources.
39
Q

How does the Kubernetes scheduler determine which nodes to deploy pods onto? #4

A

Kubernetes scheduler is responsible for assigning pods to nodes based on

- resource requirements
- node availability
- pod affinity
- & taints

40
Q

The scheduler works by evaluating a set of rules and constraints to determine the most suitable node for each pod. These rules and constraints include:

  • Resource requirements:
  • Node availability:
  • Pod affinity and anti-affinity:
  • Taints and tolerations:

Describe each

A
  • Resource requirements: The scheduler checks CPU and memory requirements and ensures the node has enough resources.
  • Node availability: The scheduler avoids scheduling pods on nodes that are at capacity or non-ready.
  • Pod affinity and anti-affinity: The scheduler can be configured to locate related pods together or apart based on node or pod labels.
  • Taints and tolerations: Nodes can be “tainted” and unsuitable for certain pods. Pods can be configured with “tolerations” that match taints.
41
Q

Can you explain the internal workings of the Kubernetes scheduler?

A
  • Pods start in a “Pending” state until they are scheduled.
  • The scheduler evaluates rules and constraints for each pod and assigns it to the most suitable node.
  • Then the pod moves to the “Running” state.
42
Q

What is the significance of setting pod/node affinity rules?

A

Setting node affinity rules ensures that your pods run on nodes that meet your requirements.