TOP MNC — DevOps INTERVIEW QUESTIONS 2024

1. What is GIT stash?

In Git, the git stash command is used to temporarily save changes that are not ready to be committed. It’s handy when you need to switch branches or pull changes without committing your current work. Stashing allows you to store changes in a “stash,” and later you can apply or drop these changes as needed.

2. What is a branching strategy?

A branching strategy is a set of rules or conventions that guide how branches are created, named, and merged in a version control system like Git. It helps teams collaborate efficiently, manage code releases, and maintain a clean and organized codebase. Common branching strategies include feature branching, git-flow, and GitHub flow.

3. What is the command to discard changes in the working directory?

To discard changes in the working directory in Git, you can use the command git checkout -- <file> or git checkout . to discard all changes. This will revert the files to the state of the last commit.

4. How do you debug the exited container?

To debug an exited container, you can use the docker logs <container_id> command to view the container’s logs. Additionally, you can start an interactive shell in the container using docker exec -it <container_id> /bin/bash to inspect the container’s filesystem and diagnose issues.

5. How do you execute jobs parallelly in Jenkins?

In Jenkins, you can execute jobs in parallel by using the Parallel or Matrix job configuration. You can define stages or tasks within these structures to run concurrently. Also, Jenkins Pipeline allows parallel execution using the parallel directive.

6. Maven Lifecycle?

Maven has a defined build lifecycle consisting of phases such as clean, compile, test, package, install, and deploy. Each phase represents a stage in the software development process. Maven plugins bind goals to these phases, allowing developers to customize the build process.

7. How do you upgrade Jenkins?

To upgrade Jenkins, you can follow these steps:

  • Backup your Jenkins data.
  • Download the new Jenkins WAR file.
  • Stop the Jenkins server.
  • Replace the existing Jenkins WAR file with the new one.
  • Start Jenkins using the updated WAR file.

8. What is called a Parameterized Job in Jenkins?

A parameterized job in Jenkins allows you to pass parameters or variables to a build job. This enables you to customize the build process based on specific inputs, enhancing the flexibility and reusability of Jenkins jobs.

9. What is Docker Swarm?

Docker Swarm is a container orchestration tool that allows you to create and manage a cluster of Docker hosts. It enables the deployment and scaling of containerized applications across a swarm of machines, providing high availability and load balancing.

10. How do you handle codes in Nexus satisfactorily?

To handle code in Nexus, you can use it as a repository manager to store and manage artifacts, dependencies, and build artifacts. You can publish and retrieve artifacts from Nexus using build tools like Maven or Gradle, ensuring a centralized and reliable repository for your project.

11. How do you manage space issues in the Jenkins server?

To manage space issues in the Jenkins server, regularly clean up old builds, unused plugins, and unnecessary files. Configure Jenkins job settings to limit the number of builds stored, and consider offloading artifacts to external repositories or storage solutions.

12. What is called a multibranch project in the Jenkins server?

A multibranch project in Jenkins is a type of project that automatically creates a set of sub-projects for each branch in a repository. It is particularly useful for managing and building multiple branches of a project simultaneously, with each branch having its own set of build configurations.

13. How do you secure the Jenkins server?

Securing Jenkins involves actions like enabling authentication, restricting user permissions, configuring HTTPS, regularly updating Jenkins and its plugins, implementing security plugins, and using firewalls to control access.

14. How do you manage GitHub roles?

In GitHub, you manage roles through access permissions. Roles include Owners, Collaborators, and Contributors. Owners have full access, Collaborators have write access, and Contributors have read-only access. You can add or remove collaborators to control who can contribute to a repository.

15. What is called a NULL resource in Terraform?

In Terraform, a null_resource is a resource that doesn’t directly interact with any infrastructure. It serves as a placeholder, allowing you to execute arbitrary commands or scripts during the Terraform lifecycle, without creating any physical resources.

16. What is called terraform fmt?

terraform fmt is a Terraform command used to format the Terraform configuration files. It automatically organizes and standardizes the code, making it easier to read and maintain. It helps enforce consistent coding styles across projects.

17. What is called Snowball?

AWS Snowball is a service that facilitates the transfer of large amounts of data into and out of the AWS Cloud. It provides a physical device, Snowball, which you can use to securely transport data between your on-premises environment and AWS.

18. How do you manage credentials in Terraform?

In Terraform, you manage credentials using providers. Providers may require authentication details, and these can be configured using environment variables, configuration files, or other methods depending on the provider. It’s crucial to handle credentials securely, such as using environment variables or a secrets management solution.

19. What is called CodeDeploy in AWS?

AWS CodeDeploy is a service that automates code deployments to various compute services, including Amazon EC2, AWS Fargate, AWS Lambda, and more. It allows you to deploy applications in a consistent and reliable manner, handling updates and rollbacks efficiently.

20. Can you attach a single EBS volume to multiple EC2 instances at the same time?

No, an EBS volume can only be attached to a single EC2 instance at a time. To share data between multiple instances, you can use solutions like Amazon EFS (Elastic File System) or set up network file sharing.

21. Can you use Multiple FROM in DockerFile?

No, a Dockerfile can have only one FROM instruction. The FROM instruction specifies the base image for subsequent instructions in the Dockerfile.

22. DockerFile runs as which user?

By default, the commands in a Dockerfile run as the root user inside the container. You can use the USER instruction to switch to a different user for security reasons.

23. How can we pass an argument to DockerFile?

Docker does not support passing arguments directly to a Dockerfile during the build process. Instead, you can use build arguments with the --build-arg flag when running the docker build command.

24. What are deployment strategies?

Deployment strategies are approaches used to release software updates and new features with minimal disruption. Common strategies include Blue-Green deployment, Rolling deployment, Canary deployment, and Feature toggles.

25. What is called an application load balancer?

An Application Load Balancer (ALB) is an AWS service that distributes incoming application traffic across multiple targets, such as EC2 instances, in multiple availability zones. ALBs operate at the application layer (Layer 7) of the OSI model and provide features like content-based routing and SSL termination.

26. What is Kubernetes architecture?

Kubernetes architecture consists of master nodes and worker nodes. The master node manages the cluster, while worker nodes host the deployed applications. Key components include etcd (cluster state storage), API server, controller manager, scheduler, and kubelet (on each node).

27. What is called Fargate service in AWS?

AWS Fargate is a serverless compute engine for containers. It allows you to run containers without managing the underlying infrastructure. With Fargate, you can focus on deploying and managing your containerized applications without worrying about the host infrastructure.

28. What are Register targets in Ansible?

In Ansible, “register” is used to capture the output of a task and store it in a variable. Registering targets allows you to use the result of one task in subsequent tasks, making your playbook more dynamic and flexible.

29. How do you pull artifacts from NEXUS?

You can pull artifacts from Nexus using build tools like Maven or Gradle. Configure your build script to fetch dependencies from the Nexus repository, specifying the repository URL and credentials if required.

30. How to access the S3 bucket privately?

To access an S3 bucket privately, configure the bucket policy or use IAM roles to restrict access. Additionally, you can enable VPC endpoint policies or use Amazon S3 Access Points to control access to the bucket.

31. What is the difference between a NAT instance and a NAT Gateway?

A NAT instance is a single EC2 instance configured as a Network Address Translation (NAT) gateway. In contrast, a NAT Gateway is a fully managed AWS service that provides similar functionality but is more scalable, highly available, and does not require maintenance like a NAT instance.

32. How can you restrict particular IPs accessing EC2 instances?

You can restrict access to EC2 instances by configuring security groups or network ACLs. Security groups control inbound and outbound traffic at the instance level, while network ACLs operate at the subnet level, controlling traffic between subnets.

33. What is called VPC peering?

VPC peering enables direct communication between two Virtual Private Clouds (VPCs) using private IP addresses. It allows resources in one VPC to access resources in another VPC securely.

34. What is called Transit Gateway?

AWS Transit Gateway is a service that simplifies network connectivity between multiple VPCs, VPNs, and on-premises networks. It acts as a hub, facilitating scalable and centralized connectivity across a network.

35. What are the types of autoscaling?

The types of autoscaling in AWS are:

  1. Manual Scaling: Manually adjusting the number of instances.
  2. Dynamic Scaling: Automatically adjusting the number of instances based on traffic or other metrics.
  3. Scheduled Scaling: Scaling based on a predefined schedule.
  4. Predictive Scaling: Uses machine learning to predict scaling needs based on historical data.

36. To prevent DDOS attacks, which load balancer is used?

To prevent DDoS attacks, AWS provides the AWS Shield service, which is automatically integrated with the AWS Global Accelerator and the AWS WAF (Web Application Firewall). These services help protect against DDoS attacks and provide enhanced security features.

37. What is called a sticky session?

A sticky session (or session affinity) in load balancing ensures that a user’s requests are consistently directed to the same backend server. This is achieved by associating a user’s session with a specific server, improving user experience for applications that require state persistence.

38. What is called Lambda?

AWS Lambda is a serverless computing service that allows you to run code without provisioning or managing servers. It automatically scales based on demand and charges only for the compute time consumed during code execution.

39. How do you manage tfstate file in Terraform?

To manage the tfstate file in Terraform, you can store it remotely using backends like AWS S3 or HashiCorp Consul. Storing tfstate remotely helps in collaborative work, version control, and ensures a centralized state management.

40. How do you create multiple EC2 instances in Terraform?

To create multiple EC2 instances in Terraform, you can use a resource block for the aws_instance and specify the count parameter. For example:

resource "aws_instance" "example" {
  ami           = "ami-xxxxxxxxxxxxxxxxx"
  instance_type = "t2.micro"
  count         = 3
}

This will create three EC2 instances based on the specified parameters.

41. AWS has released a new service, how does Terraform behave?

When AWS releases a new service, Terraform may not have immediate support for it. However, Terraform is regularly updated, and new providers or resources are added to support the latest AWS services. Always ensure you are using an up-to-date version of Terraform or check for community-contributed providers.

42. How do you uncommit the changes that have already been pushed to GitHub?

To uncommit changes that have already been pushed to GitHub, you can use the git revert or git reset command to undo commits locally. After making the necessary changes, you can force-push the updated branch to GitHub. Be cautious when force-pushing to shared branches to avoid disrupting collaboration.

43. What is the difference between git pull and git fetch?

git pull is a combination of git fetch and git merge. It fetches changes from the remote repository and automatically merges them into the current branch. On the other hand, git fetch only fetches changes, allowing you to inspect them before deciding to merge or rebase.

44. What is called Jenkins File?

A Jenkinsfile is a text file that defines the entire Jenkins Pipeline. It is written in a domain-specific language (DSL) and resides in the version control system along with the source code. Jenkinsfiles provide a way to describe, control, and visualize the entire build and deployment process.

45. What is called Shared Libraries in Jenkins?

Shared Libraries in Jenkins allow you to centralize and reuse common code across multiple pipelines. They help maintain consistency, promote code reuse, and simplify the management of complex Jenkins pipelines by storing commonly used functions and steps in a shared location.

46. What is called Docker networking?

Docker networking is the mechanism that allows communication between Docker containers and between containers and the host system. Docker provides various networking options, including bridge networks, host networks, overlay networks, and user-defined networks, to facilitate communication and connectivity between containers.

47. What is called a Trust relationship in AWS?

A trust relationship in AWS is established between two entities, such as AWS accounts or services, to define permissions and access. For example, a trust relationship between an IAM role and an AWS service allows the service to assume the role and perform actions on behalf of the role’s permissions.

48. What is called Public Subnet and Private Subnet?

In AWS, a public subnet is a subnet with a route to the internet, typically associated with resources like load balancers or web servers. A private subnet, on the other hand, lacks direct internet access and is often used for backend databases or application servers that should not be directly accessible from the internet.

49. How do you establish a connection between EC2 instance to another EC2 instance?

To establish a connection between EC2 instances, you can use various methods:

  • SSH: Secure Shell for secure command-line access.
  • HTTP/HTTPS: For web applications.
  • RDP: Remote Desktop Protocol for Windows instances.
  • Custom protocols: Configure security groups and network ACLs to allow specific communication.

50. What is the realm command?

The realm command in Linux is used to join a system to an Active Directory or Kerberos realm. It facilitates the integration of Linux systems with centralized authentication systems like Microsoft Active Directory.

51. How do you differentiate within an AWS account dev env, test env, and prod env?

To differentiate between development (dev), test, and production (prod) environments in AWS, you can use various strategies such as naming conventions, resource tagging, and VPC segregation. Tagging resources with environment-specific labels helps in easy identification and management.

52. Types of EC2 instances?

AWS EC2 instances come in various types optimized for different use cases. Common types include:

  • General Purpose (e.g., t4g, t3, t3a, t2): Balanced compute, memory, and networking.
  • Compute Optimized (e.g., c7g, c6g, c5, c5a, c5n): High-performance computing.
  • Memory Optimized (e.g., r7g, r6g, r5, r5a, u-6tb1.metal): High-memory capacity.
  • Storage Optimized (e.g., i3, i3en, h1, d2): High-performance storage.

53. How can you encrypt the already created unencrypted EBS without creating a fresh EC2 instance?

To encrypt an already created unencrypted EBS volume without creating a fresh EC2 instance, you can create a snapshot of the unencrypted volume, copy the snapshot while enabling encryption, and then create a new EBS volume from the encrypted snapshot.

54. How do you install Nginx in the Ansible playbook?

To install Nginx using Ansible, you can use the apt or yum module, depending on the Linux distribution. Here’s an example for Ubuntu:

---
- hosts: your_servers
  tasks:
    - name: Install Nginx
      become: yes
      apt:
        name: nginx
        state: present

Adjust the playbook according to your server’s package manager if it’s not Ubuntu.

55. How do you recover the deleted object in S3?

To recover a deleted object in S3, you can use versioning. If versioning is enabled, deleted objects are not permanently removed; instead, a delete marker is added. You can then either delete the delete marker or restore the previous version of the object.

56. How do you route the data only to one EC2 instance when an application load balancer has 5 servers connected?

To route data to a specific EC2 instance behind an Application Load Balancer (ALB), you can use target groups and rules. Create a target group containing only the desired EC2 instance and configure a rule on the ALB to route traffic based on the defined conditions.

57. What is called “FROM SCRATCH” in Docker?

FROM SCRATCH in Docker is a minimalistic starting point for creating Docker images. It creates an image from an empty filesystem, allowing you to build lightweight and specialized images. It’s often used for building small, single-purpose containers.

58. Can we run the container inside the container?

Yes, you can run a container inside another container using a feature called Docker-in-Docker (DinD) or nested Docker. However, this approach has limitations and potential security implications. Alternatively, consider using tools like Docker Compose or Kubernetes for managing multiple containers.

59. Can we use Ansible to create infrastructure in AWS?

Yes, Ansible can be used to create infrastructure in AWS using the AWS modules provided by Ansible. You can define AWS resources, such as EC2 instances, VPCs, and S3 buckets, in Ansible playbooks and use them to automate the provisioning of infrastructure.

60. What is called EC2 auto recovery?

EC2 Auto Recovery is an AWS feature that automatically recovers an EC2 instance if it becomes impaired due to an underlying hardware failure. It does so by stopping and then restarting the instance on new hardware within the same Availability Zone.

61. What is called Persistent Storage in Docker?

Persistent storage in Docker refers to data storage that persists beyond the lifecycle of a container. It is achieved using Docker volumes or bind mounts, allowing data to survive container restarts or removals. Persistent storage is crucial for preserving application data and state.

62. What happens when you delete /var/lib/docker/overlay?

Deleting the /var/lib/docker/overlay directory directly can lead to the loss of all Docker containers and images. This directory contains the overlay storage driver’s data, including container filesystems and layers. Avoid manually deleting this directory unless you are intentionally trying to reset Docker completely.

63. What are called regular expressions in Linux?

Regular expressions (regex or regexp) in Linux are patterns used for matching character combinations within strings. They are powerful tools for searching, matching, and manipulating text. Commands like grep, sed, and awk use regular expressions for text processing.

64. What is called DynamoDB?

Amazon DynamoDB is a fully managed NoSQL database service provided by AWS. It is designed to deliver low-latency and high-performance access to data, making it suitable for applications that require fast and scalable database operations. DynamoDB supports both document and key-value data models.

65. How do you push the image to DockerHub?

To push a Docker image to DockerHub, follow these steps:

  1. Build your Docker image: docker build -t your_image_name:tag .
  2. Tag the image with your DockerHub repository: docker tag your_image_name:tag dockerhub_username/your_image_name:tag
  3. Log in to DockerHub: docker login
  4. Push the image: docker push dockerhub_username/your_image_name:tag

66. Why do you change the name of the image using the tag command in Docker?

Changing the name of the Docker image using the docker tag command is essential for associating the image with a specific repository on DockerHub or another container registry. The tag includes the repository information, ensuring the image is correctly identified and pushed to the intended destination.

67. How do you authorize data to the Application Load Balancer?

Authorization of data to an Application Load Balancer (ALB) is typically managed within the web application or service running on the backend servers. ALBs primarily handle routing and load balancing, and authorization mechanisms are implemented within the application code, such as authentication tokens, API keys, or OAuth.

68. What is called Event Handler in Lambda?

In AWS Lambda, an Event Handler is a function that processes events and executes custom code in response. Lambda functions can be triggered by various events, such as changes in S3 buckets, incoming HTTP requests via API Gateway, or events from other AWS services.

69. What is the difference between CMD and Entrypoint in Docker?

In Docker, CMD and ENTRYPOINT both define commands to run when a container starts, but they serve different purposes. CMD specifies the default command and arguments for an executing container, while ENTRYPOINT configures the container to be an executable, with CMD providing default arguments.

70. What is called CloudFormation?

AWS CloudFormation is a service that allows you to define and provision AWS infrastructure as code (IaC). It uses templates, written in JSON or YAML, to describe the resources and their configurations. CloudFormation automates the provisioning and updating of infrastructure in a predictable and repeatable manner.

71. How do you change the name of an instance in a Terraform file without destroying it?

To change the name of an instance in Terraform without destroying it, you can use the terraform state mv command to update the state file with the new resource name. After that, modify your Terraform configuration with the new name, and then run terraform apply to apply the changes without recreating the instance.

72. How does Ansible execute the jobs?

Ansible executes jobs by connecting to remote nodes over SSH and then running the specified tasks in a playbook. Ansible uses a push-based model, where the control node pushes configurations and tasks to the managed nodes. The entire process is orchestrated through playbooks, which are YAML files containing instructions for tasks to be executed.

73. How to connect the on-premise data center to AWS?

To connect an on-premise data center to AWS, you can use several methods:

  • AWS Direct Connect: Establish a dedicated network connection between on-premises and AWS.
  • VPN (Virtual Private Network): Set up a secure connection over the internet using VPN.
  • AWS Storage Gateway: Extend on-premise storage to AWS using gateway appliances.
  • AWS Direct Connect Gateway: Connect multiple on-premises locations to multiple VPCs in AWS.

74. What is a GIT tag?

In Git, a tag is a reference to a specific commit in the repository’s history. Tags are used to mark specific points, such as releases or milestones, making it easy to reference and check out a particular commit later. Unlike branches, tags are static and do not change.

Leave a Comment