The task for an interview on a DevOps position
Looking for an experienced DevOps System Engineer is a challenging task, because it is usually difficult to estimate all aspects of a person’s knowledge.
Technical interviews can reveal some strong and weak sides of a candidate, but sometimes they leave some open questions about real experience. And if we are talking about real routine tasks - it’s not only about knowledge, but also about skills to perform different kinds of tasks using manuals, docs, and even Google.
So, the main goal of this test task - is to find out how a candidate can perform typical DevOps engineer tasks, adopting fresh-written applications to run in infrastructure and to be deployed as a production environment.
Also, this task shouldn’t take more than ~4 hours.
How it should look: Running Demo.
All files you need - are in this GitHub repository. Just clone it from GitHub.
This app was written in Python, and it is pretty simple. Why Python? In my own opinion, this is one of the languages that any Linux engineer should know. But this task is not about programming, so if you don’t know Python and are skilled in Bash - It’s ok.
Requirements:
3.6
(any other 3.x
should work too)requirements.txt
All this App does - counts unique visitors and shows this statistic. All it needs is a running database.
So, this app has some endpoints:
/
- main page with all data shown/version
- JSON response with the current app versionmigrations
- directory with database migrations (see Installation) based on alembic
static
- just static files for serving UItemplates
- HTML template for the main pageapp.py
- main “executable” which contains all the coderequirements.txt
- list of all Python packages needed to run the apprequirements.test.txt
- list of all Python packages needed for CI/CD tasksversion.txt
- text file with the current versionTo install the application, several steps should be completed:
pip install -r requirements.txt
flask db upgrade
For the last step, you can use different approaches - just choose one from official docs.
As for any Docker-ready application - It can be easily configured via environment variables. So, here is a list of them:
DATABASE_URL
(required) - connection string to your database, you can find examples here.USER_NAME
- your name, which will be shown on the pageUSER_URL
- something like your personal URL (CV, blog, contact page, etc.)So, now we can talk about the goals. I’m writing just a roadmap, and any step is optional but will give additional points if is done correctly. If you are good in docs - spend more time on writing good documentation, if you have good experience in clouds - write a scalable, fault-tolerant, and cloud-ready solution. Feel free to choose your way and show your best.
An ideal solution should be fulfilled as a git repository, which will contain all Infrastructure-related code (IaC), scenarios, diagrams, and documentation as a main README.md
file.
I think the best option for this is Terraform. But you can also use Ansible or Chef, or any tool you want. It will be great if your solution can be used from the box to start the whole stack on a cloud provider (AWS, GCP, Azure, AlibabaCloud, etc.).
Dockerfile
- should be included, but it isn’t, because the developer of the app was too lazy for this task…
So, it will be the first step to build a container with this app - writing Dockerfile
and making the first docker build
.
docker-compose.yml
for the whole app stack, which can be used by developersAll tools you need for this section are in the requirements.test.txt
file,
which can be easily used with pip install -r requirements.test.txt
.
pytest .
and get successful resultsAt this stage you already have a project, that can be built and verified for some kind of issues. It’s time to automate it.
Choose one of the CI/CD systems you like:
.gitlab-ci.yml
file as described here.Jenkinsfile
to achieve the goal.
I recommend using a scripted, not declarative pipeline - it would be much better to show your experience.
Documentation about Jenkins Pipelines is avaiable here.And of course, don’t forget about:
version.txt
and it will be shown as the version on a web page.
What about adding a build number to this version and auto-increment it on each build?Just prepare some examples, of how this app could be monitored. Docker Healthchecks or rules on AWS Route53 - anything will be accepted as a solution.
Documentation should include key points such as:
Also, you may write additional docs like:
To draw diagrams you can use Draw.io, CloudCraft or even ASCII Art. Include them in your repository too.
There are some problems with app architecture. If you have a solution - it will be great!
If you still have some questions about this task, feel free to ask me.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.