Skip to content

A RESTful Microservice for managing customer accounts, employing a full suite of DevOps best practices. This project demonstrates the entire software development lifecycle (SDLC), from Agile planning and Test Driven Development (TDD) to automated CI/CD pipelines and deployment on Kubernetes.

License

Notifications You must be signed in to change notification settings

agslima/devops-project

DevOps Capstone Banner

Customer Account Microservice - DevOps Project

Build Status Python 3.9 Docker Kubernetes License

Project Overview

This project implements a customer management microservice designed with modern Software Engineering and DevOps practices.
It implements a production-ready RESTful service for managing customer accounts while showcasing the full Software Development Lifecycle (SDLC) — from Agile planning and Test-Driven Development (TDD) to automated CI/CD pipelines, containerization, and deployment on Kubernetes/OpenShift.

Tech Stack & Tools

  • Backend: Python, Flask, SQLAlchemy
  • Database: PostgreSQL
  • Architecture: RESTful microservice, MVC
  • CI/CD: GitHub Actions (CI), Tekton Pipelines (CD)
  • Containers & Deployment: Docker, Kubernetes
  • Testing: Pytest + Coverage
  • Quality Gates: Linting, type checks, test coverage enforcement
  • Security: Secure headers, CORS policy, dependency scanning workflow
  • Observability: Structured logging, health endpoints

Key Features & Engineering Practices

This project was built in several sprints, covering the following engineering achievements:

1. Agile Planning & Management

  • Utilized a Kanban board (ZenHub/GitHub Projects) to manage the product backlog, tracking progress from "To Do" to "Done".
  • Created detailed User Stories and managed sprints effectively.

Sprint Kanban Board showing completed tasks
Figure 1: Agile Kanban Board showing user stories moved to Done/Closed through the sprints.


2. Test Driven Development (TDD)

  • Adopted a TDD approach, writing test cases before business logic.
  • Implemented unit tests for all CRUD operations (Create, Read, Update, Delete, List).
  • Achieved >95% code coverage to ensure reliability.

Code Coverage Report showing over 95%
Figure 2: Unit test execution report demonstrating high code coverage standards.


3. Continuous Integration (CI)

  • Configured GitHub Actions to trigger automated workflows on pull requests.
  • Workflows include installing dependencies, linting (PEP8), and running unit tests automatically.

4. Security & Quality

  • Integrated Security Headers using Flask-Talisman.
  • Established CORS policies using Flask-Cors to secure API access.
  • Adhered to strict coding standards verified by linting tools.

5. Containerization & Orchestration

  • Created optimized Dockerfile for the microservice.
  • Deployed the containerized application to a Kubernetes/OpenShift cluster.

6. Continuous Deployment (CD) Automation

  • Built a fully automated Tekton Pipeline for Continuous Deployment.
  • Pipeline tasks include: Cloning, Linting, Testing, Building Image, and Deploying to the cluster automatically upon code changes.

Successful Tekton CD Pipeline Execution
Figure 3: A successful execution of the Tekton CD pipeline, showing all tasks (clone, test, build, deploy) completing quickly and successfully.


Project Layout

The application follows the Model-View-Controller (MVC) pattern:

├── service/            <- Microservice package
│   ├── common/         <- Log and error handlers
│   ├── config.py       <- Flask configuration
│   ├── models.py       <- Database models (Business Logic)
│   └── routes.py       <- REST API routes (Controller)
├── tests/              <- Test Suite (TDD)
│   ├── factories.py    <- Data factories for testing
│   ├── test_models.py  <- Model unit tests
│   └── test_routes.py  <- Route unit tests
├── tekton/             <- Tekton Pipeline definitions
└── Dockerfile          <- Container definition

Development Environment

These labs are designed to be executed in the IBM Developer Skills Network Cloud IDE with OpenShift.

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

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.

Data Model

The Account resource includes:

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

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.

  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.

License

This project is licensed under the Apache 2.0 License. This repository contains the final Capstone Project for the IBM DevOps and Software Engineering Professional Certificate. Original starter code provided by IBM Skills Network. Implementation and DevOps pipelines developed by Agnaldo Silva Lima. LinkedIn Coursera Portfolio

About

A RESTful Microservice for managing customer accounts, employing a full suite of DevOps best practices. This project demonstrates the entire software development lifecycle (SDLC), from Agile planning and Test Driven Development (TDD) to automated CI/CD pipelines and deployment on Kubernetes.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •