DevOps Intern Assignment
DevOps Intern Assignment
Overview
We want to assess your understanding of Kubernetes through a practical task involving a Python Flask application connecting with MongoDB.
Prerequisites
Step-by-Step Instructions
Create a new directory for your project and navigate into it:
mkdir flask-mongodb-app
cd flask-mongodb-app
Cookie Points: Can you explain the benefits of using a virtual environment for python applications?
from flask import Flask, request, jsonify # Import necessary modules from Flask
from pymongo import MongoClient # Import MongoClient to interact with MongoDB
from datetime import datetime # Import datetime to get the current time
import os # Import os to access environment variables
Flask==2.0.2
Werkzeug==2.0.3
pymongo==3.12.0
Set the MONGODB_URI environment variable to point to the local MongoDB instance. Create a .env file in the project directory with the following
MONGODB_URI=mongodb://localhost:27017/
Load the environment variables from the .env file:
export $(cat .env | xargs)
export FLASK_APP=app.py
export FLASK_ENV=development
flask run
set FLASK_APP=app.py
set FLASK_ENV=development
flask run
Open your web browser and navigate to http://localhost:5000 to see the welcome message.
Task: Deploy the provided Python Flask application that interacts with a MongoDB database on a Kubernetes cluster, ensuring proper setup of
services, volumes, autoscaling, database authentication, DNS resolution, and resource management.
Requirements: