# iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster architecture

> Architecture diagram of the GitHub repository iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster
- Repository: https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster

## Overview

##### Main Components
- Master Node and Worker Node(s): Represent the control plane (master) and the compute nodes (workers) where the application and database pods run.
- Application Tier (PHP App):
- A PHP pod running the PHP To-Do Application built from the provided Dockerfile and index.php.
- Exposed via a NodePort service (phpapp-svc) on port 8088.
- Data Tier (MySQL Database):
- A MySQL pod (mysql-pod) configured via a YAML file.
- Environment variables are injected via a ConfigMap (db-config) and a Secret (db-secret).
- Exposed via a ClusterIP service (mysql-svc) on port 3306.
- Administration Tier (phpMyAdmin):
- A phpMyAdmin pod (phpadmin-pod) set up through its respective YAML file.
- Configured through a ConfigMap (phpadmin-config) and Secret (phpadmin-secret).
- Exposed via a NodePort service (phpadmin-svc) on a designated port (8099).

##### Relationships and Interactions
- The PHP application (frontend) communicates with the MySQL database (backend) via the ClusterIP service.
- phpMyAdmin interacts with the MySQL pod (again using the ClusterIP) to manage the database.
- End-users access the PHP app and phpMyAdmin using their respective NodePort services configured on the Kubernetes cluster.
- The Kubernetes setup (using kubeadm) on both master and worker nodes orchestrates scheduling, deployment, and networking between the pods.

##### Architectural Patterns and Design Principles
- Three-Tier Architecture: Clearly separates presentation (PHP app), business/data logic (MySQL), and administration (phpMyAdmin).
- Containerization & Orchestration: Docker images (via Dockerfile) and Kubernetes pods ensure modularity and scalability.
- Environment Configuration: Use of ConfigMaps and Secrets shows best practices in managing configuration data distinct from code.
- Microservices/Pod Pattern: Even though the components are relatively monolithic in function, they run in separate pods, demonstrating a loosely-coupled design.

##### Technologies & Frameworks
- PHP for the application logic.
- MySQL as the database.
- phpMyAdmin for database administration.
- Docker for containerization.
- Kubernetes as the orchestration platform (using kubeadm for cluster setup).

## Diagram (Mermaid)

```mermaid
flowchart TD
    user["End Users"]:::external

    svc_app["phpapp-svc (NodePort:8088)"]:::service
    svc_db["mysql-svc (ClusterIP:3306)"]:::service
    svc_admin["phpadmin-svc (NodePort:8099)"]:::service

    user -->|"accesses"| svc_app
    user -->|"accesses"| svc_admin

    subgraph "Kubernetes Cluster"
        subgraph "Master Node"
            master["Master Node"]:::master
            km_setup["kubeadm_master_install.sh"]:::k8s
            master --> km_setup
        end

        subgraph "Worker Node"
            subgraph "Application Tier"
                php_app["PHP To-Do App Pod"]:::app
                dockerfile["Dockerfile"]:::file
                indexphp["index.php"]:::file
                php_app --- dockerfile
                php_app --- indexphp
            end

            subgraph "Data Tier"
                mysql["MySQL Pod"]:::db
                mysql_yaml["mysql-pod.yml"]:::file
                simple_sql["simple_todo.sql"]:::file
                mysql --- mysql_yaml
                mysql --- simple_sql
            end

            subgraph "Administration Tier"
                phpadmin["phpMyAdmin Pod"]:::admin
                phpadmin_yaml["phpadmin-pod.yml"]:::file
                phpadmin --- phpadmin_yaml
            end

            kube_node["kubeadm_node_install.sh"]:::k8s
        end
    end

    svc_app -->|"routes_to"| php_app
    svc_admin -->|"routes_to"| phpadmin
    php_app -->|"calls"| svc_db
    phpadmin -->|"accesses"| svc_db
    mysql --> svc_db

    click dockerfile "https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster/tree/master/Dockerfile"
    click indexphp "https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster/blob/master/index.php"
    click mysql_yaml "https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster/blob/master/mysql-pod.yml"
    click simple_sql "https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster/blob/master/simple_todo.sql"
    click phpadmin_yaml "https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster/blob/master/phpadmin-pod.yml"
    click km_setup "https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster/blob/master/kubeadm_master_install.sh"
    click kube_node "https://github.com/iamsaikishore/project4---deploying-a-sample-php-to-do-3-tier-application-on-kubernetes-cluster/blob/master/kubeadm_node_install.sh"

    classDef external fill:#ffdddd,stroke:#990000,stroke-width:2px;
    classDef service fill:#ffe599,stroke:#b38600,stroke-width:2px,stroke-dasharray: 5 5;
    classDef app fill:#c9daf8,stroke:#1155cc,stroke-width:2px;
    classDef db fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef admin fill:#ead1dc,stroke:#8e44ad,stroke-width:2px;
    classDef master fill:#fff2cc,stroke:#e69138,stroke-width:2px;
    classDef k8s fill:#f4cccc,stroke:#cc0000,stroke-width:2px,stroke-dasharray: 3,3;
    classDef file fill:#eeeeee,stroke:#666666,stroke-width:1px,stroke-dasharray: 2,2;
```
