September 25, 2024
 
Git
  1. What is Git bisect and how is it used?
Git bisect is a binary search tool used to find the commit that introduced a bug. It works by marking known good and bad commits, then checking out commits in between until the first bad commit is identified.
  1. Explain the difference between git reset and git revert.
git reset moves the HEAD and branch ref pointers to a specified commit, potentially discarding commits. git revert creates a new commit that undoes the changes made in a specific commit, preserving the project history.
  1. What is a Git hook?
Git hooks are scripts that run automatically before or after events like commit, push, and receive. They're used to enforce policies, automate tasks, or integrate with other systems.
  1. How do you squash multiple commits into one?
You can use interactive rebase: git rebase -i HEAD~n where n is the number of commits to combine. In the interactive editor, change 'pick' to 'squash' for the commits you want to combine.
  1. What is Git LFS?
Git Large File Storage (LFS) is an extension that replaces large files with text pointers inside Git, while storing the file contents on a remote server.
  1. Explain the concept of Git submodules.
Git submodules allow you to keep a Git repository as a subdirectory of another Git repository, enabling you to include and track the version of an external project within your main project.
  1. What is the difference between git fetch and git pull?
git fetch downloads new data from a remote repository but doesn't integrate it into your working files. git pull does a git fetch followed by a git merge to update your current branch with the latest changes.
  1. How do you undo the last commit in Git?
To undo the last commit while keeping the changes, use git reset HEAD~1. To completely remove the last commit and its changes, use git reset --hard HEAD~1.
  1. What is Git cherry-pick?
Git cherry-pick is used to apply the changes introduced by some existing commits to the current branch. It's useful when you want to pick specific commits from one branch and apply them to another.
  1. How do you resolve merge conflicts in Git?
To resolve merge conflicts:
  1. Open the conflicting files and look for conflict markers.
  1. Edit the files to resolve the conflicts.
  1. Use git add to mark the conflicted files as resolved.
  1. Complete the merge by running git commit.
Linux
  1. What is the difference between a hard link and a symbolic link?
A hard link is a direct reference to the physical file on disk, while a symbolic link (or soft link) is a reference to the file name. Hard links can't cross file systems, but symbolic links can.
  1. Explain the purpose of the /etc/fstab file.
The /etc/fstab file contains information about disk drives and partitions. It's used by the system to mount file systems automatically at boot time or when the mount -a command is issued.
  1. What is a zombie process?
A zombie process is a process that has completed execution but still has an entry in the process table. It's waiting for its parent process to read its exit status.
  1. How do you check system resource usage in Linux?
You can use commands like:
  • top or htop for real-time system monitoring
  • free for memory usage
  • df for disk usage
  • iostat for CPU and I/O statistics
  1. What is the purpose of the iptables command?
iptables is used to set up, maintain, and inspect the tables of IP packet filter rules in the Linux kernel. It's primarily used for configuring firewall rules.
  1. Explain the difference between su and sudo.
su switches the current user to another user (typically root), requiring the target user's password. sudo allows a user to execute commands with the security privileges of another user (typically root) while using their own password.
  1. What is a Linux kernel module?
A kernel module is a piece of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system.
  1. How do you troubleshoot high CPU usage on a Linux system?
To troubleshoot high CPU usage:
  1. Use top or htop to identify the processes consuming CPU.
  1. Use ps aux to get more details about specific processes.
  1. Check system logs in /var/log for any errors or warnings.
  1. Use strace to trace system calls and signals.
  1. What is the purpose of the /proc filesystem?
The /proc filesystem is a pseudo-filesystem that provides an interface to kernel data structures. It's used to access information about processes and system resources.
  1. Explain the concept of Linux namespaces.
Linux namespaces are a feature that partitions kernel resources such that one set of processes sees one set of resources while another set of processes sees a different set of resources. They're used to create isolated environments for containers.
Docker
  1. What is Docker and how does it differ from virtual machines?
Docker is a platform for developing, shipping, and running applications in containers. Unlike virtual machines, Docker containers share the host system's kernel and are more lightweight, starting up faster and using fewer resources.
  1. Explain the difference between a Docker image and a Docker container.
A Docker image is a read-only template that contains a set of instructions for creating a container. A container is a runnable instance of an image, which can be started, stopped, moved, or deleted.
  1. What is a Dockerfile and what are its main components?
A Dockerfile is a text file that contains instructions to build a Docker image. Main components include:
  • FROM: Specifies the base image
  • RUN: Executes commands in the container
  • COPY and ADD: Copy files into the container
  • CMD and ENTRYPOINT: Specify the command to run when the container starts
  1. How do you persist data in Docker?
Data can be persisted in Docker using:
  • Volumes: Managed by Docker and stored in a part of the host filesystem
  • Bind mounts: Map a host file or directory to a container file or directory
  • tmpfs mounts: Stored in the host system's memory only
  1. Explain Docker networking and the different network drivers.
Docker networking allows containers to communicate with each other and the outside world. Network drivers include:
  • bridge: Default network driver
  • host: Removes network isolation between container and host
  • overlay: Connects multiple Docker daemons
  • macvlan: Assigns a MAC address to a container
  1. What is Docker Compose and when would you use it?
Docker Compose is a tool for defining and running multi-container Docker applications. It uses a YAML file to configure application services, networks, and volumes. It's useful for development, testing, and staging environments.
  1. How do you optimize a Docker image size?
To optimize Docker image size:
  • Use a smaller base image
  • Minimize the number of layers
  • Use multi-stage builds
  • Remove unnecessary files
  • Combine RUN commands
  1. Explain Docker swarm mode.
Docker swarm mode is a clustering and scheduling tool for Docker containers. It allows you to manage a cluster of Docker nodes as a single virtual system, providing features like load balancing, service discovery, and rolling updates.
  1. What is the purpose of Docker healthchecks?
Docker healthchecks are used to determine the health status of a container. They can be configured to run a command inside the container periodically and report the container's status as healthy or unhealthy.
  1. How do you handle secrets in Docker?
Docker provides a secrets management feature that allows you to securely store sensitive data like passwords, SSH keys, or API tokens. Secrets are encrypted at rest and only made available to services that have been granted explicit access to them.
Jenkins
  1. What is Jenkins and why is it used?
Jenkins is an open-source automation server used for building, testing, and deploying software. It's used to implement continuous integration and continuous delivery (CI/CD) pipelines, automating the software development process.
  1. Explain the difference between Freestyle and Pipeline jobs in Jenkins.
Freestyle jobs are configured through the web UI and are suitable for simple, linear workflows. Pipeline jobs are defined using a Jenkinsfile and provide more flexibility, allowing for complex workflows with conditional logic and parallel execution.
  1. What is a Jenkins agent and how does it differ from the master?
A Jenkins agent (or slave) is a machine that connects to the Jenkins master and executes tasks when directed by the master. The master is responsible for scheduling jobs, distributing builds to agents, and monitoring agents. Agents offload build tasks from the master.
  1. How do you secure Jenkins?
To secure Jenkins:
  • Enable authentication and authorization
  • Use HTTPS
  • Keep Jenkins and its plugins updated
  • Implement proper user management
  • Use credentials management for sensitive information
  • Configure security settings like CSRF protection
  1. What is a Jenkinsfile and what are its advantages?
A Jenkinsfile is a text file that contains the definition of a Jenkins Pipeline. Advantages include:
  • Version control of the pipeline along with the application code
  • Code review/iteration on the pipeline
  • Ability to audit the pipeline
  • Single source of truth for the pipeline
  1. Explain the concept of Jenkins shared libraries.
Jenkins shared libraries are reusable code that can be shared across multiple pipelines. They allow you to define common functionality in a central place and use it in multiple Jenkins jobs, promoting code reuse and maintainability.
  1. How do you handle credentials in Jenkins?
Jenkins provides a Credentials Plugin that allows secure storage of credentials. These can be used in jobs without exposing sensitive information. Types of credentials include usernames and passwords, SSH keys, and secret text.
  1. What is Jenkins Blue Ocean?
Blue Ocean is a redesigned user interface for Jenkins that focuses on Pipeline visualization. It provides a more modern and intuitive way to interact with Jenkins, making it easier to create, visualize, and diagnose Pipelines.
  1. How do you set up a master-slave configuration in Jenkins?
To set up a master-slave configuration:
  1. Install Jenkins on the master node
  1. Configure the slave node (install Java, create a Jenkins user)
  1. Add the slave node in Jenkins master (Manage Jenkins > Manage Nodes > New Node)
  1. Configure the connection method (SSH, JNLP, etc.)
  1. Launch the agent on the slave node
  1. Explain how you would implement a rollback strategy in Jenkins.
A rollback strategy in Jenkins could involve:
  1. Keeping track of successful builds and their artifacts
  1. Implementing version control for configuration files
  1. Creating a separate pipeline for rollback
  1. Using Jenkins parameters to specify the version to roll back to
  1. Implementing health checks after deployment
  1. Automating the rollback process if 
etes manifests.
Microservices
  1. What are microservices and how do they differ from monolithic architecture?
Microservices are an architectural style where an application is composed of small, independent services that communicate over well-defined APIs. They differ from monolithic architecture, where the entire application is built as a single unit.
  1. What are the benefits of using microservices?
Benefits include:
  • Improved scalability
  • Better fault isolation
  • Easier to understand and maintain
  • Enables use of different technologies for different services
  • Facilitates continuous deployment
  1. How do microservices communicate with each other?
Microservices typically communicate via APIs, often using lightweight protocols like HTTP/REST or messaging queues. They can also use gRPC or GraphQL for more efficient communication.
  1. What is the role of API Gateway in microservices architecture?
An API Gateway acts as a single entry point for all client requests. It handles tasks such as routing requests to appropriate services, authentication, load balancing, and protocol translation.
  1. How do you handle data management in microservices?
Data management in microservices often involves:
  • Database per service pattern
  • Event sourcing
  • CQRS (Command Query Responsibility Segregation)
  • Saga pattern for distributed transactions
  1. Explain the concept of service discovery in microservices.
Service discovery is the process of automatically detecting services and their instances on a network. It helps microservices locate and communicate with each other dynamically.
  1. What is the Circuit Breaker pattern and why is it used in microservices?
The Circuit Breaker pattern is used to detect failures and encapsulates the logic of preventing a failure from constantly recurring. It's used to improve the system's stability and resilience.
  1. How do you ensure data consistency in a microservices architecture?
Data consistency can be ensured through:
  • Eventual consistency models
  • Distributed transactions (e.g., two-phase commit)
  • Event-driven architecture
  • Saga pattern
  1. What are the challenges of testing microservices?
Challenges include:
  • Testing service interactions
  • Managing test data across services
  • Setting up complex test environments
  • End-to-end testing across multiple services
  • Testing eventual consistency
  1. How do you handle logging and monitoring in a microservices environment?
Logging and monitoring in microservices often involve:
  • Centralized logging systems (e.g., ELK stack)
  • Distributed tracing (e.g., Jaeger, Zipkin)
  • Metrics collection and visualization (e.g., Prometheus, Grafana)
  • Health check APIs
  • Correlation IDs for request tracing across services

x

No comments:

Powered by Blogger.