# iamdevbox/github-actions-k8s-deploy architecture

> Architecture diagram of the GitHub repository iamdevbox/github-actions-k8s-deploy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamdevbox/github-actions-k8s-deploy
- Repository: https://github.com/iamdevbox/github-actions-k8s-deploy

## Overview

#### Purpose and Activation
This repository is a reusable GitHub Actions-to-Kubernetes deployment template, not a standalone application product. Its pipeline definition is intentionally stored as an example and must be copied into `.github/workflows/` to activate: `workflow-examples/deploy.yml`. It builds and deploys the bundled Node.js service from `app/`.

#### Application and Container Boundary
The deployable workload is a small Node.js/Express service with health/readiness endpoints in `app/src/index.js`. `app/Dockerfile` packages it into a container image; `app/package.json` defines its runtime dependencies and commands. The image is expected to be pushed to GitHub Container Registry (`ghcr.io`) and consumed by Kubernetes manifests.

#### CI/CD Control Flow
`workflow-examples/deploy.yml` is the central orchestrator: feature branches run validation only; `develop` builds, pushes, and deploys to staging; `main` builds, pushes, and performs production rollout/monitoring plus notification. GitHub Actions receives source-control events, authenticates to the container registry and target Kubernetes cluster using repository secrets, then applies environment-specific manifests.

#### Kubernetes Access and Registry Authentication
`k8s/rbac.yaml` establishes the namespace-scoped GitHub Actions service account, Role, and RoleBinding boundary rather than granting cluster-admin access. `scripts/generate-kubeconfig.sh` creates the scoped kubeconfig intended for `KUBE_CONFIG_STAGING` or `KUBE_CONFIG_PROD` GitHub secrets. `scripts/setup-pull-secret.sh` provisions registry credentials so cluster nodes can pull private GHCR images.

#### Staging Deployment Path
Staging is defined independently through `k8s/staging/deployment.yaml` and `k8s/staging/service.yaml`. The pipeline updates the staging workload image, waits for deployment health, and runs in-cluster smoke checks according to the workflow. The Deployment is the workload/replica boundary; the ClusterIP Service is the stable in-cluster traffic endpoint.

#### Production Progressive Delivery
Production uses `k8s/production/deployment.yaml` with `k8s/production/service.yaml` as the traffic-selection boundary, supporting versioned/blue-green rollout behavior. `k8s/production/canary.yaml` adds Flagger-based progressive delivery and traffic analysis. This introduces Flagger and its required cluster-side integrations as material external infrastructure beyond Kubernetes itself.

#### Recovery and External Integrations
`scripts/rollback.sh` is the operator-facing emergency recovery path for reverting a rollout. GitHub Actions depends on GitHub-hosted execution, GitHub Secrets, GHCR, and Kubernetes API access; Slack incoming webhooks are an optional notification sink configured through `SLACK_WEBHOOK`. The repository documents Sealed Secrets and External Secrets Operator patterns, but no corresponding manifests are present in this tree.

Main entry points: [`workflow-examples/deploy.yml`](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/workflow-examples/deploy.yml) (Deploy workflow example), [`k8s/production/deployment.yaml`](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/deployment.yaml) (Production Deployment), [`k8s/staging/deployment.yaml`](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/staging/deployment.yaml) (Staging Deployment), [`k8s/production/canary.yaml`](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/canary.yaml) (Flagger canary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Repository assets"]
  node_app["Express service<br/>Node.js workload<br/>[index.js]"]
  node_package["Runtime package<br/>Node.js manifest<br/>[package.json]"]
  node_dockerfile["Container build<br/>Dockerfile"]
  node_kubeconfig["Scoped kubeconfig generator<br/>Shell script"]
  node_pull_secret["Registry pull-secret setup<br/>Shell script"]
  node_rollback["Emergency rollback<br/>Operator script<br/>[rollback.sh]"]
end

subgraph group_github["GitHub delivery"]
  node_workflow["Deploy workflow example<br/>GitHub Actions workflow<br/>[deploy.yml]"]
  node_github_events(("Source-control events<br/>GitHub trigger"))
  node_secrets[("Repository secrets<br/>GitHub Secrets")]
  node_smoke_checks["In-cluster smoke checks<br/>Workflow stage<br/>[deploy.yml]"]
end

subgraph group_cluster["Kubernetes"]
  node_rbac["Namespace RBAC<br/>Kubernetes access policy<br/>[rbac.yaml]"]
  node_staging_deployment["Staging Deployment<br/>Kubernetes workload<br/>[deployment.yaml]"]
  node_staging_service{{"Staging Service<br/>ClusterIP Service<br/>[service.yaml]"}}
  node_production_deployment["Production Deployment<br/>Kubernetes workload<br/>[deployment.yaml]"]
  node_production_service{{"Production Service<br/>Traffic selector<br/>[service.yaml]"}}
  node_canary["Flagger canary<br/>Progressive delivery policy<br/>[canary.yaml]"]
end

subgraph group_external["External integrations"]
  node_ghcr[("GHCR<br/>Container registry")]
  node_flagger{{"Flagger integrations<br/>Cluster infrastructure"}}
  node_slack(("Slack webhook<br/>Notification sink"))
end

node_package -->|"defines runtime"| node_app
node_dockerfile -->|"packages"| node_app
node_github_events -->|"triggers"| node_workflow
node_secrets -->|"authenticates"| node_workflow
node_kubeconfig -->|"supplies KUBE_CONFIG values"| node_secrets
node_rbac -->|"scopes API identity"| node_kubeconfig
node_workflow -->|"builds"| node_dockerfile
node_workflow -->|"pushes image"| node_ghcr
node_pull_secret -->|"configures pulls from"| node_ghcr
node_workflow -->|"develop deploys"| node_staging_deployment
node_staging_deployment -->|"served by"| node_staging_service
node_workflow -->|"runs after staging"| node_smoke_checks
node_smoke_checks -->|"checks"| node_staging_service
node_workflow -->|"main deploys"| node_production_deployment
node_production_deployment -->|"selected by"| node_production_service
node_canary -->|"progressively rolls out"| node_production_deployment
node_canary -->|"requires"| node_flagger
node_workflow -.->|"optionally notifies"| node_slack
node_rollback -->|"reverts"| node_production_deployment
node_ghcr -->|"image source"| node_staging_deployment
node_ghcr -->|"image source"| node_production_deployment

click node_app "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/app/src/index.js"
click node_package "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/app/package.json"
click node_dockerfile "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/app/Dockerfile"
click node_workflow "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/workflow-examples/deploy.yml"
click node_kubeconfig "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/scripts/generate-kubeconfig.sh"
click node_rbac "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/rbac.yaml"
click node_pull_secret "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/scripts/setup-pull-secret.sh"
click node_staging_deployment "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/staging/deployment.yaml"
click node_staging_service "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/staging/service.yaml"
click node_smoke_checks "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/workflow-examples/deploy.yml"
click node_production_deployment "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/deployment.yaml"
click node_production_service "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/service.yaml"
click node_canary "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/canary.yaml"
click node_rollback "https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/scripts/rollback.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_package,node_dockerfile,node_kubeconfig,node_pull_secret,node_rollback toneBlue
class node_workflow,node_github_events,node_secrets,node_smoke_checks toneAmber
class node_rbac,node_staging_deployment,node_staging_service,node_production_deployment,node_production_service,node_canary toneMint
class node_ghcr,node_flagger,node_slack toneRose
```

## Components

### Repository assets

- [Express service](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/app/src/index.js): Node.js workload · Provides health and readiness endpoints. · `app/src/index.js`
- [Runtime package](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/app/package.json): Node.js manifest · `app/package.json`
- [Container build](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/app/Dockerfile): Dockerfile · `app/Dockerfile`
- [Scoped kubeconfig generator](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/scripts/generate-kubeconfig.sh): Shell script · Produces kubeconfig values for staging or production secrets. · `scripts/generate-kubeconfig.sh`
- [Registry pull-secret setup](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/scripts/setup-pull-secret.sh): Shell script · Provisions node access to private GHCR images. · `scripts/setup-pull-secret.sh`
- [Emergency rollback](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/scripts/rollback.sh): Operator script · Reverts a rollout outside the normal pipeline. · `scripts/rollback.sh`

### GitHub delivery

- [Deploy workflow example](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/workflow-examples/deploy.yml): GitHub Actions workflow · Must be copied into .github/workflows/ to activate. · `workflow-examples/deploy.yml`
- **Source-control events**: GitHub trigger · Feature branches validate; develop targets staging; main targets production.
- **Repository secrets**: GitHub Secrets · Supplies registry, cluster, and optional Slack credentials.
- [In-cluster smoke checks](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/workflow-examples/deploy.yml): Workflow stage · `workflow-examples/deploy.yml`

### Kubernetes

- [Namespace RBAC](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/rbac.yaml): Kubernetes access policy · Limits GitHub Actions to a service account, Role, and RoleBinding. · `k8s/rbac.yaml`
- [Staging Deployment](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/staging/deployment.yaml): Kubernetes workload · Replica and deployment-health boundary. · `k8s/staging/deployment.yaml`
- [Staging Service](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/staging/service.yaml): ClusterIP Service · Stable in-cluster staging endpoint. · `k8s/staging/service.yaml`
- [Production Deployment](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/deployment.yaml): Kubernetes workload · Supports versioned or blue-green rollout. · `k8s/production/deployment.yaml`
- [Production Service](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/service.yaml): Traffic selector · Production traffic-selection boundary. · `k8s/production/service.yaml`
- [Flagger canary](https://github.com/iamdevbox/github-actions-k8s-deploy/blob/main/k8s/production/canary.yaml): Progressive delivery policy · Defines traffic analysis for production rollout. · `k8s/production/canary.yaml`

### External integrations

- **GHCR**: Container registry
- **Flagger integrations**: Cluster infrastructure · Required cluster-side progressive-delivery components.
- **Slack webhook**: Notification sink · Optional delivery notification target.

## Connections

- Runtime package → Express service: defines runtime
- Container build → Express service: packages
- Source-control events → Deploy workflow example: triggers
- Repository secrets → Deploy workflow example: authenticates
- Scoped kubeconfig generator → Repository secrets: supplies KUBE_CONFIG values
- Namespace RBAC → Scoped kubeconfig generator: scopes API identity
- Deploy workflow example → Container build: builds
- Deploy workflow example → GHCR: pushes image
- Registry pull-secret setup → GHCR: configures pulls from
- Deploy workflow example → Staging Deployment: develop deploys
- Staging Deployment → Staging Service: served by
- Deploy workflow example → In-cluster smoke checks: runs after staging
- In-cluster smoke checks → Staging Service: checks
- Deploy workflow example → Production Deployment: main deploys
- Production Deployment → Production Service: selected by
- Flagger canary → Production Deployment: progressively rolls out
- Flagger canary → Flagger integrations: requires
- Deploy workflow example → Slack webhook: optionally notifies
- Emergency rollback → Production Deployment: reverts
- GHCR → Staging Deployment: image source
- GHCR → Production Deployment: image source
