Skip to main content

Posts

Showing posts with the label cloud

Docker + Docker Compose + Ansible

 Docker + Docker Compose + Ansible ----------------------------------------------------------------------------------------------------------------------------- Flask Application Deployment using Ansible roles and Docker-Compose 1. Run the "setup.sh" file given in the path to install the required dependencies before starting the challenge. 2. A Flask application named "app.py" is given in the path . 3. Create an Ansible role named "Installation" in the path "/etc/ansible/roles" to install docker-compose. 4. Write an Ansible playbook named "creation.yaml" in the path , to perform the following tasks: 1. Using "file" and "copy" modules, create a Multi-stage "Dockerfile" in the path to  - Dockerize the given Flask application with "python:alpine3.7" as its base image, using the given 'requirements.txt' file.  - Build an image using "postgres" as its base image. 2. Using ...

Docker + Kubernetes + Ansible

  Docker + Kubernetes + Ansible ----------------------------------------------------------------------------------------------------------------------------- Web Application Deployment using Kubernetes and Ansible A Flask application named "application.py" is given in the path Run the given setup.sh file given in the path to install the required dependencies be the challenge. 1. Start Minikube and sync host Docker with Minikube Docker. Note: If you get any errors while starting Minikube, please do try again by running the command to start Minikube. 2. Create a Dockerfile in the path and dockerize the given 'Flask' application as 'webapp-img' using 'python:alpine3.7' as its base image. 3. Create a 'deployment.yml' file in the path to create a Kubernetes deployment object named "web-deployment" with 3 replicas which uses the 'webapp-img' and runs a container named "webapp-container". Add Label "app=webapp" an...

Ansible with Azure

  Problem statement Create a Virtual Machine with the following configurations by using Ansible Script. Region: (US) East US Availability options: No infrastructure redundancy required Security type: Standard Image: Ubuntu Server 20.04 LTS - Gen2 Size: Standard_B2ms Authentication type: SSH public key SSH public key source: Generate new key pair OS disk type: Standard HDD Security Group: Inbound rule: Allow SSH, HTTP, and HTTPS Outbound rule: Allow All Notes Launch Both Azure Basics Lab and Ubuntu Challenge Lab in new tabs. You must click on the Credentials button on the top right corner of Ubuntu Challenge Lab to allow typing within the environment. Utilize Ubuntu Challenge Lab to perform an Ansible Script. Ansible and Python3 are already Installed in the Playground. Install rest of the required dependencies for ansible. Use the credentials given in the Azure Basics Lab to log in to the Azure Portal. After completing the hands-on, delete all the resources cr...

Kubernetes2

  Challenge 2 ConfigMaps: Step-1: To create a ConfigMap named 'fresco-config' with the key-value pair SERVER_URL= https://www.fresco.me , use the following command: kubectl create configmap fresco-config --from-literal=SERVER_URL=https://www.fresco.me To verify if the ConfigMap is created, use the following command: kubectl get configmap fresco-config Step-2: To create an nginx pod with the environmental variable SERVER_URL_ENV using the ConfigMap created earlier, use the following YAML template: apiVersion: v1 kind: Pod metadata: name: fresco-nginx-pod spec: containers: - name: fresco-nginx-container image: nginx env: - name: SERVER_URL_ENV valueFrom: configMapKeyRef: name: fresco-config key: SERVER_URL Deploy the above file you can name it deployment.yaml and use the command: kubectl apply -f deployment.yaml To test your configuration by executing the following command: ...

Kubernetes1

  Challenge 1 Welcome to the Kubernetes challenge, your task is to follow the below steps and complete them successfully. Environment Setup Check whether docker & minikube are properly installed and configured. Start Minikube and execute this command to sync host docker with minikube docker minikube -p minikube docker-env and eval $(minikube docker-env) Step-1 Create a pod object using kubectl run command with google's sample image: gcr.io/google-samples/kubernetes-bootcamp:v1 and expose it on port 8080, name the pod as firstapp. Check if the pod creation is successful by running the command: kubectl get pod firstapp Step-2 Expose the application to the local VM by creating a Service object of type NodePort. Check if the service is created by running the command: kubectl get svc firstapp Step-3 Create another deployment using a 'YAML' file, create a deployment.yaml file that contains information of the number of replicas and the images to be ...

Build Flask App(Kanbanboard) using Docker and Docker Compose

 A Kanban board is a project management tool designed to help visualize work, manage project tasks, workflows and communication. In this challenge, you are going to write the unit test cases for the given Kanban board Flask application using Pytest and deploy the application using Docker Compose. Instructions: 1. Write the unit test cases using Pytest testing framework in the following path 2. Refer 'test.py' file for further instructions. 3. Commands to Execute: - 'export FLASK APP-app.py' to set an environment variable. - 'python3 m flask run' to run the Flask application.  - 'python3 m pytest test.py' to run the test cases. 4. Once you done with test cases. Deploy the Kanban board Flask application in Docker using Docker Compose. 5. Create a 'Dockerfile' to dockerize the Kanban board Flask application with 'python alpine3.7 as its base image named 'kanbanboard_app_image".  6. Create 'docker-compose.yml file to create a s...

Testing a Flask App

 Main.py from flask import Flask from flask_restful import Api, Resource, reqparse app = Flask(__name__) api = Api(app) @app.route("/") def hello_world():     return "<p>Hello, World!</p>" class DemoApiEndpoint(Resource):     def __init__(self):         self.post_args = reqparse.RequestParser()         self.post_args.add_argument("name",                                     type=str,                                     help="You must include a name string with this post request.",                                     required=True)     def get(self):         return {             "message":...

Create & Dockerize a Flask app with Redis

  Create & Dockerize a Flask app with Redis For this project we would create everything from scratch. Section 1 : We would create the Flask app Section 2 : We would deploy the app as service, along with redis using docker and docker-compose. Section 1 Creating a flask app that returns the count number of times the page was visited. Create a  requirements.txt file, and paste the following dependency name Flask redis Import dependencies using pip install --no-cache-dir -r requirements.txt Create a  app.py file  from flask import Flask from redis import Redis app = Flask(__name__) redis = Redis(host='db_service', port=6379) @app.route('/') def hello():     visit_count = redis.incr('visit_count')     return f"Hello, this page has been visited {visit_count} times." if __name__ == '__main__':     app.run(host='0.0.0.0') We can test the app locally for this we need to: Install virtualenv if it's not already installed: sudo apt-get up...

Build Flask image using docker & docker-compose

 Build Flask Image using docker & docker-compose 1. Create a Dockerfile to build Flask image with Flask application, 'requirements.txt' and expose it in port 5000. 2. Create a 'docker-compose.json' file to create two services named 'python_web_app' and 'db_service' 3. The 'python_web_app' service  should be built from Dockerfile and specify the port as 5000 4. the 'db_service' should be built from image 'redis:alpine' 5. Add a volume to the 'python_web_app' service that mounts the current directory to the working directory inside the container and set the flask envireonment in debug mode. 6. Visit 'http:localhost:5000" to check weather the Flask application is running fine. The container name of 'python_web_app' service should be 'web_container' and container name of 'db_service' should be 'db_container' Here are the instructions for each of the tasks mentioned: Create a file na...

Dockerize Gradle application using Jenkins

 Dockerize Gradle application using Jenkins In this challenge we will build and deploy a application using docker and Jenkins A Gradle web project structure is given in the gradle webapp directory which is in the path mentioned below. dev/workspace/sample-project Initialize the gradle webapp directory as a gradle project and configure the build script to - generate a war file - build a docker image named " gradle_image " - run the docker image on a container named " gradle_container ", expose to the port 8001 Create a Dockerfile to deploy the generated war file in tomcat server Initialize git to make gradle webapp directory as your local git repository. Launch jenkins and create a declarative pipeline named gradle-build to run and deploy the gradle application. Ensure that your Gradle application is running on http://localhost:8001/gradle_webapp Let's get started... 1. Initialize the Gradle project: Open the command prompt/ter...

Build & Deploy docker image using Gradle

 Build & Deploy docker image using Gradle You are tasked to create a gradle java application, Dockerfile to run the 'springbootify.jar' file on port 8080 , use suitable gradle plugins to configure the gradle application to build a docker image and run the docker container. On successful deployment of docker container, hit the url ( http://localhost:8080/doit ) and you could see the message on the webpage. Note: Jar file 'springbootify.jar' is already given in folder /Desktop/Project no need to build a need jar file. Please do install gradle using the command "sudo apt install gradle" Please do use "sudo service jenkins stop" Create a Docker & gradle application in the path /Desktop/Project Make the gradle project operable for both gradle & gradlew commands Docker base image: openj dk: 12-jdk-alpine. Solving the tasks... sudo apt install gradle sudo service jenkins stop cd /Desktop/Project Crea...