# cray-hpe/csm architecture

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

- Interactive diagram: https://gitdiagram.com/cray-hpe/csm
- Repository: https://github.com/cray-hpe/csm

## Overview

Below are detailed instructions and guidelines tailored to this project:

##### Main components

- Source Repository & Configuration
- This includes the Git repository itself with all configuration files in the .github directory (workflows, pull request templates, CODEOWNERS), the Jenkinsfile, and other CI/CD related files.
- Makefile at the top level, which orchestrates many of the build steps.

- Build & Release Pipeline
- CI/CD: Represent the integration between GitHub Actions (as shown in .github/workflows) and the Jenkins-based processes (Jenkinsfile.github).
- Build Scripts: Highlight key scripts under “build/”, “assets.sh”, “common.sh”, “get_base.sh”, “release.sh” and “upgrade.sh” that control different phases (preparing images, packaging, release process).
- Hack Scripts: Include the “hack/” directory, which houses helper scripts for container image verifications, signing, scanning (Snyk, Trivy), and swagger documentation generation.

- Packaging Components:
- RPM Packaging: Show the “rpm/” folder with its subdivisions for various supported environments (e.g., cray/csm with multiple SLE versions), cloud-init configuration.
- Helm & Manifests: Capture the “helm/” and “manifests/” directories that contain Kubernetes chart definitions and deployment files for core services like Nexus, Keycloak, etc.
- Docker & Container Images: Identify the “docker/” folder and “build/images/” scripts that help manage container images required for different parts of the release.

- Security & Integrity Checks:
- Security Directory: Emphasize “security/” which includes Snyk scan results, Dockerfiles, signing keys (under “security/sign/keys”), and signing scripts that ensure released artifacts are verified.
- Additional testing scripts found in “lib/” that set up tests (such as goss tests) and other readiness checks.

- Artifact Distribution:
- The final stage of the build—the result is a release distribution that is automatically uploaded to the designated Artifactory repository ("csm-releases").
- Flow from the build artifacts (RPMs, container images, Helm charts) to the external Artifactory system.

##### Relationships & Interactions

- How the CI/CD components (GitHub workflows, Jenkins) trigger execution of the Makefile and associated shell scripts.
- That “hack/” and “lib/” provide utility and verification functions throughout the pipeline.

##### Architectural Patterns & Design Principles

- Modularity: The project separates build, security, and package creation into distinct directories (“build”, “hack”, “rpm”, “helm”), which suggests a modular and maintainable approach.
- Pipeline Automation: Emphasizing CI/CD integration via GitHub workflows and Jenkins ensures automated, repeatable release processes.
- Security by Design: The inclusion of Snyk scans, container image verification scripts, and secure signing of artifacts emphasizes a security-first process.

##### Relevant Technologies and Tools

- GitHub Actions / Jenkins (CI/CD orchestration)
- Make and Shell Scripts (build and automation)
- Docker and Helm (for container images and Kubernetes packaging)
- Artifactory (artifact repository)
- Security scanning tools (Snyk, Trivy)
- RPM packaging tools for various SLE distributions

##### Specific Elements

- Labels: Clearly label nodes such as “GitHub Repository,” “Jenkins / GitHub Actions CI/CD,” “Build Scripts (Makefile, assets.sh, etc.),” “Docker Image Build,” “Helm Chart Packaging,” “RPM Packaging,” “Security & Signing,” and “Artifact Upload (Artifactory).”
- Automation & orchestration elements (e.g., CI/CD components) versus script/tool components (e.g., build scripts, test scripts).
- Packaging outputs (e.g., container images, RPM packages, Helm charts).
- Security verification steps (e.g., Snyk scans, signing processes).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Control & CI/CD Layer
    subgraph "Source Control & CI/CD"
        Source1["GitHub Config"]:::source
        Source2["Jenkins CI Config"]:::source
    end

    %% Build & Pre-packaging Layer
    subgraph "Build & Pre-packaging"
        Build1["Build Orchestration (Makefile)"]:::build
        Build2["Build Scripts (Shell Scripts)"]:::build
        Build3["Image Build (build/images)"]:::build
        Build4["Hack Scripts"]:::build
    end

    %% Packaging Components Layer
    subgraph "Packaging Components"
        Pack1["RPM Packaging"]:::packaging
        Pack2["Helm & Manifests Packaging"]:::packaging
        Pack3["Docker Image Build"]:::packaging
    end

    %% Security & Integrity Layer
    subgraph "Security & Integrity"
        Sec1["Security & Signing (Snyk/Trivy)"]:::security
        Sec2["Test Scripts (lib)"]:::security
    end

    %% Artifact Distribution Layer
    subgraph "Artifact Distribution"
        Dist1["Artifact Upload (Artifactory)"]:::distribution
    end

    %% Connections for vertical flow
    Source1 -->|"triggers"| Source2
    Source2 -->|"initiates"| Build1
    Build1 -->|"executes"| Build2
    Build2 -->|"prepares"| Build3
    Build3 -->|"supports"| Build4
    Build4 -->|"feeds packaging"| Pack1
    Build4 -->|"feeds packaging"| Pack2
    Build4 -->|"feeds packaging"| Pack3
    Pack1 -->|"packages for"| Sec1
    Pack2 -->|"packages for"| Sec1
    Pack3 -->|"packages for"| Sec1
    Sec2 -->|"verifies"| Sec1
    Sec1 -->|"releases to"| Dist1

    %% Click Events for Source Control & CI/CD
    click Source1 "https://github.com/cray-hpe/csm/blob/release/1.7/.github"
    click Source2 "https://github.com/cray-hpe/csm/blob/release/1.7/Jenkinsfile.github"

    %% Click Events for Build & Pre-packaging
    click Build1 "https://github.com/cray-hpe/csm/tree/release/1.7/Makefile"
    click Build2 "https://github.com/cray-hpe/csm/blob/release/1.7/assets.sh"
    click Build2 "https://github.com/cray-hpe/csm/blob/release/1.7/common.sh"
    click Build2 "https://github.com/cray-hpe/csm/blob/release/1.7/get_base.sh"
    click Build2 "https://github.com/cray-hpe/csm/blob/release/1.7/release.sh"
    click Build2 "https://github.com/cray-hpe/csm/blob/release/1.7/upgrade.sh"
    click Build3 "https://github.com/cray-hpe/csm/tree/release/1.7/build/images"
    click Build4 "https://github.com/cray-hpe/csm/tree/release/1.7/hack"

    %% Click Events for Packaging Components
    click Pack1 "https://github.com/cray-hpe/csm/tree/release/1.7/rpm"
    click Pack2 "https://github.com/cray-hpe/csm/tree/release/1.7/helm"
    click Pack3 "https://github.com/cray-hpe/csm/tree/release/1.7/docker"

    %% Click Events for Security & Integrity
    click Sec1 "https://github.com/cray-hpe/csm/tree/release/1.7/security"
    click Sec2 "https://github.com/cray-hpe/csm/tree/release/1.7/lib"

    %% Styles
    classDef source fill:#E0FFE0,stroke:#006400,stroke-width:2px;
    classDef build fill:#E0E0FF,stroke:#0000CD,stroke-width:2px;
    classDef packaging fill:#FFFACD,stroke:#DAA520,stroke-width:2px;
    classDef security fill:#FFD2D2,stroke:#B22222,stroke-width:2px;
    classDef distribution fill:#DCD0FF,stroke:#4B0082,stroke-width:2px;
```
