Giter Site home page Giter Site logo

devops-capstone-project's Introduction

DevOps Capstone Template

Build Status

License Python 3.9

This repository contains the starter code for the project in IBM-CD0285EN-SkillsNetwork DevOps Capstone Project which is part of the IBM DevOps and Software Engineering Professional Certificate

Usage

You should use this template to start your DevOps Capstone project. It contains all of the code that you will need to get started.

Do Not fork this code! It is meant to be used by pressing the Use this Template button in GitHub. This will copy the code to your own repository with no connection back to the original repository like a fork would. This is what you want.

Development Environment

These labs are designed to be executed in the IBM Developer Skills Network Cloud IDE with OpenShift. Please use the links provided in the Coursera Capstone project to access the lab environment.

Once you are in the lab environment, you can initialize it with bin/setup.sh by sourcing it. (Note: DO NOT run this program as a bash script. It sets environment variable and so must be sourced):

source bin/setup.sh

This will install Python 3.9, make it the default, modify the bash prompt, create a Python virtual environment and activate it.

After sourcing it you prompt should look like this:

(venv) theia:project$

Useful commands

Under normal circumstances you should not have to run these commands. They are performed automatically at setup but may be useful when things go wrong:

Activate the Python 3.9 virtual environment

You can activate the Python 3.9 environment with:

source ~/venv/bin/activate

Installing Python dependencies

These dependencies are installed as part of the setup process but should you need to install them again, first make sure that the Python 3.9 virtual environment is activated and then use the make install command:

make install

Starting the Postgres Docker container

The labs use Postgres running in a Docker container. If for some reason the service is not available you can start it with:

make db

You can use the docker ps command to make sure that postgres is up and running.

Project layout

The code for the microservice is contained in the service package. All of the test are in the tests folder. The code follows the Model-View-Controller pattern with all of the database code and business logic in the model (models.py), and all of the RESTful routing on the controller (routes.py).

├── service         <- microservice package
│   ├── common/     <- common log and error handlers
│   ├── config.py   <- Flask configuration object
│   ├── models.py   <- code for the persistent model
│   └── routes.py   <- code for the REST API routes
├── setup.cfg       <- tools setup config
└── tests                       <- folder for all of the tests
    ├── factories.py            <- test factories
    ├── test_cli_commands.py    <- CLI tests
    ├── test_models.py          <- model unit tests
    └── test_routes.py          <- route unit tests

Data Model

The Account model contains the following fields:

Name Type Optional
id Integer False
name String(64) False
email String(64) False
address String(256) False
phone_number String(32) True
date_joined Date False

Your Task

Complete this microservice by implementing REST API's for READ, UPDATE, DELETE, and LIST while maintaining 95% code coverage. In true Test Driven Development fashion, first write tests for the code you "wish you had", and then write the code to make them pass.

Local Kubernetes Development

This repo can also be used for local Kubernetes development. It is not advised that you run these commands in the Cloud IDE environment. The purpose of these commands are to simulate the Cloud IDE environment locally on your computer.

At a minimum, you will need Docker Desktop installed on your computer. For the full development environment, you will also need Visual Studio Code with the Remote Containers extension from the Visual Studio Marketplace. All of these can be installed manually by clicking on the links above or you can use a package manager like Homebrew on Mac of Chocolatey on Windows.

Please only use these commands for working stand-alone on your own computer with the VSCode Remote Container environment provided.

  1. Bring up a local K3D Kubernetes cluster

    $ make cluster
  2. Install Tekton

    $ make tekton
  3. Install the ClusterTasks that the Cloud IDE has

    $ make clustertasks

You can now perform Tekton development locally, just like in the Cloud IDE lab environment.

Author

John Rofrano, Senior Technical Staff Member, DevOps Champion, @ IBM Research, and Instructor @ Coursera

License

Licensed under the Apache License. See LICENSE

© IBM Corporation 2022. All rights reserved.

devops-capstone-project's People

Contributors

francostellari avatar

Watchers

 avatar

devops-capstone-project's Issues

Set up the development environment

As a developer
I need to setup a development environment
So that I can start working on the project

Details and Assumptions

* On my windows machine I need to install vagrant to be able to bring up the development environment

Acceptance Criteria

gherkin 
Given a cloned copy of the Git repo
When i run the command `vagrant up`
Then I should have a ready to use development environment

Deploy your Docker image to Kubernetes

As a user
I need deploy the Docker image of the microservice in Kubernetes
So that the microservice can be run and accessed in the cloud

Details and Assumptions

* Give the Docker container image of the microservice application, I need to deploy it into Kubernetes using appropriate YAML

Acceptance Criteria

gherkin 
Given the existing Docker image of the microservice
When I deploy it into a Kubernetes cluster
Then I should be able to access the features of the microservice from the cloud

Read an account from the service

As a user
I need to read an customer account from the service
So that I get the customer information

Details and Assumptions

* Assuming that I have the microservice running with some customer information in it, I would like to call on the RESTful API to get a specific customer information

Acceptance Criteria

gherkin 
Given a running microservice with XYZ customer information in it
When I trigger the restful API to get customer XYZ
Then I should get the customer XYZ information

Delete an account from the service

As a user
I need to be able to delete a customer entry
So that it is removed from the application

Details and Assumptions

* A would like to be able to completely remove the record of a customer XYZ from the application so that it is no more accessible    

Acceptance Criteria

gherkin 
Given a customer XYZ in the application
When I delete the record of customer XYZ
Then the record of customer XYZ should be removed from the application and not be accessible anymore

Containerize your microservice using Docker

As a developer
I need create a Docker container of the microservice application
So that it can be deployed in the cloud

Details and Assumptions

* Given the Python code of the microservice application, I need to to create a Dockerfile that packages the code into a container

Acceptance Criteria

gherkin 
Given the local Python code of the application that has been tested to work
When I run the docker build command
Then I should get a docker container image corresponding to the python code

Need to add security headers and CORS policies

As a service provider
I need my service to use security headers and CORS policies
So that my web site is not vulnerable to CORS attacks

Assumptions

  • Flask-Talisman will be used for security headers
  • Flask-Cors will be used to establish cross-origin resource sharing (CORS) policies

Acceptance Criteria

Given the site is secured
When a REST API request is made
Then secure headers and a CORS policy should be returned

List all accounts in the service

As a user
I need to retrieve a list of the accounts
So that I can get a list of all the accounts available in the application

Details and Assumptions

* [document what you know]      

Acceptance Criteria

gherkin 
Given a list of accounts available in the application
When I request a list of accounts
Then I should get a full list of all the accounts available 

Update an account in the service

As a user
I need update a customer information
So that the new customer information is saved in the application

Details and Assumptions

* Given a customer XYZ, I would like to change some detail about the customer information, such as the address, so that it is updated in the application for future use

Acceptance Criteria

gherkin 
Given A customer XYZ with `address1`
When When I update it's address to `address2`
Then The new `address2` should replace the previous `address`1 and be stored in the application for future retrieval

Create a CD pipeline to automate deployment to Kubernetes

As a developer
I need to create a CD pipeline to automate deployment to Kubernetes
So that developers aren't wasting their time doing it manually

Details and Assumptions

  • Use Tekton to define the pipeline
  • It should clone, lint, test, build, and deploy the service
  • Deployment should be to OpenShift
  • It can use a manual trigger for this MVP

Acceptance Criteria

gherkin 
Given the CD pipeline has been created
When I trigger the pipeline run
Then I should see the accounts service deployed to OpenShift

Need the ability to automate continuous integration checks

As a Developer
I need automation to build and test every pull request
So that I do not have to rely on manual testing of each request, which is time-consuming

Assumptions

  • GitHub Actions will be used for the automation workflow
  • The workflow must include code linting and testing
  • The Docker image should be postgres:alpine for the database
  • A GitHub Actions badge should be added to the README.md to reflect the build status

Acceptance Criteria

Given code is ready to be merged
When a pull request is created
Then GitHub Actions should run linting and unit tests
And the badge should show that the build is passing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.