DMCA.com Protection Status Trending Topics About Devops

Saturday, 24 July 2021

Integrating Ansible and Docker for a CI/CD Pipeline Using Jenkins

 


Integrating Ansible and Docker for a CI/CD Pipeline Using Jenkins

In this guide, we will use Ansible as a Deployment tool in a Continuous Integration/Continuous Deployment process using Jenkins Job.

In the world of CI/CD process, Jenkins is a popular tool for provisioning development/production environments as well as application deployment through pipeline flow. Still, sometimes, it gets overwhelming to maintain the application's status, and script reusability becomes harder as the project grows.

To overcome this limitation, Ansible plays an integral part as a shell script executor, which enables Jenkins to execute the workflow of a process.

Let us begin the guide by installing Ansible on our Control node.

Install and Configure Ansible

Installing Ansible:
Here we are using CentOS 8 as our Ansible Control Node. To install Ansible, we are going to use python2-pip, and to do so, first, we have to install python2. Use the below-mentioned command to do so:

# sudo yum update
# sudo yum install python2

After Python is installed on the system, use pip2 command to install Ansible on the Control Node:

# sudo pip2 install ansible
# sudo pip2 install docker

It might take a minute or two to complete the installation, so sit tight. Once the installation is complete, verify:

# ansible --version
 
ansible 2.9.4
  config file = None
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.16 (default, Nov 17 2019, 00:07:27) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]

Through the above command, we notice that the config file path is missing, which we will create and configure later. For now, let’s move to the next section.

Configuring Ansible Control Node User:
The first thing we are going to do is create a user named ansadmin, as it is considered the best practice. So let’s create a user, by using the command adduser, which will create a new user to our system:

# useradd ansadmin

Now, use the passwd command to update the ansadmin user’s password. Make sure that you use a strong password.

# passwd ansadmin

Changing password for user ansadmin.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

Copy the password for user ansadmin and save it somewhere safe.

Once we have created the user, it's time to grant sudo access to it, so it doesn't ask for a password when we log in as root. To do so, follow the below-mentioned steps:

# nano /etc/sudoers

Go to the end of the file and paste the below-mentioned line as it is:

...
ansadmin ALL=(ALL)       NOPASSWD: ALL
...

Before moving forward, we have one last thing to do. By default, SSH password authentication is disabled in our instance. To enable it, follow the below-mentioned steps:

# nano /etc/ssh/sshd_config

Find PasswordAuthentication, uncomment it and replace no with yes, as shown below:

...
PasswordAuthentication yes
...

You will see why we are doing this in the next few steps. To reflect changes, reload the ssh service:

# service sshd reload

Now, log in as an ansadmin user on your Control Node and generate ssh key, which we will use to connect with our remote or managed host. To generate the private and public key, follow the below-mentioned commands:

# su - ansadmin

Use ssh-keygen command to generate key:

# ssh-keygen

Enter file in which to save the key (/home/ansadmin/.ssh/id_rsa): ansible-CN   
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in ansible-CN.
Your public key has been saved in ansible-CN.pub.
The key fingerprint is:
SHA256:6G0xzIrIsmsBwCakACI8CVr8AOuRR8v5F1p2+CsB6EY ansadmin@ansible-host
The key's randomart image is:
+---[RSA 3072]----+
|&+o.             |
|OO* +   .        |
|Bo.E . = .       |
|o = o =++        |
|.. o o.oS.       |
| o.. o.o.o.      |
|. + . o.o.       |
| +     ..        |
|+.               |
+----[SHA256]-----+

Usually, keys are generated in the .ssh/directory. In our case, you can find keys at /home/ansadmin/.ssh/. Now let us configure our Managed Host for Ansible.

Configuring Ansible Managed Host User:
First, we will create a user on our managed host, so log in to your host and create a user with the same name and password.

As our managed host is an Ubuntu machine, therefore here we have to use the adduser command. Please make sure that the password for the username ansadminis the same for Control and Managed Host.

# adduser ansadmin
# su - ansadmin

Other than this, it is also an excellent thing to cross-check if password authentication is enabled on the Managed Host as we need to copy the ssh public key from the control node to the Managed Host.

Switch to Control Node machine; to copy the public key to our Managed Host machine, we will use the command ssh-copy-id:

$ su - ansadmin
$ ssh-copy-id -i .ssh/ansible-CN.pub ansadmin@managed-host-ip-here 

For the first time, it will ask for the password. Enter the password for ansadmin, and you are done. Now, if you wish, you can disable Password Authentication on both machines.

Setting Ansible Inventory:
Ansible allows us to manage multiple nodes or hosts at the same time. The default location for the inventory resides in /etc/ansible/hosts. In this file, we can define groups and sub-groups.

If you remember, earlier, the hosts' file was not created automatically for our Ansible. So let's create one:

# cd /etc/ansible
# touch hosts && nano hosts

Add the following lines in your hosts' file and save it:

[docker_group]
docker_host ansible_host=your-managed-host-ip ansible_user=ansadmin ansible_ssh_private_key_file=/home/ansadmin/.ssh/ansible-CN ansible_python_interpreter=/usr/bin/python3
ansible_CN ansible_connection=local

Make sure that you replace your-managed-host-ip with your host IP address.

Let's break down the basic INI format:

  • docker_group - Heading in brackets is your designated group name.
  • docker_host & ansible_CN - The first hostname is docker_host, which points to our Managed Host. While the second hostname is ansible_CN, which is pointing towards our localhost, to be used in Ad-Hoc commands and Playbooks.
  • ansible_host - Here, you need to specify the IP address of our Managed Host.
  • ansible_user - We mentioned our Ansible user here.
  • ansible_ssh_private_key_file - Add the location of your private key.
  • ansible_python_interpreter - You can specify which Python version you want to use; by default, it will be Python2.
  • ansible_connection - This variable helps Ansible to understand that we are connecting the local machine. It also helps to avoid the SSH error.

It is time to test our Ansible Inventory, which can be done through the following command. Here we are going to use a simple Ansible module PING:

# ansible all -m ping
ansible_CN | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    }, 
    "changed": false, 
    "ping": "pong"
}
docker_host | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    }, 
    "changed": false, 
    "ping": "pong"
}

It looks like the Ansible system can now communicate with our Managed Host as well as with the localhost.

Install Docker:

We need a Docker ready system to manage our process; for this, we have to install Docker on both systems. So follow the below-mentioned steps:

For CentOS (Control Node):
Run the following command on your Control Node:

# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
 
# sudo yum-config-manager --add-repo \  https://download.docker.com/linux/centos/docker-ce.repo
 
# sudo yum install docker-ce docker-ce-cli containerd.io

In case you encounter the below-mentioned error during installation:

Error: 
 Problem: package docker-ce-3:19.03.5-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed

Next, run the following command:

# sudo yum install docker-ce docker-ce-cli containerd.io --nobest

For Ubuntu OS (Managed Host):
Run the following command on your Managed Host, which is a Ubuntu-based machine:

$ sudo apt-get remove docker docker-engine docker.io containerd runc
 
$ sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io

That’s it for this section. Next, we are going to cover how to integrate Ansible with Jenkins.

Integrating Ansible with Jenkins:

In this section, we will integrate Ansible with Jenkins. Fire up your Jenkins, go to Dashboard > Manage Jenkins > Manage Plugins > Available and then search for Publish Over SSH as shown in the image below:

Now, go to Configure System and find Publish over SSH; under this section, go to SSH Servers and click on the Add button. Here we are going to add our Docker Server as well as Ansible Server, as shown in the image:

SSH server setting for Docker:

SSH server setting for Ansible:

In the Hostname field, add your IP address or domain name of Docker and Ansible server. Before saving the setting, make sure that you test the connection before saving the configuration, by clicking on the Test Configuration button as shown in the image below:

Create Jenkins Job

The next step is to create Jenkins jobs. The sole propose of this Job is to build, test, and upload the artifact to our Ansible Server. Here we are going to create Job as a Maven Project, as shown in the image below:

Next in Job setting page, go to the Source Code Management section and add your Maven project repo URL, as shown in the image below:

Find the Build section, and in Root POMfield enter your pom.xml file name. Additionally in the Goals and options field enter clean install package:

After successful build completion, your goal is to send the war file to the specified directory to your Ansible server with the right permissions so that it doesn't give us the writing permission by assigning ansadmin to the directory.

Right now, we don't have such a directory, so let us create one. Follow the below-mentioned steps:

# sudo su
# mkdir /opt/docker
# chown ansadmin:ansadmin /opt/docker -R
# ls -al /opt/docker/

total 0
drwxr-xr-x. 2 ansadmin ansadmin  6 Jan 31 16:57 .
drwxr-xr-x. 4 root     root     38 Jan 31 17:10 ..

Directory /opt/docker will be used as our workspace, where Jenkins will upload the artifacts to Ansible Server.

Now, go to the Post-build Actions section and from the drop-down menu, select Send build artifacts over SSH, as shown in the image below:

Make sure that in the Remote Directoryfield, you enter the pattern //opt//docker as it doesn’t support special characters. Apart from this, for now, we are going to leave the Exec Commandfield empty so that we can test whether our existing configuration works or not.

Now Build the project, and you will see the following output in your Jenkins’s console output:

Go to your Ansible Server terminal and see if the artifact was sent with right user privileges:

# ls -al /opt/docker/

total 4
drwxr-xr-x. 2 ansadmin ansadmin   24 Feb  3 10:54 .
drwxr-xr-x. 4 root     root       38 Jan 31 17:10 ..
-rw-rw-r--. 1 ansadmin ansadmin 2531 Feb  3 10:54 webapp.war

It looks like our webapp.war file was transferred successfully. In the following step, we will create an Ansible Playbook and Dockerfile.


Creating Dockerfile and Ansible Playbook:

To create a Docker Image with the webapp.war file, first, we will create a DockerFile. Follow the below-mentioned steps:

First, log in to your Ansible Server and go to directory /opt/docker and create a file named as Dockerfile:

# cd /opt/docker/
# touch Dockerfile

Now open the Dockerfile in your preferred editor, and copy the below-mentioned lines and save it:

FROM tomcat:8.5.50-jdk8-openjdk
MAINTAINER Your-Name-Here
COPY ./webapp.war /usr/local/tomcat/webapps

Here instructions are to pull a Tomcat image with tag 8.5.50-jdk8-openjdk and copying the webapp.war file to Tomcat default webapp directory., which is /usr/local/tomcat/webapps

With the help of this Dockerfile, we will create a Docker container. So let us create the Ansible Playbook, which will enable us to automate the Docker image build process and later run the Docker container out of it.

We are creating a Ansible Playbook, which does two tasks for us:

  1. Pull Tomcat’s latest version and build an image using webapp.war file.
  2. Run the built image on the desired host.

For this, we are going to create a new YAML format file for your Ansible Playbook:

# nano simple-ansible.yaml

Now copy the below-mentioned line into your simple-ansible.yaml file:

---
#Simple Ansible Playbook to build and run a Docker containers
 
- name: Playbook to build and run Docker
  hosts: all
  become: true
  gather_facts: false
 
  tasks:
    - name: Build a Docker image using webapp.war file
      docker_image:
        name: simple-docker-image
        build:
          path: /opt/docker
          pull: false
        source: build
 
    - name: Run Docker container using simple-docker-image
      docker_container:
        name: simple-docker-container
        image: simple-docker-image:latest
        state: started
        recreate: yes
        detach: true
        ports:
          - "8888:8080"

You can get more help here: docker_imageand docker_container. Now, as our Playbook is created, we can run a test to see if it works as planned:

# cd /opt/docker
# ansible-playbook simple-ansible-playbook.yaml --limit ansible_CN

Here we have used the --limit flag, which means it will only run on our Ansible Server (Control Node). You might see the following output, in your terminal window:

PLAY [Playbook to build and run Docker] 
***************************************************************************
 
TASK [Build Docker image using webapp.war file] 
***************************************************************************
changed: [ansible_CN]
 
TASK [Run Docker image using simple-docker-image]
***************************************************************************
changed: [ansible_CN]
 
PLAY RECAP 
***************************************************************************
ansible_CN                 : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Look's like Playbook ran sccessfully and no error was detected during the Ansible Playbook check, so now we can move to Jenkins to complete our CI/CD process using Ansible.

Run Ansible Playbook using Jenkins

In this step, we would execute our Ansible Playbook (i.e., simple-ansible-playbook.yaml) file, and to do so let us go back to the Project Configuration page in Jenkins and find Post-build Actions there.

In this section, copy the below-mentioned command in the Exec command field:

sudo ansible-playbook --limit ansible_CN /opt/docker/simple-ansible-playbook.yaml;

Now, let us try to build the project and see the Jenkins Job's console output:

In the output, you can see that our Ansible playbook ran successfully. Let us verify if at Ansible Server the image is created and the container is running:

For Docker Image list:

# docker images
 
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
simple-docker-image   latest              d47875d99095        32 seconds ago      507MB
tomcat                latest              5692d26ea179        15 hours ago        507MB

For Docker Container list:

# docker ps

CONTAINER ID        IMAGE                        COMMAND             CREATED             STATUS              PORTS                    NAMES
5a824d0a43d5        simple-docker-image:latest   "catalina.sh run"   15 seconds ago      Up 14 seconds       0.0.0.0:8888->8080/tcp   simple-docker-container

It looks like Jenkins was able to run the Ansible Playbook successfully. Next, we are going to push Docker Image to Docker Hub.

Pushing Docker Image to Docker Hub Using Ansible

We are going to use Docker Hub public repository for this guide; in case you want to work on a live project, then you should consider using the Docker Hub private registry.

For this step, you have to create a Docker Hub account if you haven’t had one yet.

Our end goal for this step is to publish the Docker Image to Docker Hub using Ansible Playbook. So go to your Ansible Control Node and follow the below-mentioned steps:

# docker login
 
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: your-docker-hub-user
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
 
Login Succeeded

Make sure that you enter the right username and password.

Now it’s time to create a new Ansible Playbook which will build and push the Docker image to your Docker Hub account. Note that this image will be publicly available, so be cautious.

# nano build-push.yaml

Create a new Ansible Playbook, which will build a Docker image and push it to our Docker Hub account:

---
#Simple Ansible Playbook to build and push Docker image to Registry
 
- name: Playbook to build and run Docker
  hosts: ansible_CN
  become: true
  gather_facts: false
 
  tasks:
    - name: Delete existing Docker images from the Control Node
      shell: docker rmi $(docker images -q) -f 
      ignore_errors: yes
 
    - name: Push Docker image to Registry
      docker_image:
        name: simple-docker-image
        build:
          path: /opt/docker
          pull: true
        state: present
        tag: "latest"
        force_tag: yes
        repository: gauravsadawarte/simple-docker-image:latest
        push: yes
        source: build

Let us run the playbook now and see what we get:

# ansible-playbook --limit ansible_CN build-push.yaml
 
PLAY [Playbook to build and run Docker] 
*****************************************************************************************
 
TASK [Push Docker image to Registry] 
*****************************************************************************************
changed: [ansible_CN]
 
PLAY RECAP 
*****************************************************************************************
ansible_CN                 : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Go to your Docker Hub account and see if the image was pushed successfully, as shown in the image below:

Next, let us modify our simple-ansible-playbook.yaml playbook, which we created earlier, as from here on, we are going to pull the Docker image from Docker Hub Account and create a container out of it.

---
#Simple Ansible Playbook to pull Docker Image from the registry and run a Docker containers
 
- import_playbook: build-push.yaml
 
- name: Playbook to build and run Docker
  hosts: docker_host
  gather_facts: false
 
  tasks:
    - name: Run Docker container using simple-docker-image
      docker_container:
        name: simple-docker-container
        image: gauravsadawarte/simple-docker-image:latest
        state: started
        recreate: yes
        detach: true
        pull: yes
        ports:
          - "8888:8080"

Note that we have used the import_playbook statement at the top of the existing playbook, which means that we want to run the build-push.yamlplaybook first along with our main playbook, and this way, we don’t have to run multiple playbooks manually.

Let us break the whole process into steps:

  1. With the help of build-push.yamlplaybook, we are asking Ansible to build an image with the artifacts sent by Jenkins to our Control Node, and later push the built image (i.e., simple-docker-image) to our Docker Hub’s account or any other private registry like AWS ECR or Google’s Container Registry.
  2. In the simple-ansible-playbook.yaml file, we have imported the build-push.yaml file, which is going to run prior to any statement present within the simple-ansible-playbook.yamlfile.
  3. Once build-push.yaml playbook is executed, Ansible will launch a container into our Managed Docker Host by pulling our image from our defined registry.

Now, it's time to build our job. So in the next step, we will deploy the artifact to our Control Node, where Ansible Playbook will build an image, push to Docker Hub and run the container in Managed Host. Let us get started!

Jenkins Jobs to Deploy Docker Container Using Ansible

To begin, go to JenkinstoDockerUsingAnsible configure page and change the Exec command in the Post-build Actions section.

Copy the below-mentioned command and add it as shown in the image below:

sudo ansible-playbook /opt/docker/simple-ansible-playbook.yaml;

Save the configuration and start the build; you will see the following output:

Now go to your Control Node and verify if our images were built:

# docker images
REPOSITORY                            TAG                   IMAGE ID            CREATED             SIZE
gauravsadawarte/simple-docker-image   latest                9ccd91b55796        2 minutes ago       529MB
simple-docker-image                   latest                9ccd91b55796        2 minutes ago       529MB
tomcat                                8.5.50-jdk8-openjdk   b56d8850aed5        5 days ago          529MB

It looks like Ansible Playbook was successfully executed on our Control Node. It’s time to verify if Ansible was able to launch containers on our Managed Host or not.

Go to your Managed Host and enter the following command:

# docker ps
CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS              PORTS                               NAMES
6f5e18c20a68        gauravsadawarte/simple-docker-image:latest   "catalina.sh run"        4 minutes ago       Up 4 minutes        0.0.0.0:8888->8080/tcp              simple-docker-container

Now visit the following URL http://your-ip-addr:8888/webapp/ in your browser. Note that, Tomcat Server may take some time before you can see the output showing your project is successfully setup.

And you are done!

You successfully managed to deploy your application using Jenkins, Ansible, and Docker. Now, whenever someone from your team pushes code to the repository, Jenkins will build the artifact and send it to Ansible, from there Ansible will be responsible for publishing the application to the desired machine.

Friday, 23 July 2021

*Top 10 Sites for your career in 2021:*


1. LinkedIN

2. Indeed

3. Naukri

4. Monster

5. JobBait

6. Careercloud

7. Dice

8. CareerBuilder

9. Jibberjobber

10. Glassdoor


*Top 10 Tech Skills in demand in 2021:*


1. Machine Learning

2. Mobile Development

3. SEO/SEM Marketing

4. Data Visualization

5. Data Engineering

6. UI/UX Design

7. Cyber-security

8. Cloud Computing/AWS

9. Blockchain

10. IOT


*Top 10 Sites for Free Online Education:*


1. Coursera

2. edX

3. Khan Academy

4. Udemy

5. iTunesU Free Courses

6. MIT OpenCourseWare

7. Stanford Online

8. Codecademy

9. Open Culture Online Courses


*Top 10 Sites to learn Excel for free:*


1. Microsoft Excel Help Center

2. Excel Exposure

3. Chandoo

4. Excel Central

5. Contextures

6. Excel Hero

7. Mr. Excel

8. Improve Your Excel

9. Excel Easy

10. Excel Jet


*Top 10 Sites to review your resume for free:*


1. Zety Resume Builder

2. Resumonk

3. Resume dot com

4. VisualCV

5. Cvmaker

6. ResumUP

7. Resume Genius

8. Resumebuilder

9. Resume Baking

10. Enhancv


*Top 10 Sites for Interview Preparation:*


1. Ambitionbox

2. AceTheInterview

3. Geeksforgeeks

4. Leetcode

5. Gainlo

6. Careercup

7. Codercareer

8. InterviewUp

9. InterviewBest

10. Indiabix


*Top 3 Sites for Pharma Jobs:*

1. Daily Pharma Jobs

2. Pharma Wisdom

3. Pharma Job Alert

Thursday, 15 July 2021

DevOps Tools

 Describe each of the following components in Ansible, including the relationship between them:

  • Task
  • Module
  • Play
  • Playbook
  • Role

How Ansible is different from other Automation tools?

Ansible is:

  • Agentless
  • Minimal run requirements (Python & SSH) and simple to use
  • Default mode is "push" (it supports also pull)
  • Focus on simpleness and ease-of-use
True or False? Ansible follows the mutable infrastructure paradigm

True.

True or False? Ansible uses declarative style to describe the expected end state
False. It uses a procedural style.
What kind of automation you wouldn't do with Ansible and why?

While it's possible to provision resources with Ansible, some prefer to use tools that follow immutable infrastructure paradigm. Ansible doesn't saves state by default. So a task that creates 5 instances for example, when executed again will create additional 5 instances (unless additional check is implemented) while other tools will check if 5 instances exist. If only 4 exist, additional instance will be created.

What is an inventory file and how do you define one?

An inventory file defines hosts and/or groups of hosts on which Ansible tasks executed upon.

An example of inventory file:

192.168.1.2
192.168.1.3
192.168.1.4

[web_servers]
190.40.2.20
190.40.2.21
190.40.2.22

What is a dynamic inventory file? When you would use one?

A dynamic inventory file tracks hosts from one or more sources like cloud providers and CMDB systems.

You should use one when using external sources and especially when the hosts in your environment are being automatically
spun up and shut down, without you tracking every change in these sources.

How do you list all modules and how can you see details on a specific module?

  1. Ansible online docs
  2. ansible-doc -l for list of modules and ansible [module_name] for detailed information on a specific module
Write a task to create the directory ‘/tmp/new_directory’
- name: Create a new directory
  file:
    path: "/tmp/new_directory"
    state: directory

You want to run Ansible playbook only on specific minor version of your OS, how would you achieve that?
What the "become" directive used for in Ansible?
What are facts? How to see all the facts of a certain host?
What would be the result of the following play?
---
- name: Print information about my host
  hosts: localhost
  gather_facts: 'no'
  tasks:
      - name: Print hostname
        debug:
            msg: "It's me, {{ ansible_hostname }}"

When given a written code, always inspect it thoroughly. If your answer is “this will fail” then you are right. We are using a fact (ansible_hostname), which is a gathered piece of information from the host we are running on. But in this case, we disabled facts gathering (gather_facts: no) so the variable would be undefined which will result in failure.

What would be the result of running the following task? How to fix it?
- hosts: localhost
  tasks:
      - name: Install zlib
        package:
          name: zlib
          state: present
Which Ansible best practices are you familiar with?. Name at least three
Explain the directory layout of an Ansible role
What 'blocks' are used for in Ansible?
How do you handle errors in Ansible?
You would like to run a certain command if a task fails. How would you achieve that?
Write a playbook to install ‘zlib’ and ‘vim’ on all hosts if the file ‘/tmp/mario’ exists on the system.
---
- hosts: all
  vars:
      mario_file: /tmp/mario
      package_list:
          - 'zlib'
          - 'vim'
  tasks:
      - name: Check for mario file
        stat:
            path: "{{ mario_file }}"
        register: mario_f

      - name: Install zlib and vim if mario file exists
        become: "yes"
        package:
            name: "{{ item }}"
            state: present
        with_items: "{{ package_list }}"
        when: mario_f.stat.exists

Write a single task that verifies all the files in files_list variable exist on the host
- name: Ensure all files exist
  assert:
    that:
      - item.stat.exists
  loop: "{{ files_list }}"

Write a playbook to deploy the file ‘/tmp/system_info’ on all hosts except for controllers group, with the following content
I'm <HOSTNAME> and my operating system is <OS>

Replace and with the actual data for the specific host you are running on

The playbook to deploy the system_info file

---
- name: Deploy /tmp/system_info file
  hosts: all:!controllers
  tasks:
      - name: Deploy /tmp/system_info
        template:
            src: system_info.j2
            dest: /tmp/system_info

The content of the system_info.j2 template

# {{ ansible_managed }}
I'm {{ ansible_hostname }} and my operating system is {{ ansible_distribution }

The variable 'whoami' defined in the following places:
  • role defaults -> whoami: mario
  • extra vars (variables you pass to Ansible CLI with -e) -> whoami: toad
  • host facts -> whoami: luigi
  • inventory variables (doesn’t matter which type) -> whoami: browser

According to variable precedence, which one will be used?

For each of the following statements determine if it's true or false:
  • A module is a collection of tasks
  • It’s better to use shell or command instead of a specific module
  • Host facts override play variables
  • A role might include the following: vars, meta, and handlers
  • Dynamic inventory is generated by extracting information from external sources
  • It’s a best practice to use indention of 2 spaces instead of 4
  • ‘notify’ used to trigger handlers
  • This “hosts: all:!controllers” means ‘run only on controllers group hosts
Explain the Diffrence between Forks and Serial & Throttle.

Serial is like running the playbook for each host in turn, waiting for completion of the complete playbook before moving on to the next host. forks=1 means run the first task in a play on one host before running the same task on the next host, so the first task will be run for each host before the next task is touched. Default fork is 5 in ansible.

[defaults]
forks = 30
- hosts: webservers
  serial: 1
  tasks:
    - name: ...

Ansible also supports throttle This keyword limits the number of workers up to the maximum set via the forks setting or serial. This can be useful in restricting tasks that may be CPU-intensive or interact with a rate-limiting API

tasks:
- command: /path/to/cpu_intensive_command
  throttle: 1

What is ansible-pull? How is it different from how ansible-playbook works?
What is Ansible Vault?
Demonstrate each of the following with Ansible:
  • Conditionals
  • Loops
What are filters? Do you have experience with writing filters?
Write a filter to capitalize a string
def cap(self, string):
    return string.capitalize()

You would like to run a task only if previous task changed anything. How would you achieve that?
What are callback plugins? What can you achieve by using callback plugins?
What is Ansible Collections?
File '/tmp/exercise' includes the following content
Goku = 9001
Vegeta = 5200
Trunks = 6000
Gotenks = 32

With one task, switch the content to:

Goku = 9001
Vegeta = 250
Trunks = 40
Gotenks = 32

Ansible Testing

How do you test your Ansible based projects?
What is Molecule? How does it works?
You run Ansibe tests and you get "idempotence test failed". What does it mean? Why idempotence is important?

Terraform

Explain what Terraform is and how does it works

What benefits infrastructure-as-code has?
Why Terraform and not other technologies? (e.g. Ansible, Puppet, CloufFormation)
True or False? Terraform follows the mutable infrastructure paradigm

True or False? Terraform uses declarative style to describe the expected end state
Explain what is "Terraform configuration"
What is HCL?
Explain each of the following:
  • Provider
  • Resource
  • Provisioner
What terraform.tfstate file is used for?

How do you rename an existing resource?

Explain what the following commands do:
  • terraform init
  • terraform plan
  • terraform validate
  • terraform apply

How to write down a variable which changes by an external source or during terraform apply?

Give an example of several Terraform best practices
Explain how implicit and explicit dependencies work in Terraform
What is local-exec and remote-exec in the context of provisioners?
What is a "tainted resource"?

What terraform taint does?
What types of variables are supported in Terraform?

What is a data source? In what scenarios for example would need to use it?
What are output variables and what terraform output does?
Explain Modules

What is the Terraform Registry?

Explain remote-exec and local-exec
Explain "Remote State". When would you use it and how?
Explain "State Locking"
What is the "Random" provider? What is it used for
How do you test a terraform module?
Aside from .tfvars files or CLI arguments, how can you inject dependencies from other modules?

Containers

Containers Exercises

NameTopicObjective & InstructionsSolutionComments
My First DockerfileDockerfileLinkLink

Containers Self Assesment

What is a Container? What is it used for?

How are containers different from virtual machines (VMs)?
In which scenarios would you use containers and in which you would prefer to use VMs?
Explain Podman or Docker architecture
Describe in detail what happens when you run `podman/docker run hello-world`?

What are `dockerd, docker-containerd, docker-runc, docker-containerd-ctr, docker-containerd-shim` ?

Describe difference between cgroups and namespaces

Describe in detail what happens when you run `docker pull image:tag`?

How do you run a container?

What `podman commit` does?. When will you use it?

How would you transfer data from one container into another?
What happens to data of the container when a container exists?
Explain what each of the following commands do:
  • docker run
  • docker rm
  • docker ps
  • docker pull
  • docker build
  • docker commit
How do you remove old, non running, containers?
Dockerfile
What is Dockerfile

What is the difference between ADD and COPY in Dockerfile?

What is the difference between CMD and RUN in Dockerfile?

Do you perform any checks or testing related to your Dockerfile?

Explain what is Docker compose and what is it used for

Describe the process of using Docker Compose
Explain Docker interlock
Where can you store Docker images?
What is Docker Hub?
What is the difference between Docker Hub and Docker cloud?

What is Docker Repository?
Explain image layers

What best practices are you familiar related to working with containers?
How do you manage persistent storage in Docker?
How can you connect from the inside of your container to the localhost of your host, where the container runs?
How do you copy files from Docker container to the host and vice versa?

Kubernetes

Kubernetes Exercises

Developer & Regular User Path

NameTopicObjective & InstructionsSolutionComments
My First PodPodsExerciseSolution
Creating a serviceServiceExerciseSolution

Kubernetes Self Assesment

What is Kubernetes? Why organizations are using it?
What is a Kubernetes Cluster?

When or why NOT to use Kubernetes?

Kubernetes Nodes

What is a Node?

What the master node is responsible for?
What do we need the worker nodes for?

What is kubectl?
Which command you run to view your nodes?

True or False? Every cluster must have 0 or more master nodes and at least on e worker

What are the components of the master node?
What are the components of a worker node?

Kubernetes Pod

Explain what is a pod

Deploy a pod called "my-pod" using the nginx:alpine image

How many containers can a pod contain?

What does it mean that "pods are ephemeral?

Which command you run to view all pods running on all namespaces?

How to delete a pod?

Kubernetes Deployment

What is a "Deployment" in Kubernetes?

How to create a deployment?

How to edit a deployment?

What happens after you edit a deployment and change the image?

How to delete a deployment?

What happens when you delete a deployment?

How make an app accessible on private or external network?

Kubernetes Service

What is a Service in Kubernetes?

True or False? The lifecycle of Pods and Services isn't connected so when a pod dies, the service still stays

What Service types are there?

How to get information on a certain service?

How to verify that a certain service forwards the requests to a pod

What is the difference between an external and an internal service?
How to turn the following service into an external one?
spec:
  selector:
    app: some-app
  ports:
    - protocol: TCP
      port: 8081
      targetPort: 8081

What would you use to route traffic from outside the Kubernetes cluster to services within a cluster?

Kubernetes Ingress

What is Ingress?

Complete the following configuration file to make it Ingress
metadata:
  name: someapp-ingress
spec:

Explain the meaning of "http", "host" and "backend" directives
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: someapp-ingress
spec:
  rules:
  - host: my.host
    http:
      paths:
      - backend:
          serviceName: someapp-internal-service
          servicePort: 8080

What is Ingress Controller?

What are some use cases for using Ingress?
How to list Ingress in your namespace?

What is Ingress Default Backend?

How to configure a default backend?

How to configure TLS with Ingress?

True or False? When configuring Ingress with TLS, the Secret component must be in the same namespace as the Ingress component

Kubernetes Configuration File

Which parts a configuration file has?
What is the format of a configuration file?

How to get latest configuration of a deployment?

Where Kubernetes gets the status data (which is added to the configuration file) from?

Kubernetes etcd

What is etcd?
True or False? Etcd holds the current status of any kubernetes component

True or False? The API server is the only component which communicates directly with etcd

True or False? application data is not stored in etcd

Kubernetes Namespaces

What are namespaces?

Why to use namespaces? What is the problem with using one default namespace?

True or False? When a namespace is deleted all resources in that namespace are not deleted but moved to another default namespace

What special namespaces are there by default when creating a Kubernetes cluster?
What can you find in kube-system namespace?
How to list all namespaces?

What kube-public contains?
How to get the name of the current namespace?

What kube-node-lease contains?

How to create a namespace?

What default namespace contains?

True or False? With namespaces you can limit the resources consumed by the users/teams

How to switch to another namespace? In other words how to change active namespace?

What is Resource Quota?
How to create a Resource Quota?

Which resources are accessible from different namespaces?

Let's say you have three namespaces: x, y and z. In x namespace you have a ConfigMap referencing service in z namespace. Can you reference the ConfigMap in x namespace from y namespace?

Which service and in which namespace the following file is referencing?
apiVersion: v1
kind: ConfigMap
metadata:
  name: some-configmap
data:
  some_url: samurai.jack

Which components can't be created within a namespace?

How to list all the components that bound to a namespace?

How to create components in a namespace?

Kubernetes Commands

What kubectl exec does?
What kubectl get all does?
What the command kubectl get pod does?
How to see all the components of a certain application?

What kubectl apply -f [file] does?
What the command kubectl api-resources --namespaced=false does?

How to print information on a specific pod?

How to execute the command "ls" in an existing pod?

How to create a service that exposes a deployment?

How to create a pod and a service with one command?

Describe in detail what the following command does kubectl create deployment kubernetes-httpd --image=httpd
Why to create kind deployment, if pods can be launched with replicaset?
How to scale a deployment to 8 replicas?

How to get list of resources which are not in a namespace?

How to delete all pods whose status is not "Running"?

What kubectl logs [pod-name] command does?
What kubectl describe pod [pod name] does? command does?
How to display the resources usages of pods?

What kubectl get componentstatus does?

What is Minikube?

How do you monitor your Kubernetes?
You suspect one of the pods is having issues, what do you do?

What the Kubernetes Scheduler does?
What happens to running pods if if you stop Kubelet on the worker nodes?
What happens what pods are using too much memory? (more than its limit)

Describe how roll-back works
True or False? Memory is a compressible resource, meaning that when a container reach the memory limit, it will keep running

What is the control loop? How it works?

Kubernetes Operator

What is an Operator?

Why do we need Operators?

What components the Operator consists of?
How Operator works?

True or False? Kubernetes Operator used for stateful applications

What is the Operator Framework?

What components the Operator Framework consists of?
Describe in detail what is the Operator Lifecycle Manager

What openshift-operator-lifecycle-manager namespace includes?
What is kubconfig? What do you use it for?
Can you use a Deployment for stateful applications?
Explain StatefulSet

Kubernetes ReplicaSet

What is the purpose of ReplicaSet?
How a ReplicaSet works?
What happens when a replica dies?

Kubernetes Secrets

Explain Kubernetes Secrets

How to create a Secret from a key and value?

How to create a Secret from a file?

What type: Opaque in a secret file means? What other types are there?

True or False? storing data in a Secret component makes it automatically secured

What is the problem with the following Secret file:
apiVersion: v1   
kind: Secret
metadata:
    name: some-secret
type: Opaque
data:
    password: mySecretPassword
How to create a Secret from a configuration file?

What the following in Deployment configuration file means?
spec:
  containers:
    - name: USER_PASSWORD
      valueFrom:
        secretKeyRef:
          name: some-secret
          key: password

Kubernetes Storage

True or False? Kubernetes provides data persistence out of the box, so when you restart a pod, data is saved

Explain "Persistent Volumes". Why do we need it?

True or False? Persistent Volume must be available to all nodes because the pod can restart on any of them

What types of persistent volumes are there?
What is PersistentVolumeClaim?
True or False? Kubernetes manages data persistence

Explain Storage Classes
Explain "Dynamic Provisioning" and "Static Provisioning"
Explain Access Modes
What is Reclaim Policy?
What reclaim policies are there?

Kubernetes Access Control

What is RBAC?
Explain the Role and RoleBinding" objects
What is the difference between Role and ClusterRole objects?

Kubernetes Misc

Explain what Kubernetes Service Discovery means
You have one Kubernetes cluster and multiple teams that would like to use it. You would like to limit the resources each team consumes in the cluster. Which Kubernetes concept would you use for that?

What Kube Proxy does?
What "Resources Quotas" are used for and how?
Explain ConfigMap
How to use ConfigMaps?
Trur or False? Sensitive data, like credentials, should be stored in a ConfigMap

Explain "Horizontal Pod Autoscaler"

When you delete a pod, is it deleted instantly? (a moment after running the command)
How to delete a pod instantly?

Explain Liveness probe
Explain Readiness probe
What does being cloud-native mean?
Explain the pet and cattle approach of infrastructure with respect to kubernetes
Describe how you one proceeds to run a containerised web app in K8s, which should be reachable from a public URL.
How would you troubleshoot your cluster if some applications are not reachable any more?
Describe what CustomResourceDefinitions there are in the Kubernetes world? What they can be used for?
How does scheduling work in kubernetes?

How are labels and selectors used?
Explain what is CronJob and what is it used for
What QoS classes are there?
Explain Labels. What are they and why would one use them?
Explain Selectors
What is Kubeconfig?

Helm

What is Helm?

Why do we need Helm? What would be the use case for using it?

Explain "Helm Charts"

It is said that Helm is also Templating Engine. What does it mean?

What are some use cases for using Helm template file?
Explain the Helm Chart Directory Structure

How do you search for charts?

Is it possible to override values in values.yaml file when installing a chart?

How Helm supports release management?

Submariner

Explain what is Submariner and what is it used for

What each of the following components does?:
  • Lighthouse
  • Broker
  • Gateway Engine
  • Route Agent

Istio

What is Istio? What is it used for?

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?

Explain expressions and statements

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

Explain what are design patterns and describe three of them in detail
Explain big O notation
What is "Duck Typing"?
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?

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 accesssearch insert and remove for the following data structures:
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
Describe (no need to implement) how to detect a loop in a Linked List

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)

Python

What are some characteristics of the Python programming language?

What built-in types Python has?

What is mutability? Which of the built-in types in Python are mutable?

What is a tuple in Python? What is it used for?

List, like a tuple, is also used for storing multiple items. What is then, the difference between a tuple and a list?

What is the result of each of the following?
  • 1 > 2

  • 'b' > 'a'

  • 1 == 'one'

  • 2 > 'one'

What is the result of of each of the following?
  • "abc"*3

  • "abc"*2.5

  • "abc"*2.0

  • "abc"*True

  • "abc"*False

What is the result of `bool("")`? What about `bool(" ")`? Explain

What is the result of running [] is not []? explain the result

Improve the following code:
char = input("Insert a character: ")
if char == "a" or char == "o" or char == "e" or char =="u" or char == "i":
    print("It's a vowel!")

How to define a function with Python?

In Python, functions are first-class objects. What does it mean?

Explain inheritance and how to use it in Python

Explain and demonstrate class attributes & instance attributes

Python - Exceptions

What is an error? What is an exception? What types of exceptions are you familiar with?

Explain Exception Handling and how to use it in Python

What is the result of running the following function?
def true_or_false():
    try:
        return True
    finally:
        return False

Python Built-in functions

Explain the following built-in functions (their purpose + use case example):
  • repr
  • any
  • all
What is the difference between repr function and str?
What is the __call__ method?
Do classes has the __call__ method as well? What for?
What _ is used for in Python?
Explain what is GIL
What is Lambda? How is it used?

Properties

Are there private variables in Python? How would you make an attribute of a class, private?
Explain the following:
  • getter
  • setter
  • deleter
Explain what is @property
How do you swap values between two variables?

Explain the following object's magic variables:
  • dict
Write a function to return the sum of one or more numbers. The user will decide how many numbers to use

Print the average of [2, 5, 6]. It should be rounded to 3 decimal places

Python Lists

How to add the number 2 to the list x = [1, 2, 3]

How to check how many items a list contains?

How to get the last element of a list?

How to add the items of [1, 2, 3] to the list [4, 5, 6]?

How to remove the first 3 items from a list?

How do you get the maximum and minimum values from a list?

How to get the top/biggest 3 items from a list?

How to insert an item to the beginning of a list? What about two items?
How to sort list by the length of items?

Do you know what is the difference between list.sort() and sorted(list)?

Convert every string to an integer: [['1', '2', '3'], ['4', '5', '6']]

How to merge two sorted lists into one sorted list?

How to check if all the elements in a given lists are unique? so [1, 2, 3] is unique but [1, 1, 2, 3] is not unique because 1 exists twice
You have the following function
def my_func(li = []):
    li.append("hmm")
    print(li)

If we call it 3 times, what would be the result each call?

How to iterate over a list?

How to iterate over a list with indexes?

How to start list iteration from 2nd index?

How to iterate over a list in reverse order?

Sort a list of lists by the second item of each nested list

Combine [1, 2, 3] and ['x', 'y', 'z'] so the result is [(1, 'x'), (2, 'y'), (3, 'z')]

What is List Comprehension? Is it better than a typical loop? Why? Can you demonstrate how to use it?
You have the following list: [{'name': 'Mario', 'food': ['mushrooms', 'goombas']}, {'name': 'Luigi', 'food': ['mushrooms', 'turtles']}] Extract all type of foods. Final output should be: {'mushrooms', 'goombas', 'turtles'}

Python Dictionaries

How to create a dictionary?

How to remove a key from a dictionary?

How to sort a dictionary by values?

How to sort a dictionary by keys?

How to merge two dictionaries?

Convert the string "a.b.c" to the dictionary {'a': {'b': {'c': 1}}}

Common Algorithms Implementation
Can you implement "binary search" in Python?

Python Files

How to write to a file?

How to print the 12th line of a file?
How to reverse a file?
Sum all the integers in a given file
Print a random line of a given file
Print every 3rd line of a given file
Print the number of lines in a given file
Print the number of of words in a given file
Can you write a function which will print all the file in a given directory? including sub-directories
Write a dictionary (variable) to a file

Python OS

How to print current working directory?

Given the path /dir1/dir2/file1 print the file name (file1)

Given the path /dir1/dir2/file1
  1. Print the path without the file name (/dir1/dir2)
  2. Print the name of the directory where the file resides (dir2)

How do you execute shell commands using Python?
How do you join path components? for example /home and luig will result in /home/luigi
How do you remove non-empty directory?

Python Regex

How do you perform regular expressions related operations in Python? (match patterns, substitute strings, etc.)

How to substitute the string "green" with "blue"?
How to find all the IP addresses in a variable? How to find them in a file?

Python Strings

Find the first repeated character in a string

How to extract the unique characters from a string? for example given the input "itssssssameeeemarioooooo" the output will be "mrtisaoe"

Find all the permutations of a given string

How to check if a string contains a sub string?
Find the frequency of each character in string
Count the number of spaces in a string
Given a string, find the N most repeated words
Given the string (which represents a matrix) "1 2 3\n4 5 6\n7 8 9" create rows and colums variables (should contain integers, not strings)
What is the result of each of the following?
>> ', '.join(["One", "Two", "Three"])
>> " ".join("welladsadgadoneadsadga".split("adsadga")[:2])
>> "".join(["c", "t", "o", "a", "o", "q", "l"])[0::2]

How to reverse a string? (e.g. pizza -> azzip)

Reverse each word in a string (while keeping the order)
What is the output of the following code: "".join(["a", "h", "m", "a", "h", "a", "n", "q", "r", "l", "o", "i", "f", "o", "o"])[2::3]

Python Iterators

What is an iterator?

Python Misc

Explain data serialization and how do you perform it with Python
How do you handle argument parsing in Python?
What is a generator? Why using generators?
What would be the output of the following block?
for i in range(3, 3):
   print(i)

What is yeild? When would you use it?
Explain the following types of methods and how to use them:
  • Static method
  • Class method
  • instance method
How to reverse a list?
How to combine list of strings into one string with spaces between the strings
You have the following list of nested lists: [['Mario', 90], ['Geralt', 82], ['Gordon', 88]] How to sort the list by the numbers in the nested lists?

Explain the following:
  • zip()
  • map()
  • filter()

Python - Slicing

For the following slicing exercises, assume you have the following list: my_list = [8, 2, 1, 10, 5, 4, 3, 9]

What is the result of `my_list[0:4]`?
What is the result of `my_list[5:6]`?
What is the result of `my_list[5:5]`?
What is the result of `my_list[::-1]`?
What is the result of `my_list[::3]`?
What is the result of `my_list[2:]`?
What is the result of `my_list[:3]`?

Python Debugging

How do you debug Python code?

How to check how much time it took to execute a certain script or block of code?
What empty return returns?

How to improve the following block of code?
li = []
for i in range(1, 10):
    li.append(i)

Given the following function
def is_int(num):
    if isinstance(num, int):
        print('Yes')
    else:
        print('No')

What would be the result of is_int(2) and is_int(False)?

Python - Linked List

Can you implement a linked list in Python?

Add a method to the Linked List class to traverse (print every node's data) the linked list

Write a method to that will return a boolean based on whether there is a loop in a linked list or not

Python - Stack

Implement Stack in Python

Python Testing

What is your experience with writing tests in Python?
What is PEP8? Give an example of 3 style guidelines

How to test if an exception was raised?
What assert does in Python?
Explain mocks
How do you measure execution time of small code snippets?
Why one shouldn't use assert in non-test/production code?

Flask

Can you describe what is Django/Flask and how you have used it? Why Flask and not Djano? (or vice versa)
What is a route?
What is a blueprint in Flask?
What is a template?

zip

Given x = [1, 2, 3], what is the result of list(zip(x))?

What is the result of each of the following:
list(zip(range(5), range(50), range(50)))
list(zip(range(5), range(50), range(-2)))

Python Descriptors

Explain Descriptors

What would be the result of running a.num2 assuming the following code
class B:
    def __get__(self, obj, objtype=None):
        reuturn 10

class A:
    num1 = 2
    num2 = Five()
What would be the result of running some_car = Car("Red", 4) assuming the following code
class Print:

    def __get__(self, obj, objtype=None):
        value = obj._color
        print("Color was set to {}".format(valie))
        return value

    def __set__(self, obj, value):
        print("The color of the car is {}".format(value))
        obj._color = value

class Car:

    color = Print()

    def __ini__(self, color, age):
        self.color = color
        self.age = age

Python Misc

How can you spawn multiple processes with Python?
Implement simple calculator for two numbers

What data types are you familiar with that are not Python built-in types but still provided by modules which are part of the standard library?

Explain what is a decorator
Can you show how to write and use decorators?

Write a decorator that calculates the execution time of a function
Write a script which will determine if a given host is accessible on a given port
Are you familiar with Dataclasses? Can you explain what are they used for?
You wrote a class to represent a car. How would you compare two cars instances if two cars are equal if they have the same model and color?

Explain Context Manager
Tell me everything you know about concurrency in Python
Explain the Buffer Protocol
Do you have experience with web scraping? Can you describe what have you used and for what?
Can you implement Linux's tail command in Python? Bonus: implement head as well
You have created a web page where a user can upload a document. But the function which reads the uploaded files, runs for a long time, based on the document size and user has to wait for the read operation to complete before he/she can continue using the web site. How can you overcome this?
How yield works exactly?

Monitoring

Explain monitoring. What is it? What its goal?

What is wrong with the old approach of watching for a specific value and trigger an email/phone alert while value is exceeded?

What types of monitoring outputs are you familiar with and/or used in the past?

What is the different between infrastructure monitoring and application monitoring? (methods, tools, ...)

Prometheus

What is Prometheus? What are some of Prometheus's main features?
Describe Prometheus architecture and components
Can you compare Prometheus to other solutions like InfluxDB for example?
What is an Alert?
Describe the following Prometheus components:
  • Prometheus server
  • Push Gateway
  • Alert Manager

What is an Instance? What is a Job?
What core metrics types Prometheus supports?
What is an exporter? What is it used for?
Which Prometheus best practices are you familiar with?. Name at least three
How to get total requests in a given period of time?
What HA in Prometheus means?
How do you join two metrics?
How to write a query that returns the value of a label?
How do you convert cpu_user_seconds to cpu usage in percentage?

Git

NameTopicObjective & InstructionsSolutionComments
My first CommitCommitExerciseSolution
Time to BranchBranchExerciseSolution
How do you know if a certain directory is a git repository?

How to check if a file is tracked and if not, then track it?
What is the difference between git pull and git fetch?

Explain the following: git directoryworking directory and staging area

How to resolve git merge conflicts?
What is the difference between git reset and git revert?
You would like to move forth commit to the top. How would you achieve that?

In what situations are you using git rebase?
What merge strategies are you familiar with?

How can you see which changes have done before committing them?

How do you revert a specific file to previous commit?

How to squash last two commits?
What is the .git directory? What can you find there?

What are some Git anti-patterns? Things that you shouldn't do
How do you remove a remote branch?

Are you familiar with gitattributes? When would you use it?

How do you discard local file changes? (before commit)

How do you discard local commits?

True or False? To remove a file from git but not from the filesystem, one should use git rm

Explain Git octopus merge

Go

What are some characteristics of the Go programming language?

What is the difference between var x int = 2 and x := 2?

True or False? In Go we can redeclare variables and once declared we must use it.

What libraries of Go have you used?
What is the problem with the following block of code? How to fix it?
func main() {
    var x float32 = 13.5
    var y int
    y = x
}
The following block of code tries to convert the integer 101 to a string but instead we get "e". Why is that? How to fix it?
package main

import "fmt"

func main() {
    var x int = 101
    var y string
    y = string(x)
    fmt.Println(y)
}

What is wrong with the following code?:
package main

func main() {
    var x = 2
    var y = 3
    const someConst = x + y
}

What will be the output of the following block of code?:
package main

import "fmt"

const (
	x = iota
	y = iota
)
const z = iota

func main() {
	fmt.Printf("%v\n", x)
	fmt.Printf("%v\n", y)
	fmt.Printf("%v\n", z)
}

What _ is used for in Go?

What will be the output of the following block of code?:
package main

import "fmt"

const (
	_ = iota + 3
	x
)

func main() {
	fmt.Printf("%v\n", x)
}

What will be the output of the following block of code?:
package main

import (
	"fmt"
	"sync"
	"time"
)

func main() {
	var wg sync.WaitGroup

	wg.Add(1)
	go func() {
		time.Sleep(time.Second * 2)
		fmt.Println("1")
		wg.Done()
	}()

	go func() {
		fmt.Println("2")
	}()

	wg.Wait()
	fmt.Println("3")
}

What will be the output of the following block of code?:
package main

import (
	"fmt"
)

func mod1(a []int) {
	for i := range a {
		a[i] = 5
	}

	fmt.Println("1:", a)
}

func mod2(a []int) {
	a = append(a, 125) // !

	for i := range a {
		a[i] = 5
	}

	fmt.Println("2:", a)
}

func main() {
	sl := []int{1, 2, 3, 4}
	mod1(s1)
	fmt.Println("1:", s1)

	s2 := []int{1, 2, 3, 4}
	mod2(s2)
	fmt.Println("2:", s2)
}

What will be the output of the following block of code?:
package main

import (
	"container/heap"
	"fmt"
)

// An IntHeap is a min-heap of ints.
type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	h := &IntHeap{4, 8, 3, 6}
	heap.Init(h)
	heap.Push(h, 7)

  fmt.Println((*h)[0])
}

Mongo

What are the advantages of MongoDB? Or in other words, why choosing MongoDB and not other implementation of NoSQL?

What is the difference between SQL and NoSQL?

In what scenarios would you prefer to use NoSQL/Mongo over SQL?
What is a document? What is a collection?
What is an aggregator?
What is better? Embedded documents or referenced?
Have you performed data retrieval optimizations in Mongo? If not, can you think about ways to optimize a slow data retrieval?
Queries
Explain this query: db.books.find({"name": /abc/})
Explain this query: db.books.find().sort({x:1})
What is the difference between find() and find_one()?
How can you export data from Mongo DB?

OpenShift

What is OpenShift?
How OpenShift is related to Kubernetes?
True or False? OpenShift is a IaaS (infrastructure as a service) solution

What would be the best way to run and manage multiple OpenShift environments?

OpenShift Federation

What is OpenShift Federation?

Explain the following in regards to Federation:
  • Multi Cluster
  • Federated Cluster
  • Host Cluster
  • Member Cluster

OpenShift Azure

What is "OpenShift on Azure" and "Azure Red Hat OpenShift"?

Storage

What is a storage device? What storage devices are there?
Explain the following:
  • Block Storage
  • Object Storage
  • File Storage
What is Random Seek Time?

Scripts

What do you tend to include in every script you write?

Today we have tools and technologies like Ansible. Why would someone still use scripting?

Scripts Fundamentals

Explain conditionals and how do you use them
What is a loop? What types of loops are you familiar with?
Demonstrate how to use loops

Writing Scripts

Note: write them in any language you prefer

Write a script which will list the differences between two directories
Write a script to determine whether a host is up or down

Write a script to remove all the empty files in a given directory (also nested directories)

SQL

What does SQL stand for?

How is SQL Different from NoSQL

What does it mean when a database is ACID compliant?
When is it best to use SQL? NoSQL?

What is a Cartesian Product?
SQL Specific Questions

For these questions, we will be using the Customers and Orders tables shown below:

Customers

Customer_IDCustomer_NameItems_in_cartCash_spent_to_Date
100204John Smith020.00
100205Jane Smith340.00
100206Bobby Frank1100.20

ORDERS

Customer_IDOrder_IDItemPriceDate_sold
100206A123Rubber Ducky2.202019-09-18
100206A123Bubble Bath8.002019-09-18
100206Q98780-Pack TP90.002019-09-20
100205Z001Cat Food - Tuna Fish10.002019-08-05
100205Z001Cat Food - Chicken10.002019-08-05
100205Z001Cat Food - Beef10.002019-08-05
100205Z001Cat Food - Kitty quesadilla10.002019-08-05
100204X202Coffee20.002019-04-29
How would I select all fields from this table?

How many items are in John's cart?

What is the sum of all the cash spent across all customers?

How many people have items in their cart?

How would you join the customer table to the order table?

How would you show which customer ordered which items?

Using a with statement, how would you show who ordered cat food, and the total amount of money spent?

Azure

Explain Azure's architecture
Explain availability sets and availability zones

What is Azure Policy?
What is the Azure Resource Manager? Can you describe the format for ARM templates?
Explain Azure managed disks

Azure Network

What's an Azure region?
What is the N-tier architecture?

Azure Storage

What storage options Azure supports?

Azure Security

What is the Azure Security Center? What are some of its features?
What is Azure Active Directory?

What is Azure Advanced Threat Protection?
What components are part of Azure ATP?
Where logs are stored in Azure Monitor?
Explain Azure Site Recovery
Explain what the advisor does
Explain VNet peering
Which protocols are available for configuring health probe
Explain Azure Active
What is a subscription? What types of subscriptions are there?
Explain what is a blob storage service

GCP

Explain GCP's architecture
What are the main components and services of GCP?
What GCP management tools are you familiar with?
Tell me what do you know about GCP networking
Explain Cloud Functions
What is Cloud Datastore?
What network tags are used for?
What are flow logs? Where are they enabled?
How do you list buckets?
What Compute metadata key allows you to run code at startup?

What the following commands does? `gcloud deployment-manager deployments create`
What is Cloud Code?

Google Kubernetes Engine (GKE)

What is GKE

Anthos

What is Anthos

List the technical components that make up Anthos
What is the primary computing environment for Anthos to easily manage workload deployment?
How does Anthos handle the control plane and node components for GKE?

Which load balancing options are available?
Can you deploy Anthos on AWS?
List and explain the enterprise security capabilities provided by Anthos
How can workloads deployed on Anthos GKE on-prem clusters securely connect to Google Cloud services?
What is Island Mode configuration with regards to networking in Anthos GKE deployed on-prem?
Explain Anthos Config Management
How does Anthos Config Management help?

What is Anthos Service Mesh?
Describe the two main components of Anthos Service Mesh
What are the components of the managed control plane of Anthos Service Mesh?
How does Anthos Service Mesh help?
List possible use cases of traffic controls that can be implemented within Anthos Service Mesh
What is Cloud Run for Anthos?

How does Cloud Run for Anthos simplify operations?
List and explain three high-level out of the box autoscaling primitives offered by Cloud Run for Anthos that do not exist in K8s natively
List some Cloud Run for Anthos use cases

OpenStack

What components/projects of OpenStack are you familiar with?
Can you tell me what each of the following services/projects is responsible for?:
  • Nova

  • Neutron

  • Cinder

  • Glance

  • Keystone

Identify the service/project used for each of the following:
  • Copy or snapshot instances
  • GUI for viewing and modifying resources
  • Block Storage
  • Manage virtual instances
What is a tenant/project?
Determine true or false:
  • OpenStack is free to use
  • The service responsible for networking is Glance
  • The purpose of tenant/project is to share resources between different projects and users of OpenStack
Describe in detail how you bring up an instance with a floating IP
You get a call from a customer saying: "I can ping my instance but can't connect (ssh) it". What might be the problem?
What types of networks OpenStack supports?
How do you debug OpenStack storage issues? (tools, logs, ...)
How do you debug OpenStack compute issues? (tools, logs, ...)

OpenStack Deployment & TripleO

Have you deployed OpenStack in the past? If yes, can you describe how you did it?
Are you familiar with TripleO? How is it different from Devstack or Packstack?

OpenStack Compute

Can you describe Nova in detail?
What do you know about Nova architecture and components?

OpenStack Networking (Neutron)

Explain Neutron in detail
Explain each of the following components:
  • neutron-dhcp-agent

  • neutron-l3-agent

  • neutron-metering-agent

  • neutron-*-agtent

  • neutron-server

Explain these network types:
  • Management Network

  • Guest Network

  • API Network

  • External Network

What is a provider network?
What components and services exist for L2 and L3?
What is the ML2 plug-in? Explain its architecture
What is the L2 agent? How does it works and what is it responsible for?
What is the L3 agent? How does it works and what is it responsible for?
Explain what the Metadata agent is responsible for
What networking entities Neutron supports?
How do you debug OpenStack networking issues? (tools, logs, ...)

OpenStack - Glance

Explain Glance in detail
Describe Glance architecture

OpenStack - Swift

Explain Swift in detail
Can users store by default an object of 100GB in size?

Explain the following in regards to Swift:
  • Container

  • Account

  • Object

True or False? there can be two objects with the same name in the same container but not in two different containers

OpenStack - Cinder

Explain Cinder in detail
Describe Cinder's components

OpenStack - Keystone

Can you describe the following concepts in regards to Keystone?
  • Role

  • Tenant/Project

  • Service

  • Endpoint

  • Token

What are the properties of a service? In other words, how a service is identified?
Explain the following: * PublicURL * InternalURL * AdminURL
What is a service catalog?

OpenStack Advanced - Services

Describe each of the following services
  • Swift

  • Sahara

  • Ironic

  • Trove

  • Aodh

  • Ceilometer

Identify the service/project used for each of the following:
  • Database as a service which runs on OpenStack

  • Bare Metal Provisioning

  • Track and monitor usage

  • Alarms Service

  • Manage Hadoop Clusters

  • highly available, distributed, eventually consistent object/blob store

OpenStack Advanced - Keystone

Can you describe Keystone service in detail?
Describe Keystone architecture
Describe the Keystone authentication process

OpenStack Advanced - Compute (Nova)

What each of the following does?:
  • nova-api

  • nova-compuate

  • nova-conductor

  • nova-cert

  • nova-consoleauth

  • nova-scheduler

What types of Nova proxies are you familiar with?

OpenStack Advanced - Networking (Neutron)

Explain BGP dynamic routing
What is the role of network namespaces in OpenStack?

OpenStack Advanced - Horizon

Can you describe Horizon in detail?
What can you tell about Horizon architecture?

Security

What is DevSecOps? What its core principals?
What security techniques are you familiar with? (or what security techniques have you used in the past?)
What the "Zero Trust" concept means? How Organizations deal with it?

Explain Authentication and Authorization

How do you manage sensitive information (like passwords) in different tools and platforms?
Explain what is Single Sign-On

Explain MFA (Multi-Factor Authentication)

Explain RBAC (Role-based Access Control)

Security - Web

What is Nonce?

Security - SSH

What is SSH how does it work?

What is the role of an SSH key?

Security Cryptography

Explain Symmetrical encryption

Explain Asymmetrical encryption

What is "Key Exchange" (or "key establishment") in cryptography?

True or False? The symmetrical encryption is making use of public and private keys where the private key is used to decrypt the data encrypted with a public key

True or False? The private key can be mathematically computed from a public key
True or False? In the case of SSH, asymmetrical encryption is not used to the entire SSH session

What is Hashing?
How hashes are part of SSH?

Explain the following:
  • Vulnerability
  • Exploits
  • Risk
  • Threat
Are you familiar with "OWASP top 10"?

What is XSS?

What is an SQL injection? How to manage it?

What is Certification Authority?
How do you identify and manage vulnerabilities?
Explain "Privilege Restriction"
How HTTPS is different from HTTP?
What types of firewalls are there?
What is DDoS attack? How do you deal with it?
What is port scanning? When is it used?
What is the difference between asynchronous and synchronous encryption?
Explain Man-in-the-middle attack
Explain CVE and CVSS
What is ARP Poisoning?
Describe how do you secure public repositories
How do cookies work?
What is DNS Spoofing? How to prevent it?

What can you tell me about Stuxnet?

What can you tell me about the BootHole vulnerability?
What can you tell me about Spectre?

Explain OAuth
Explain "Format String Vulnerability"
Explain DMZ
Explain TLS
What is CSRF? How to handle CSRF?

Explain HTTP Header Injection vulnerability

What security sources are you using to keep updated on latest news?
What TCP and UDP vulnerabilities are you familiar with?
Do using VLANs contribute to network security?
What are some examples of security architecture requirements?
What is air-gapped network (or air-gapped environment)? What its advantages and disadvantages?
Explain what is Buffer Overflow

Containers
What security measures are you taking when dealing with containers?
Explain what is Docker Bench
Explain MAC flooding attack

What is port flooding?
What is "Diffie-Hellman key exchange" and how does it work?
Explain "Forward Secrecy"
What is Cache Poisoned Denial of Service?

Security - Threats

Explain "Advanced persistent threat (APT)"
What is a "Backdoor" in information security?

Puppet

What is Puppet? How does it works?
Explain Puppet architecture
Can you compare Puppet to other configuration management tools? Why did you chose to use Puppet?
Explain the following:
  • Module
  • Manifest
  • Node
Explain Facter
What is MCollective?
Do you have experience with writing modules? Which module have you created and for what?
Explain what is Hiera

Elastic

What is the Elastic Stack?

Explain what is Elasticsearch

What is Logstash?
Explain what beats are

What is Kibana?

Describe what happens from the moment an app logged some information until it's displayed to the user in a dashboard when the Elastic stack is used
Elasticsearch
What is a data node?

What is a master node?

What is an ingest node?

What is Coordinating node?

How data is stored in elasticsearch?
What is an Index?

Explain Shards

What is an Inverted Index?

What is a Document?

You check the health of your elasticsearch cluster and it's red. What does it mean? What can cause the status to be yellow instead of green?

True or False? Elasticsearch indexes all data in every field and each indexed field has the same data structure for unified and quick query ability

What reserved fields a document has?
Explain Mapping
What are the advantages of defining your own mapping? (or: when would you use your own mapping?)
Explain Replicas

Can you explain Term Frequency & Document Frequency?

You check "Current Phase" under "Index lifecycle management" and you see it's set to "hot". What does it mean?

What this command does? curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'{ "name": "John Doe" }'

What will happen if you run the previous command twice? What about running it 100 times?
What is the Bulk API? What would you use it for?

Query DSL
Explain Elasticsearch query syntax (Booleans, Fields, Ranges)
Explain what is Relevance Score
Explain Query Context and Filter Context

Describe how would an architecture of production environment with large amounts of data would be different from a small-scale environment

Logstash
What are Logstash plugins? What plugins types are there?
What is grok?

How grok works?
What grok patterns are you familiar with?
What is `_grokparsefailure?`
How do you test or debug grok patterns?
What are Logstash Codecs? What codecs are there?
Kibana
What can you find under "Discover" in Kibana?

You see in Kibana, after clicking on Discover, "561 hits". What does it mean?

What can you find under "Visualize"?

What visualization types are supported/included in Kibana?
What visualization type would you use for statistical outliers
Describe in detail how do you create a dashboard in Kibana

Filebeat

What is Filebeat?
If one is using ELK, is it a must to also use filebeat? In what scenarios it's useful to use filebeat?
What is a harvester?

True or False? a single harvester harvest multiple files, according to the limits set in filebeat.yml

What are filebeat modules?

Elastic Stack

How do you secure an Elastic Stack?

DNS

What is DNS? What is it used for?

How DNS works?
Explain the resolution sequence of: www.site.com
What types of DNS records are there?
What is a A record?

What is a AAAA record?

What is a PTR record?

What is a MX record?
Is DNS using TCP or UDP?

True or False? DNS can be used for load balancing

Which techniques a DNS can use for load balancing?
What is DNS Record TTL? Why do we need it?
What is a zone? What types of zones are there?

Distributed

Explain Distributed Computing (or Distributed System)

What can cause a system to fail?
Do you know what is "CAP theorem"? (aka as Brewer's theorem)
What are the problems with the following design? How to improve it?
What are the problems with the following design? How to improve it?
What is "Shared-Nothing" architecture?

Explain the Sidecar Pattern (Or sidecar proxy)

Misc

What is a server? What is a client?

Define or Explain what is an API

What is Automation? How it's related or different from Orchestration?

Tell me about interesting bugs you've found and also fixed
What is a Debuggger and how it works?
What is Metadata?

You can use one of the following formats: JSON, YAML, XML. Which one would you use? Why?

YAML

What is YAML?

True or False? Any valid JSON file is also a valid YAML file

What is the format of the following data?
{
    applications: [
        {
            name: "my_app",
            language: "python",
            version: 20.17
        }
    ]
}
What is the format of the following data?
applications:
  - app: "my_app"
    language: "python"
    version: 20.17
How to write a multi-line string with YAML? What use cases is it good for?

What is the difference between someMultiLineString: | to someMultiLineString: >?

What are placeholders in YAML?

How can you define multiple YAML components in one file?

Jira

Explain/Demonstrate the following types in Jira:
  • Epic
  • Story
  • Task
What is a project in Jira?

Kafka

What is Kafka?
In Kafka, how to automatically balance brokers leadership of partitions in a cluster?
  • Enable auto leader election and reduce the imbalance percentage ratio
  • Manually rebalance by using kafkat
  • Configure group.initial.rebalance.delay.ms to 3000
  • All of the above

Cassandra

When running a cassandra cluster, how often do you need to run nodetool repair in order to keep the cluster consistent?
  • Within the columnFamily GC-grace Once a week
  • Less than the compacted partition minimum bytes
  • Depended on the compaction strategy

Customers and Service Providers

What is SLO (service-level objective)?
What is SLA (service-level agreement)?

HTTP

What is HTTP?
Describe HTTP request lifecycle
True or False? HTTP is stateful

How HTTP request looks like?
What HTTP method types are there?
What HTTP response codes are there?
What is HTTPS?
Explain HTTP Cookies

What is HTTP Pipelining?
You get "504 Gateway Timeout" error from an HTTP server. What does it mean?

What is a proxy?
What is a reverse proxy?
What is CDN?
When you publish a project, you usually publish it with a license. What types of licenses are you familiar with and which one do you prefer to use?

Load Balancers

What is a load balancer?

What benefits load balancers provide?
What load balancer techniques/algorithms are you familiar with?
What are the drawbacks of round robin algorithm in load balancing?
What is an Application Load Balancer?
In which scenarios would you use ALB?
At what layers a load balancer can operate?

Can you perform load balancing without using a dedicated load balancer instance?

What is DNS load balancing? What its advantages? When would you use it?
What are sticky sessions? What are their pros and cons?
Explain each of the following load balancing techniques
  • Round Robin
  • Weighted Round Robin
  • Least Connection
  • Weighted Least Connection
  • Resource Based
  • Fixed Weighting
  • Weighted Response Time
  • Source IP Hash
  • URL Hash
Explain use case for connection draining?

Licenses

Are you familiar with "Creative Commons"? What do you know about it?
Explain the differences between copyleft and permissive licenses

Random

How a search engine works?
How auto completion works?
What is faster than RAM?
What is a memory leak?
What is your favorite protocol?

What is Cache API?
What is the C10K problem? Is it relevant today?

HR

These are not DevOps related questions as you probably noticed, but since they are part of the DevOps interview process I've decided it might be good to keep them

Tell us little bit about yourself
Tell me about your last big project/task you worked on
What was most challenging part in the project you worked on?
How did you hear about us?

How would you describe a good leadership? What makes a good boss for you?
Tell me about a time where you didn't agree on an implementation
How do you deal with a situation where key stakeholders are not around and a big decision needs to be made?
Where do you see yourself 5 years down the line?
Give an example of a time when you were able to change the view of a team about a particular tool/project/technology
Have you ever caused a service outage? (or broke a working project, tool, ...?)

Rank the following in order 1 to 5, where 1 is most important: salaray, benefits, career, team/people, work life balance

You have three important tasks scheduled for today. One is for your boss, second for a colleague who is also a friend, third is for a customer. All tasks are equally important. What do you do first?
You have a colleague you don‘t get along with. Tell us some strategies how you create a good work relationship with them anyway.

What do you love about your work?
What are your responsibilities in your current position?

Why should we hire you for the role?

Pointless Questions

Why do you want to work here?
Why are you looking to leave your current place?
What are your strengths and weaknesses?
Where do you see yourself in five years?

Team Lead

How would you improve productivity in your team?

Questions you CAN ask

A list of questions you as a candidate can ask the interviewer during or after the interview. These are only a suggestion, use them carefully. Not every interviewer will be able to answer these (or happy to) which should be perhaps a red flag warning for your regarding working in such place but that's really up to you.

What do you like about working here?
How does the company promote personal growth?
What is the current level of technical debt you are dealing with?

Why I should NOT join you? (or 'what you don't like about working here?')
What was your favorite project you've worked on?

If you could change one thing about your day to day, what would it be?

Let's say that we agree and you hire me to this position, after X months, what do you expect that I have achieved?

Testing

Explain white-box testing
Explain black-box testing
What are unit tests?
What types of tests would you run to test a web application?
Explain test harness?
What is A/B testing?
What is network simulation and how do you perform it?
What types of performances tests are you familiar with?
Explain the following types of tests:
  • Load Testing
  • Stress Testing
  • Capacity Testing
  • Volume Testing
  • Endurance Testing

Databases

What is sharding?

You find out your database became a bottleneck and users experience issues accessing data. How can you deal with such situation?

What is a connection pool?

What is a connection leak?

What is Table Lock?
Your database performs slowly than usual. More specifically, your queries are taking a lot of time. What would you do?
What is a Data Warehouse?

Explain what is a time-series database
What is OLTP (Online transaction processing)?
What is OLAP (Online Analytical Processing)?
What is an index in a database?

Regex

Given a text file, perform the following exercises

Extract

Extract all the numbers
Extract the first word of each line

Extract all the IP addresses
Extract dates in the format of yyyy-mm-dd or yyyy-dd-mm
Extract email addresses

Replace

Replace tabs with four spaces
Replace 'red' with 'green'

System Design

Explain what is a "Single point of failure" and give an example
Explain "3-Tier Architecture" (including pros and cons)
What are the drawbacks of monolithic architecture?
What are the advantages of microoservices architecture over a monolithic architecture?
What's a service mesh?

Explain "Loose Coupling"
What is a message queue? When is it used?

Scalability

Explain Scalability

Explain Elasticity

Explain Fault Tolerance and High Availability

Explain Vertical Scaling

What are the disadvantages of Vertical Scaling?

Explain Horizontal Scaling

What is the disadvange of Horizontal Scaling? What is often required in order to perform Horizontal Scaling?

Explain when in which use cases will you use vertical scaling and in which use cases you will use horizontal scaling
Explain Resiliency and what ways are there to make a system more resilient
Explain "Consistent Hashing"
How would you update each of the services in the following drawing without having app (foo.com) downtime?
What is the problem with the following architecture and how would you fix it?
Users report that there is huge spike in process time when adding little bit more data to process as an input. What might be the problem?
How would you scale the architecture from the previous question to hundreds of users?

Cache

What is "cache"? In which cases would you use it?
What is "distributed cache"?
What is a "cache replacement policy"?

Which cache replacement policies are you familiar with?

Explain the following cache policies:
  • FIFO
  • LIFO
  • LRU

Why not writing everything to cache instead of a database/datastore?

Migrations

How you prepare for a migration? (or plan a migration)

Explain "Branch by Abstraction" technique

Design a system

Can you design a video streaming website?
Can you design a photo upload website?
How would you build a URL shortener?

More System Design Questions

Additional exercises can be found in system-design-notebook repository.

Hardware

What is a CPU?

What is RAM?

What is an embedded system?

Can you give an example of an embedded system?

What types of storage are there?

Big Data

Explain what is exactly Big Data
What is DataOps? How is it related to DevOps?

What is Data Architecture?

Explain the different formats of data
What is a Data Warehouse?

What is Data Lake?

Can you explain the difference between a data lake and a data warehouse?
What is "Data Versioning"? What models of "Data Versioning" are there?
What is ETL?

Apache Hadoop

Explain what is Hadoop

Explain Hadoop YARN

Explain Hadoop MapReduce

Explain Hadoop Distributed File Systems (HDFS)
What do you know about HDFS architecture?

Ceph

Explain what is Ceph
True or False? Ceph favor consistency and correctness over performances
Which services or types of storage Ceph supports?
What is RADOS?
Describe RADOS software components
What is the workflow of retrieving data from Ceph?
What is the workflow of retrieving data from Ceph?
What are "Placement Groups"?
Describe in the detail the following: Objects -> Pool -> Placement Groups -> OSDs
What is OMAP?
What is a metadata server? How it works?

Packer

What is Packer? What is it used for?

Packer follows a "configuration->deployment" model or "deployment->configuration"?

Certificates

If you are looking for a way to prepare for a certain exam this is the section for you. Here you'll find a list of certificates, each references to a separate file with focused questions that will help you to prepare to the exam. Good luck :)

AWS

Kubernetes

Other DevOps Projects

Credits

Thanks to all of our amazing contributors who make it easy for everyone to learn new things :)

Logos credits can be found here

License

License: CC BY-NC-ND 3.0

About

Linux, Jenkins, AWS, SRE, Prometheus, Docker, Python, Ansible, Git, Kubernetes, Terraform, OpenStack, SQL, NoSQL, Azure, GCP, DNS, Elastic, Network, Virtualization. DevOps Interview Questions

Topics

Resources

License

Releases

No releases published

Packages

No packages published
{"mode":"full","isActive":false}