├── LICENSE ├── README.md ├── azki └── compose-cicd │ ├── .gilab-ci.yml │ ├── Dockerfile │ ├── README.md │ ├── docker-compose.yml │ ├── requirements.txt │ └── src │ └── app.py ├── energi └── README.md ├── fidibo └── README.md ├── jibit └── README.md └── rayankar └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Javad Naghiloo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # intvw-challenges -------------------------------------------------------------------------------- /azki/compose-cicd/.gilab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - build 3 | - deploy 4 | 5 | build: 6 | stage: build 7 | script: 8 | - cd /opt/azki/khan-1-javad/ 9 | - docker build -t getip:$CI_COMMIT_TAG . 10 | only: 11 | refs: 12 | - tags 13 | variables: 14 | - $CI_BUILD_REF_NAME =~ /-stable$/ 15 | 16 | deploy: 17 | stage: deploy 18 | script: 19 | - docker compose -f /opt/azki/docker-compose.yml up -d 20 | only: 21 | refs: 22 | - tags 23 | variables: 24 | - $CI_BUILD_REF_NAME =~ /-stable$/ 25 | 26 | -------------------------------------------------------------------------------- /azki/compose-cicd/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7 2 | 3 | WORKDIR /app 4 | 5 | COPY requirements.txt . 6 | RUN pip3 install -r requirements.txt 7 | 8 | COPY src . 9 | 10 | 11 | CMD ["python3", "-m" , "flask", "run", "--host=0.0.0.0"] 12 | -------------------------------------------------------------------------------- /azki/compose-cicd/README.md: -------------------------------------------------------------------------------- 1 | ## Provided Description 2 | 3 | This is a simple project to get user ip. 4 | It is tested with python3.8 successfully. 5 | 6 | Install the dependencies and run `python3 -m flask run`. 7 | 8 | This app is require a mysql database to connect to it. The information is hard coded in the source file. It will be awesome if those sensitive information are read from ENV VARs and removed from source code. 9 | 10 | Create a pipeline which build and deploy the app with docker-compose when we create a tag with trailling `-stable`. 11 | 12 | 13 | ## Challanges 14 | 15 | ### Dockerize the application 16 | Separate COPY command for requirements.txt and src directory and put pip installation command between them. It will helps to improve docker layer caching and increases image build speed for next runs. 17 | Note that the application will run on port 5000 18 | 19 | 20 | ### Run the application with docker-compose 21 | Try to not map mysql ports. because the connection of app and mysql can be handled from docker network(I used bridge mode), there is no need to bind mysql port for external access. 22 | 23 | ### Setup CICD pipeline with GitlabCI 24 | 1. Register gitlab-runner that installed on the target vm. 25 | 2. Basic pipeline with build & deploy stages 26 | 3. The pipeline should trigger by tags ($CI_COMMIT_TAG var) 27 | 4. Deploy with docker-compose 28 | 5. Change pipeline to just run `stable` appended tags 29 | ``` 30 | job: 31 | only: 32 | refs: 33 | - tags 34 | variables: 35 | - $CI_BUILD_REF_NAME =~ /-stable$/ 36 | ``` 37 | 38 | 39 | ### Change the code to fill database connection string with ENV 40 | Follow [this link](https://able.bio/rhett/how-to-set-and-get-environment-variables-in-python--274rgt5) guide for python env variables. 41 | For this, there is two solution 42 | 1. Filling ENV from docker-compose hard-coded variables(I did that) 43 | 2. Using Gitlab variables to fill the ENV 44 | -------------------------------------------------------------------------------- /azki/compose-cicd/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | app: 5 | container_name: getip 6 | image: getip:${CI_COMMIT_TAG} 7 | ports: 8 | - 5000:5000 9 | environment: 10 | db-host: mysql 11 | db-name: mydatabase 12 | db-user: candidate 13 | db-pass: challange 14 | depends_on: 15 | - mysql 16 | mysql: 17 | container_name: mysql 18 | image: mysql:8.0 19 | environment: 20 | MYSQL_DATABASE: 'mydatabase' 21 | # So you don't have to use root, but you can if you like 22 | MYSQL_USER: 'candidate' 23 | # You can use whatever password you like 24 | MYSQL_PASSWORD: 'challange' 25 | # Password for root access 26 | MYSQL_ROOT_PASSWORD: 'password' 27 | -------------------------------------------------------------------------------- /azki/compose-cicd/requirements.txt: -------------------------------------------------------------------------------- 1 | flask 2 | mysql-connector-python -------------------------------------------------------------------------------- /azki/compose-cicd/src/app.py: -------------------------------------------------------------------------------- 1 | from flask import request 2 | from flask import jsonify 3 | from flask import Flask 4 | import mysql.connector 5 | from mysql.connector import Error 6 | 7 | try: 8 | connection = mysql.connector.connect(host='mysql', 9 | database='mydatabase', 10 | user='candidate', 11 | password='challange') 12 | if connection.is_connected(): 13 | db_Info = connection.get_server_info() 14 | print("**************** Connected to MySQL Server version ", db_Info) 15 | cursor = connection.cursor() 16 | cursor.execute("select database();") 17 | record = cursor.fetchone() 18 | print("**************** You're connected to database: ", record) 19 | 20 | except Error as e: 21 | print("Error while connecting to MySQL", e) 22 | 23 | app = Flask(__name__) 24 | 25 | @app.route("/ip", methods=["GET"]) 26 | def get_my_ip(): 27 | return jsonify({'ip': request.remote_addr}), 200 28 | -------------------------------------------------------------------------------- /energi/README.md: -------------------------------------------------------------------------------- 1 | # energi 2 | 3 | ## Rules 4 | You can copy, search, google, duckduckgo, stackoverflow, github or otherwise source your answers without losing marks, however - If you 5 | copy something verbatim you must reference it (for example in an inline comment) - If there are no comments explaining what it does you must 6 | add some - You should strive to test that what you’ve copied to ensure it works and fulfills the objective 7 | 8 | Generally speaking, there will be marks for just achieving anything at all (unless you copied it without referencing), plus some for each sub 9 | requirement, and then a few for style and explanation. Please don’t spend too much time. A couple of hours should suffice - maybe a little more if 10 | you have to pick stuff up as you go along. 11 | 12 | **Questions 1-3 are mandatory** - you can skip any of the subsequent questions, but you need to write a short explanation as to why (e.g. I’ve 13 | never used this technology, and it’s not on my CV; or I spent too much time on the other questions). 14 | 15 | ## Challenges 16 | **1. Docker Whale** 17 | Write a Dockerfile to run Energi v3.1.2 in a container. It should somehow verify the checksum of the downloaded release 18 | 19 | (there’s no need to build the project), run as a normal user, it should run the client, and print its output to the console. 20 | 21 | https://wiki.energi.world/en/downloads/core-node 22 | 23 | The build should be security conscious, and ideally pass a container image security test such as ECR, or Trivy. **[20 pts]** 24 | 25 | **2. K8S Awesomness** 26 | Write a Kubernetes StatefulSet to run the above, using persistent volume claims and resource limits. **[10 pts]** 27 | 28 | **3. All the continuouses** 29 | Write a simple build and deployment pipeline for the above using groovy / Jenkinsfile, Travis CI or Gitlab CI. **[15 pts]** 30 | 31 | **4. Script kiddies** 32 | Source or come up with a text manipulation problem and solve it with at least two of awk, sed, tr. and / or grep. Check the question below first though, maybe. **[10 pts]** 33 | 34 | **5. Script grown-ups** 35 | Solve the problem in question 4 using any programming language of your choice. **[15 pts]** 36 | 37 | **6. Terraform lovers** 38 | write a Terraform module that creates the following resources in IAM: - A role, with no permissions, which can be 39 | 40 | assumed by users within the same account - A policy, allowing users / entities to assume the above role - A group, with the above policy 41 | attached - A user, belonging to the above group - All four entities should have the same name, or be similarly named in some meaningful 42 | way given the context e.g. prod-ci-role, prod-ci-policy, prod-ci-group, prod-ci-user; or just prod-ci. Make the suffixes toggleable, if you 43 | wish. **[20 pts]** 44 | 45 | ## Evaluation 46 | Either submit your work by email as an attachment or provide a link to an online source code repository such as Github or Gitlab. **10 47 | points are reserved for style, and substance.** Total is 100. Pass mark is 50. 48 | Good luck! 49 | 50 | -------------------------------------------------------------------------------- /fidibo/README.md: -------------------------------------------------------------------------------- 1 | # fidibo 2 | 3 | **1. Docker** 4 | Dockerize this repository and create a deployment for this repo: 5 | 6 | https://github.com/gothinkster/golang-gin-realworld-example-app 7 | 8 | 9 | **2. Kubernetes** 10 | Deployment for ElasticSearch with three of nodes 11 | 12 | -------------------------------------------------------------------------------- /jibit/README.md: -------------------------------------------------------------------------------- 1 | # jibit 2 | 3 | **1. Application** 4 | A simple application which should have a version and a health check api. 5 | 6 | - Should be containerized with a multi-stage docker image. 7 | 8 | **2. Kubernetes** 9 | Create a Kubernetes cluster with 2 masters. 10 | 11 | - Describe your design choices. 12 | - Install the above application on the cluster using helm. 13 | - Describe a solution for zero-downtime deployment with Kubernetes. 14 | 15 | **3. Automation** 16 | To run this project we expect to run only a simple vagrant up command. 17 | 18 | -------------------------------------------------------------------------------- /rayankar/README.md: -------------------------------------------------------------------------------- 1 | # DevOps Test 2 | 3 | ## Must do: 4 | 5 | 1. [GitOps Principles](https://en.wikipedia.org/wiki/DevOps#GitOps) 6 | 2. Boostrap script or Ansible Code 7 | 3. Document your solution 8 | 9 | ## Steps 10 | 11 | 1. Please clone this repository into a new private github repository and add below repository as a git submodule, 12 | https://github.com/Star2Billing/a2billing 13 | 14 | 15 | 2. Follow the INSTALL.rst, this guid is design to run the software in a single VM, 16 | you need to separate the services into 5 Kuberenetes services in two helm charts as below (Deployments). 17 | 18 | Of course you you can also skip the part for "Callback Service" 19 | 20 | Create a helm chart called a2billing with below deployments 21 | 22 | 1. `web-customer`: Docker image: php-apache (ingress: http://cluster/customer) 23 | 2. `web-admin`: Docker image: php-apache (ingress: http://cluster/admin) 24 | 3. `sip-server`: Dockerize asterisk asterisk (ingress: sip://cluster TCP/UDP 5060) 25 | 26 | Create a second helm chart with deployments 27 | 1. `db-server`: mysql 28 | 2. `phpmyadmin`: phpMyAdmin (ingress: http://cluster/phpmyadmin) 29 | 30 | Note for the Asterisk: you can use CHAN_SIP which is the legacy asterisk module for SIP Server and can configure with `sip.conf` 31 | and it is recommended to use asterisk 11 to 13 for above (It's OLD!) 32 | 33 | Note for PHP: requested php version is 5, but it should also work php 7.x 34 | 35 | 3. Test customer portal : try to register when navigating to customer 36 | 37 | 4. Test admin portal : you must be able to login and see the customer you just registered 38 | 39 | 5. (Nice to do) Add CI/CD Pipeline (You can choose Azure or Gitlab) for automatic testing and automatic deployment 40 | 41 | 6. (Nice do do) Once your cluster is up and running, you must be able to use the client you have registered 42 | register with a SIP client softphone to your asterisk on port 5060. 43 | 44 | - For Windows you can use MicroSIP from https://www.microsip.org/ 45 | - For linux/mac you can use [Jitsi](https://jitsi.org/downloads/) 46 | 47 | 7. We expect to see a single bash script or ansible to bootstrap the build/deployment process for locally execution of the assignment in 48 | minimkube or kind environment. 49 | 50 | if it works, dialing 77 should announce your credit. provided you have modified extensions.conf to below: 51 | 52 | ``` 53 | 54 | [a2billing] 55 | include => a2billing_callingcard 56 | include => a2billing_monitoring 57 | include => a2billing_voucher 58 | 59 | ``` 60 | --------------------------------------------------------------------------------