# cdsl-research/roll-update architecture

> Architecture diagram of the GitHub repository cdsl-research/roll-update, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cdsl-research/roll-update
- Repository: https://github.com/cdsl-research/roll-update

## Overview

##### Project Type & Purpose
- This repository is a specialized tool for managing rolling updates on a WordPress application deployed in a Kubernetes (k3s) environment.
- It contains YAML configuration files that define the desired state for WordPress and its MySQL backing service, plus Python scripts that automate the update process (switching image versions and triggering a rollout).

##### File Structure
- The top-level files include:
- README.md (documentation)
- kustomization.yaml, mysql-deployment.yaml, wordpress-deployment.yaml (Kubernetes configuration files)
- rollupdate_611_631.py and rollupdate_621_631.py (Python scripts for updating from different source versions to 6.3.1)
- This file organization suggests separation between configuration (declarative YAML) and operational automation/business logic (Python scripts).

##### Key Components
a. External Actor (Operator/User):
- Initiates the rolling update by executing one of the Python scripts.

b. Python Update Controller:
- Contains the logic to delete existing WordPress and MySQL deployments, prompt for inputs (replicas, maxSurge, maxUnavailable), and invoke Kubernetes CLI (kubectl) commands.
- Two versions of the script (rollupdate_611_631.py and rollupdate_621_631.py) indicate variant handling for different starting versions.

c. Kubernetes Cluster (k3s Environment):
- Namespace “roll” where the deployments are applied.
- Two main deployments:
- WordPress Deployment: Managed via wordpress-deployment.yaml – its image tag is updated from an earlier version (6.1.1 or 6.2.1) to 6.3.1.
- MySQL Deployment: Configured by mysql-deployment.yaml.
- Additional YAML file: kustomization.yaml helps in applying and managing these resources in Kubernetes.

d. Rolling Update Process:
- Flow steps:
1. Deletion stage: The scripts first issue commands to delete existing WordPress and MySQL deployments and pods.
2. Deployment stage: The initial deployment is re-applied with the current version.
3. Update stage: The YAML file is edited (changing the image version) to trigger a rolling update.
4. Monitoring stage: The outcome (time taken, CPU usage) is recorded and output.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global nodes
    Operator["User/Operator"]:::operator

    Controller611["Update Controller 6.1.1→6.3.1"]:::python
    Controller621["Update Controller 6.2.1→6.3.1"]:::python

    %% Kubernetes Cluster subgraph
    subgraph "Kubernetes Cluster: Namespace 'roll'"
        Kustomization["Kustomization Config"]:::config
        WP["WordPress Deployment (image updated to 6.3.1)"]:::config
        MySQL["MySQL Deployment"]:::config
    end

    Monitoring["Monitoring Metrics (time,CPU)"]:::monitoring

    %% Connections
    Operator -->|"triggers"| Controller611
    Operator -->|"triggers"| Controller621

    Controller611 -->|"kubectl apply/delete"| Kustomization
    Controller621 -->|"kubectl apply/delete"| Kustomization

    Kustomization -->|"applies config"| WP
    Kustomization -->|"applies config"| MySQL

    WP -->|"rollout complete"| Monitoring
    MySQL -->|"rollout complete"| Monitoring

    %% Click Events
    click Controller611 "https://github.com/cdsl-research/roll-update/blob/main/rollupdate_611_631.py"
    click Controller621 "https://github.com/cdsl-research/roll-update/blob/main/rollupdate_621_631.py"
    click WP "https://github.com/cdsl-research/roll-update/blob/main/wordpress-deployment.yaml"
    click MySQL "https://github.com/cdsl-research/roll-update/blob/main/mysql-deployment.yaml"
    click Kustomization "https://github.com/cdsl-research/roll-update/blob/main/kustomization.yaml"

    %% Styles
    classDef operator fill:#BBDEFB,stroke:#0D47A1,stroke-width:2px,color:#0D47A1;
    classDef python fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px,color:#F57F17;
    classDef config fill:#FFCDD2,stroke:#D32F2F,stroke-width:2px,color:#B71C1C;
    classDef monitoring fill:#E1BEE7,stroke:#7B1FA2,stroke-width:2px,color:#4A148C;
```
