diff --git a/README.md b/README.md index a339ed7..19afb85 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ - programming
Programming
+ programming
Software Development
Python
Python
go
Go
Bash
Shell Scripting
@@ -38,7 +38,7 @@ Cloud
Cloud
- aws
AWS
+ aws
AWS
azure
Azure
Google Cloud Platform
Google Cloud Platform
openstack
OpenStack
@@ -828,7 +828,19 @@ The root of the filesystem. The beginning of the tree.
-Can you create files in /proc?
+What makes /proc different from other filesystems?
+
+ +
+True or False? only root can create files in /proc
+ +False. No one can create file in /proc directly (certain operations can lead to files being created in /proc by the kernel). +
+ +
+What can be found in /proc/cmdline?
+ +The command passed to the boot loader to run the kernel
@@ -1023,7 +1035,7 @@ tail -f How you measure time execution of a program?
-#### Linux Kernel +#### Linux - Kernel
What is a kernel, and what does it do?
@@ -1054,6 +1066,68 @@ The operating system executes the kernel in protected memory to prevent anyone f Applications can access system resources and indirectly the kernel space by making what is called "system calls".
+
+In what phases of kernel lifecycle, can you change its configuration?
+ + * Build time (when it's compiled) + * Boot time (when it starts) + * Runtime (once it's already running) +
+ +
+Where can you find kernel's configuration?
+ +Usually it will reside in `/boot/config-..` +
+ +
+Where can you find the file that contains the command passed to the boot loader to run the kernel?
+ +`/proc/cmdline` +
+ +
+How to list kernel's runtime parameters?
+ +`sysctl -a` +
+ +
+Will running sysctl -a as a regular user vs. root, produce different result?
+ +Yes, you might notice that in most systems, when running `systctl -a` with root, you'll get more runtime parameters compared to executing the same command with a regular user. +
+ +
+You would like to enable IPv4 forwarding in the kernel, how would you do it?
+ +`sudo sysctl net.ipv4.ip_forward=1` + +To make it persistent (applied after reboot for example): insert `net.ipv4.ip_forward = 1` into `/etc/sysctl.conf` + +Another way to is to run `echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward` +
+ +
+How sysctl applies the changes to kernel's runtime parameters the moment you run sysctl command?
+ +If you `strace` the sysctl command you can see it does it by changing the file under /proc/sys/... + +In the past it was done with sysctl system call, but it was deprecated at some point. +
+ +
+How changes to kernel runtime parameters persist? (applied even after reboot to the system for example)
+ +There is a service called `systemd-sysctl` that takes the content of /etc/sysctl.conf and applies it. This is how changes persist, even after reboot, when they are written in /etc/sysctl.conf +
+ +
+Are the changes you make to kernel parameters in a container, affects also the kernel parameters of the host on which the container runs?
+ +No. Containers have their own /proc filesystem so any change to kernel parameters inside a container, are not affecting the host or other containers running on that host. +
+ #### Linux - SSH
@@ -2342,6 +2416,21 @@ MemAvailable - The amount of available memory for new workloads (without pushing #### Linux - Misc +
+How to generate a random string?
+ +One way is to run the following: `cat /proc/sys/kernel/random/uuid` +
+ +
+What is a Linux distribution?
+ +* A collection of packages - kernel, GNU, third party apps, ... +* Sometimes distributions store some information on the distribution in `/etc/*-release` file + * For example for Red Hat distribution it will be `/etc/redhat-release` and for Amazon it will be `/etc/os-release` + * `lsb_release` is a common command you can use in multiple different distributions +
+
Name 5 commands which are two letters long
@@ -2615,242 +2704,6 @@ Yes, it's a operating-system-level virtualization, where the kernel is shared an The introduction of virtual machines allowed companies to deploy multiple business applications on the same hardware while each application is separated from each other in secured way, where each is running on its own separate operating system.
-## Programming - -
-What programming language do you prefer to use for DevOps related tasks? Why specifically this one?
-
- -
-What are static typed (or simply typed) languages?
- -In static typed languages the variable type is known at compile-time instead of at run-time. -Such languages are: C, C++ and Java -
- -
-Explain expressions and statements
- -An expression is anything that results in a value (even if the value is None). Basically, any sequence of literals so, you can say that a string, integer, list, ... are all expressions. - -Statements are instructions executed by the interpreter like variable assignments, for loops and conditionals (if-else). -
- -
-What is Object Oriented Programming? Why is it important?
-
- -
-Explain Composition
-
- -
-What is a compiler?
-
- -
-What is an interpreter?
-
- -
-Are you familiar with SOLID design principles?
- -SOLID design principles are about: - -* Make it easier to extend the functionality of the system -* Make the code more readable and easier to maintain - -SOLID is: - -* Single Responsibility - A class should only have a single responsibility -* Open-Closed - An entity should be open for extension, but closed for modification. What this practically means is that you should extend functionality by adding a new code and not by modifying it. Your system should be separated into components so it can be easily extended without breaking everything. -* Liskov Substitution - Any derived class should be able to substitute the its parent without altering its corrections. Practically, every part of the code will get the expected result no matter which part is using it -* Interface segregation - A client should never depend on anything it doesn't uses -* Dependency Inversion - High level modules should depend on abstractions, not low level modules -
- -
-What is YAGNI? What is your opinion on it?
-
- -
-What is DRY? What is your opinion on it?
-
- -
-What are the four pillars of object oriented programming?
-
- -
-Explain recursion
-
- -
-Explain Inversion of Control
-
- -
-Explain Dependency Injection
-
- -
-True or False? In Dynamically typed languages the variable type is known at run-time instead of at compile-time
- -True -
- -
-Explain what are design patterns and describe three of them in detail
-
- -
-Explain big O notation
-
- -
-What is "Duck Typing"?
-
- -
-Explain string interpolation
-
- -##### Common algorithms - -
-Binary search: - - * How does it works? - * Can you implement it? (in any language you prefer) - * What is the average performance of the algorithm you wrote?
- -It's a search algorithm used with sorted arrays/lists to find a target value by dividing the array each iteration and comparing the middle value to the target value. If the middle value is smaller than target value, then the target value is searched in the right part of the divided array, else in the left side. This continues until the value is found (or the array divided max times) - -[python implementation](coding/python/binary_search.py) - -The average performance of the above algorithm is O(log n). Best performance can be O(1) and worst O(log n). -
- -##### Code Review - -
-What are your code-review best practices?
-
- -
-Do you agree/disagree with each of the following statements and why?: - - * The commit message is not important. When reviewing a change/patch one should focus on the actual change - * You shouldn't test your code before submitting it. This is what CI/CD exists for.
-
- -#### Strings - -
-In any language you want, write a function to determine if a given string is a palindrome
-
- -
-In any language you want, write a function to determine if two strings are Anagrams
-
- -#### Integers - -
-In any language you would like, print the numbers from 1 to a given integer. For example for input: 5, the output is: 12345
-
- -#### Time Complexity - -
-Describe what would be the time complexity of the operations access, search insert and remove for the following data structures:
- - * Stack - * Queue - * Linked List - * Binary Search Tree -
- -
-What is the complexity for the best, worst and average cases of each of the following algorithms?: - - * Quick sort - * Merge sort - * Bucket Sort - * Radix Sort
-
- -#### Data Structures & Types - -
-Implement Stack in any language you would like
-
- -
-Tell me everything you know about Linked Lists
- - * A linked list is a data structure - * It consists of a collection of nodes. Together these nodes represent a sequence - * Useful for use cases where you need to insert or remove an element from any position of the linked list - * Some programming languages don't have linked lists as a built-in data type (like Python for example) but it can be easily implemented -
- -
-Describe (no need to implement) how to detect a loop in a Linked List
- -There are multiple ways to detect a loop in a linked list. I'll mention three here: - -Worst solution:
-Two pointers where one points to the head and one points to the last node. Each time you advance the last pointer by one and check whether the distance between head pointer to the moved pointer is bigger than the last time you measured the same distance (if not, you have a loop).
-The reason it's probably the worst solution, is because time complexity here is O(n^2) - -Decent solution:
- -Create an hash table and start traversing the linked list. Every time you move, check whether the node you moved to is in the hash table. If it isn't, insert it to the hash table. If you do find at any point the node in the hash table, it means you have a loop. When you reach None/Null, it's the end and you can return "no loop" value. -This one is very easy to implement (just create a hash table, update it and check whether the node is in the hash table every time you move to the next node) but since the auxiliary space is O(n) because you create a hash table then, it's not the best solution - -Good solution:
-Instead of creating a hash table to document which nodes in the linked list you have visited, as in the previous solution, you can modify the Linked List (or the Node to be precise) to have a "visited" attribute. Every time you visit a node, you set "visited" to True.
-Time compleixty is O(n) and Auxiliary space is O(1), so it's a good solution but the only problem, is that you have to modify the Linked List. - -Best solution:
-You set two pointers to traverse the linked list from the beginning. You move one pointer by one each time and the other pointer by two. If at any point they meet, you have a loop. This solution is also called "Floyd's Cycle-Finding"
-Time complexity is O(n) and auxiliary space is O(1). Perfect :) -
- -
-Implement Hash table in any language you would like
-
- -
-What is Integer Overflow? How is it handled?
-
- -
-Name 3 design patterns. Do you know how to implement (= provide an example) these design pattern in any language you'll choose?
-
- -
-Given an array/list of integers, find 3 integers which are adding up to 0 (in any language you would like)
- -``` -def find_triplets_sum_to_zero(li): - li = sorted(li) - for i, val in enumerate(li): - low, up = 0, len(li)-1 - while low < i < up: - tmp = var + li[low] + li[up] - if tmp > 0: - up -= 1 - elif tmp < 0: - low += 1 - else: - yield li[low], val, li[up] - low += 1 - up -= 1 -``` -
- ## Python ### Python Exercises diff --git a/exercises/aws/README.md b/exercises/aws/README.md index 22f4738..404b050 100644 --- a/exercises/aws/README.md +++ b/exercises/aws/README.md @@ -68,6 +68,14 @@ Note 2: Some of the exercises cost money and can't be performed using the free t |--------|--------|------|----|----| Register Domain | Route 53 | [Exercise](register_domain.md) | [Solution](solutions/register_domain.md) | Easy | Creating Records | Route 53 | [Exercise](creating_records.md) | [Solution](solutions/creating_records.md) | Easy | +Health Checks | Route 53 | [Exercise](health_checks.md) | [Solution](solutions/health_checks.md) | Easy | +Failover | Route 53 | [Exercise](route_53_failover.md) | [Solution](solutions/route_53_failover.md) | Easy | + +#### AWS - Containers + +|Name|Topic|Objective & Instructions|Solution|Comments| +|--------|--------|------|----|----| +| ECS Task | ECS, Fargate | [Exercise](ecs_task.md) | [Solution](solutions/ecs_task.md) | Easy | #### AWS - Lambda @@ -877,30 +885,76 @@ False. Charges are being made when the code is executed. True
-#### AWS Containers +#### AWS - Containers + +##### AWS Containers - ECS
What is Amazon ECS?
-Amazon definition: "Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service. Customers such as Duolingo, Samsung, GE, and Cook Pad use ECS to run their most sensitive and mission critical applications because of its security, reliability, and scalability." +[AWS Docs](https://aws.amazon.com/ecs): "Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service. Customers such as Duolingo, Samsung, GE, and Cook Pad use ECS to run their most sensitive and mission critical applications because of its security, reliability, and scalability." -Learn more [here](https://aws.amazon.com/ecs) +In simpler words, it allows you to launch containers on AWS.
+While AWS takes care of starting/stopping containers, you need to provision and maintain the infrastructure where the containers are running (EC2 instances). +
+ +
+What one should do in order to make EC2 instance part of an ECS cluster?
+ +Install ECS agent on it. Some AMIs have built-in configuration for that. +
+ +
+What ECS launch types are there?
+ +* EC2 Instance +* AWS Fargate
What is Amazon ECR?
-Amazon definition: "Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images." - -Learn more [here](https://aws.amazon.com/ecr) +[AWS Docs](https://aws.amazon.com/ecr): "Amazon Elastic Container Registry (ECR) is a fully-managed Docker container registry that makes it easy for developers to store, manage, and deploy Docker container images."
+
+What the role "EC2 Instance Profile" is used for in regards to ECS?
+ +EC2 Instance Profile used by ECS agent on an EC2 instance to: + + * Make API calls to ECS Service + * Send logs to CloudWatch from the container + * Use secrets defined in SSM Parameter Store or Secrets Manager + * Pull container images from ECR (Registry) +
+ +
+How to share data between containers (some from ECS and some from Fargate)?
+ +Using EFS is a good way to share data between containers and it works also between different AZs. +
+ +##### AWS Containers - Fargate +
What is AWS Fargate?
-Amazon definition: "AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS)." +[Amazon Docs](https://aws.amazon.com/fargate): "AWS Fargate is a serverless, pay-as-you-go compute engine that lets you focus on building applications without managing servers. AWS Fargate is compatible with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS)" -Learn more [here](https://aws.amazon.com/fargate) +In simpler words, AWS Fargate allows you launch containers on AWS without worrying about managing infrastructure. It runs containers based on the CPU and RAM you need. +
+ +
+How AWS Fargate different from AWS ECS?
+ +In AWS ECS, you manage the infrastructure - you need to provision and configure the EC2 instances.
+While in AWS Fargate, you don't provision or manage the infrastructure, you simply focus on launching Docker containers. You can think of it as the serverless version of AWS ECS. +
+ +
+True or False? Fargate creates an ENI for every task it runs
+ +True.
#### AWS - S3 @@ -908,10 +962,8 @@ Learn more [here](https://aws.amazon.com/fargate)
Explain what is AWS S3?
-S3 stands for 3 S, Simple Storage Service. +S3 stands for: Simple Storage Service.
S3 is a object storage service which is fast, scalable and durable. S3 enables customers to upload, download or store any file or object that is up to 5 TB in size. - -More on S3 [here](https://aws.amazon.com/s3)
@@ -1941,6 +1993,12 @@ Use Elastic IP which provides you a fixed IP address. [AWS Docs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html): "An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. An Elastic IP address is allocated to your AWS account, and is yours until you release it. By using an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account."
+
+Why would you use an Elastic IP address?
+ +Let's say you have an instance that you need to shutdown or perform some maintenance on. In that case, what you would want to do is to move the Elastic IP address to another instance that is operational, until you finish to perform the maintenance and then you can move it back to the original instance (or keep it assigned to the second one). +
+
True or False? When stopping and starting an EC2 instance, its public IP changes
@@ -2366,6 +2424,147 @@ True
What is a routing policy in regards to AWS Route 53?
+ +A routing policy routing defines how Route 53 responds to DNS queries. +
+ +
+What Route 53 routing policies are there?
+ +* Simple +* Geolocation +* Failover +* Latency based +* Geoproximity +* Multi-Value Answer +* Weighted +
+ +
+Suppose you need to route % of your traffic to a certain instance and the rest of the traffic, to another instance. Which routing policy would you choose?
+ +Weighted routing policy. +
+ +
+Suppose you need to route traffic to a single source with Route 53, without any other requirements, which routing policy would you choose?
+ +The `simple` routing policy +
+ +
+Explain the geolocation routing policy
+ +* Routing based on user location +* Location can be specified by continent, country or US state +* It's recommended to have a default record in case there is no match on location +
+ +
+What are some use cases for using geolocation routing policy?
+ +* Restrict content distribution +* App localization +* Load balancing +
+ +
+Explain the geoproximity routing policy
+ +* Route based on the geographic location of resources +* Shifting routing is done based on the `bias` value +* Resources can be of AWS and non-AWS type + * For non-AWS you have to specify latitude and longitude in addition to AWS region as done in AWS-based resources +* To use it, you have to use Route 53 traffic flow +
+ +
+What are some use cases for weighted routing policy?
+ +* Load balancing between regions +* Testing new applications versions +
+ +
+True or False? Route 53 simple routing policy supports both single and multiple values
+ +True. + +If multiple values are returned from Route 53 then, the client chooses a single value to use. +
+ +
+True or False? In weighted routing DNS records must have the same name but not the same type
+ +False. They must have the same name AND type. +
+ +
+You would like to use a routing policy that will take latency into account and will route to the resource with the lowest latency. Which routing policy would you use?
+ +Latency-based routing policy. +
+ +
+What happens when you set all records to weight 0 when using Weighted routing policy?
+ +All records are used equally. +
+ +
+What Route 53 health checks are used for?
+ +Automated DNS failover based on monitoring: + + * Another health check + * endpoint (app, AWS resource, server) + * CloudWatch alarms +
+ +
+You would like to use a routing policy based on the resource location and be able to shift more traffic to some resources. Which one would you use?
+ +Geoproximity routing policy +
+ +
+Explain Route 53 Traffic Flow feature
+ +It's a visual editor for managing complex routing decision trees. It allows you to simplify the process of managing records. + +Configuration can be saved (as Traffic Flow Policy) and applied to different domains/hosted zones. In addition, it supports versioning +
+ +
+What are calculated health checks?
+ +When you combine the results of multiple health checks into a single health check. +
+ +
+What is one possible use case for using calculated health checks?
+ +Performing maintenance for a website without causing all the health checks to fail. +
+ +
+You would like to use a routing policy based on the user location. Which one would you use?
+ +Geolocation routing policy. It's based on user location. + +Don't confuse it with latency-based routing policy. While shorter distance may result in lower latency, this is not the requirement in the question. +
+ +
+True or False? Route 53 Multi Value is a substitute for those who want cheaper solution than ELB
+ +False. Route 53 Multi Value is not a substitute for ELB. It's focused on client-side load balancing as opposed to ELB. +
+ +
+True or False? Domain registrar and DNS service is inherently the same thing
+ +False. DNS service can be Route 53 (where you manage DNS records) while the domain itself can be purchased from other sources that aren't Amazon related (e.g. GoDadday).
#### AWS Monitoring & Logging @@ -2798,6 +2997,20 @@ Yes, using SNI (Server Name Indication) each application can has its own SSL cer Read Replicas use asynchronous replication so it's possible users access a read replica instance that wasn't synced yet.
+
+You need a persistent shared storage between your containers that some are running in Fargate and some in ECS. What would you use?
+ +EFS. It allows us to have persistent multi-AZ shared storage for containers. +
+ +
+You would like to run an AWS Fargate task every time a file is uploaded to a certain S3 bucket. How would you achieve that?
+ +Use Amazon EventBridge so every time a file is uploaded to an S3 bucket (event) it will run an ECS task. + +Such task should have an ECS Task Role so it can get the object from the S3 bucket (and possibly other permissions if it needs to update the DB for example). +
+ #### AWS - Architecture Design
diff --git a/exercises/aws/health_checks.md b/exercises/aws/health_checks.md new file mode 100644 index 0000000..8e26309 --- /dev/null +++ b/exercises/aws/health_checks.md @@ -0,0 +1,14 @@ +## AWS Route 53 - Health Checks + +## Requirements + +3 web instances in different AZs. + +## Objectives + +1. For each instance create a health checks with the following properties: + 1. Name it after the AZ where the instance resides + 2. Failure threshold should be 5 + +2. Edit the security group of one of your instances and remove HTTP rules. + 1. Did it change the status of the health check? diff --git a/exercises/aws/route_53_failover.md b/exercises/aws/route_53_failover.md new file mode 100644 index 0000000..4c19214 --- /dev/null +++ b/exercises/aws/route_53_failover.md @@ -0,0 +1,11 @@ +## AWS Route 53 - Failover + +### Requirements + +A running EC2 web instance with an health check defined for it in Route 53 + +### Objectives + +1. Create a failover record that will failover to another record if an health check isn't passing + 1. Make sure TTL is 30 + 2. Associate the failover record with the health check you have diff --git a/exercises/aws/solutions/health_checks.md b/exercises/aws/solutions/health_checks.md new file mode 100644 index 0000000..9eb0892 --- /dev/null +++ b/exercises/aws/solutions/health_checks.md @@ -0,0 +1,33 @@ +## AWS Route 53 - Health Checks + +## Requirements + +3 web instances in different AZs. + +## Objectives + +1. For each instance create a health checks with the following properties: + 1. Name it after the AZ where the instance resides + 2. Failure threshold should be 5 + +2. Edit the security group of one of your instances and remove HTTP rules. + 1. Did it change the status of the health check? + +### Solution + +#### Console + +1. Go to Route 53 +2. Click on "Health Checks" in the left-side menu +3. Click on "Create health check" +4. Insert the name: us-east-2 +5. What to monitor: endpoint +6. Insert the IP address of the instance +7. Insert the endpoint /health if your web instance supports that endpoint +8. In advanced configuration, set Failure threshold to 5 +9. Click on "next" and then on "Create health check" +10. Repeat steps 1-9 for the other two instances you have + +1. Go to security group of one of your instances +2. Click on "Actions" -> Edit inbound rules -> Delete HTTP based rules +3. Go back to health checks page and after a couple of seconds you should see that the status becomes "unhealthy" diff --git a/exercises/aws/solutions/route_53_failover.md b/exercises/aws/solutions/route_53_failover.md new file mode 100644 index 0000000..34b7930 --- /dev/null +++ b/exercises/aws/solutions/route_53_failover.md @@ -0,0 +1,29 @@ +## AWS Route 53 - Failover + +### Requirements + +A running EC2 web instance with an health check defined for it in Route 53 + +### Objectives + +1. Create a failover record that will failover to another record if an health check isn't passing + 1. Make sure TTL is 30 + 2. Associate the failover record with the health check you have + +### Solution + +#### Console + +1. Go to Route 53 service +2. Click on "Hosted Zones" in the left-side menu +3. Click on your hosted zone +4. Click on "Created record" +5. Insert "failover" in record name and set record type to A +6. Insert the IP of your instance +7. Set the routing policy to failover +8. Set TTL to 30 +9. Associate with an health check +10. Add another record with the same properties as the previous one +11. Click on "Create records" +12. Go to your EC2 instance and edit its security group to remove the HTTP rules +13. Use your web app and if you print the hotsname of your instance then you will notice, a failover was performed and a different EC2 instance is used diff --git a/exercises/devops/README.md b/exercises/devops/README.md index 5ed715c..2890bfc 100644 --- a/exercises/devops/README.md +++ b/exercises/devops/README.md @@ -59,6 +59,16 @@ Things to think about: * Do DevOps teams or engineers have to be innovative or practice innovation as part of their role?
+
+One of your team members suggests to set a goal of "deploying at least 20 times a day" in regards to CD. What is your take on that?
+ +A couple of thoughts: + +1. Why is it an important goal? Is it affecting the business somehow? One of the KPIs? In other words, does it matters? +2. This might introduce risks such as losing quality in favor of quantity +3. You might want to set a possibly better goal such as "be able to deploy whenever we need to deploy" +
+ #### Tooling