# software development lifecycle --- ## Overview - GitOps - IaC - Requirement Analysis - Design - Implementation - CI/CD - Maintenance --- Note: overview from wikipedia --- ## GitOps
- **Requirement Analysis:** GitLab **Issues** to triage and prioritize requirements. - **Design:** GitLab **Issues** and **Merge Requests** to review, approve, and manage the design, mapping to issues from the previous phase. - **Implementation:** A feature branch-based **Git** workflow together with **Merge Requests** to implement a Git-based development workflow. - **CI/CD:** **GitLab CI/CD** pipelines, integrating with **Git** and **Merge Requests**, to automate building, testing, and deploying your code. - **Maintenance:** GitLab **Issues** to track bugs and plan maintenance tasks
Notes: - GitOps is a way to do Kubernetes cluster management and application delivery. - It uses Git as a single source of truth for declarative infrastructure and applications. --- ## GitLab
Notes: - GitLab is a complete DevOps platform, delivered as a single application. - It enables teams to collaborate and work from a single conversation, instead of managing multiple threads across disparate tools. --- ## Infrastructure as Code - **Speed and simplicity** in setting up infrastructure - **Consistency** by avoiding manual configuration - **Scalability** through automation - **Cost Reduction** by efficiently managing resources Notes: Highlight how IaC helps in quick provisioning of infrastructure, maintaining consistency across environments, easily scaling up/down as per demand, and optimizing costs by automating resource management. - Tools like Terraform, Ansible, and CloudFormation are commonly used for IaC. - Emphasize the importance of version control for infrastructure code. --- ## SDLC on GitLab - **Planning** - **Development** - **CI/CD** - **Test & QA** - **Releases** - **Monitoring & Observability** Note: overview .... - GitLab provides a comprehensive set of tools for managing the entire SDLC. - Each phase of the SDLC can be managed within GitLab, from planning to monitoring. --- ## Planning - Branching Stategy - tooling Note: feature branches .... - Feature branches allow developers to work on new features without affecting the main codebase. - Once the feature is complete, it can be merged back into the main branch after review. --- # Development - pre-commit hooks (pre-commit.com) - dependency management (uv) - linting (ruff) Note: - Pre-commit hooks help ensure code quality by running checks before code is committed. - Dependency management ensures that all required libraries are installed and up-to-date. - Linting helps maintain code quality and consistency. --- # CI/CD - Linting & Formatting (ruff, mypy) - Unit & Integration Tests (pytest, coverage reports) - Security Scans (bandit, pip-audit) - Pypi Builds (uv build / uv publish) - Container Builds (docker, podman) Note: - CI/CD pipelines automate the process of testing, building, and deploying code. - Security scans help identify vulnerabilities in the codebase. - Container builds ensure that applications run consistently across different environments. ---- # GitLab CI/CD ``` stages: - test - build pytest: stage: test image: ghcr.io/astral-sh/uv script: - echo "Installing dependencies..." - uv sync --all-extras --dev - echo "Running unit tests..." - uv run pytest ``` Note: - The `pytest` job runs unit tests to ensure code quality. - Using a container image ensures a consistent environment for running tests. - The `uv sync` command installs all dependencies, including development dependencies. --- # Test & QA - Code Review - Unit & Integration Testing (pytest) - End-to-End Testing (playwright) - Performance Testing (pytest-benchmark) - Security Testing (bandit, pip-audit) Note: - Code reviews help catch issues early and improve code quality. - Unit and integration tests using `pytest` verify the functionality of individual components and their interactions. - End-to-end tests with `playwright` simulate real user scenarios to validate the entire application flow. - Performance tests with `pytest-benchmark` check the application's responsiveness and stability under load. - Security tests with `bandit` and `pip-audit` identify vulnerabilities and ensure the application is secure. --- # Releases - Build python package (uv build) - Build Open Container Image (podman build) - Upload artifacts to Gitlab (podman push & uv publish) - Deploy artifacts from Gitlab (podman pull & uv sync) Note: - Building the Python package with `uv build`. - Building the Open Container Image with `podman build` to run either via podman or in a kubernetes cluster. - Uploading artifacts to GitLab using `podman push` and `uv publish` makes them available for deployment and further use. - Deploying artifacts from GitLab with `podman pull` and `uv sync` ensures that the latest versions are used in the deployment process, maintaining consistency and reliability. ---- # Deployment - **A/B Testing:** Deploy two versions to compare. - **Blue/Green Deployment:** Deploy new version alongside old. - **Canary Releases:** Gradually roll out new version. - **Rolling Updates:** Incrementally update without downtime. - **Recreate Strategy:** Shut down old before deploying. Note: - A/B Testing helps in comparing two versions to determine which performs better. It allows for data-driven decisions based on user interactions. - Blue/Green Deployment minimizes downtime and allows for quick rollback if issues are detected. This strategy ensures that the new version is fully functional before switching traffic. - Canary Releases provide a safe way to test new features with a limited audience before full deployment. This helps in identifying potential issues early. - Rolling Updates ensure continuous availability by updating instances one at a time. This strategy is useful for applications that require high availability. - The Recreate Strategy is simple but can cause downtime, making it less ideal for high-availability applications. It involves shutting down the old version completely before deploying the new version. --- # Monitoring & Observability - **Grafana:** Visualize metrics and logs. - **Icinga2:** Monitor system health and alerts. Note: - Grafana is a powerful tool for visualizing metrics and logs. It integrates with various data sources and provides customizable dashboards. - Icinga2 is used for monitoring system health and generating alerts. It helps in identifying and resolving issues quickly. - Together, Grafana and Icinga2 provide comprehensive monitoring and observability, ensuring that the system is running smoothly and any issues are promptly addressed.