# bmuschko/cks-crash-course architecture

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

- Interactive diagram: https://gitdiagram.com/bmuschko/cks-crash-course
- Repository: https://github.com/bmuschko/cks-crash-course

## Overview

##### Project type and purpose
- This is an educational/training repository designed to prepare candidates for the Certified Kubernetes Security Specialist (CKS) exam.
- It contains self-contained, hands-on exercises covering topics like Network Policies, TLS Ingress, OPA Gatekeeper, image scanning (Trivy), runtime security (Falco), Pod Security Standards, audit logging, AppArmor, and more.
- Learners follow instructions, run setup scripts or Vagrantfile VMs, and apply Kubernetes manifests to a local or VM-based cluster.

##### File structure
- Top-level folders:
- .github/workflows: CI validation of Kubernetes manifest syntax
- exercises: 12 numbered exercise subfolders (each has instructions.md, setup scripts or YAML, and solution folder)
- prerequisites: environment setup instructions
- slides.pdf: training slides
- exercises/scripts: common shell scripts to bootstrap control plane and workers
- Pattern: each exercise is a module that provisions or configures part of a k8s cluster, applies policies or tooling, and demonstrates a security concept.
- Configuration files: YAML manifests for Kubernetes resources, Vagrantfiles, shell scripts to install agents or tools.

##### README for additional insights
- README defines the scope: a performance-based course aligned to CNCF CKS curriculum.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Workstation
    Workstation["Developer/Trainee Workstation\n(Prerequisites)"]:::infra
    click Workstation "https://github.com/bmuschko/cks-crash-course/blob/master/prerequisites/instructions.md"

    %% Provisioning Layer
    subgraph "Provisioning Layer"
        CommonSh["common.sh"]:::infra
        ControlPlaneSh["control-plane.sh"]:::infra
        WorkerSh["worker.sh"]:::infra
        VagrantSetup["vagrant-setup.md"]:::infra
        VF05["Vagrantfile (Exercise 05)"]:::infra
        VF10["Vagrantfile (Exercise 10)"]:::infra
        VF12["Vagrantfile (Exercise 12)"]:::infra
    end
    click CommonSh "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/scripts/common.sh"
    click ControlPlaneSh "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/scripts/control-plane.sh"
    click WorkerSh "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/scripts/worker.sh"
    click VagrantSetup "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/common/vagrant-setup.md"
    click VF05 "https://github.com/bmuschko/cks-crash-course/tree/master/exercises/05-apparmor-network-call/Vagrantfile"
    click VF10 "https://github.com/bmuschko/cks-crash-course/tree/master/exercises/10-behavioral-analysis-falco/Vagrantfile"
    click VF12 "https://github.com/bmuschko/cks-crash-course/tree/master/exercises/12-audit-logging/Vagrantfile"

    Workstation --> ProvisioningLayer
    ProvisioningLayer --> ControlPlane
    ProvisioningLayer --> WorkerNodes

    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        direction TB
        ControlPlane["Control Plane\n(API Server, etcd,\nController Manager, Scheduler)"]:::control
        WorkerNodes["Worker Nodes\n(kubelet, kube-proxy,\nContainer Runtime)"]:::control
        NetworkPlugin["Cilium (CNI)"]:::network
        IngressController["Ingress Controller\n(TLS)"]:::infra
        APIAudit["Audit Logging Backend"]:::audit
    end
    click NetworkPlugin "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/01-network-policy-restrict/cilium-setup.md"
    click IngressController "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/02-tls-ingress/ingress-controller-setup.md"
    click APIAudit "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/12-audit-logging/audit-log-backend-setup.md"

    ControlPlane -->|manages| WorkerNodes
    WorkerNodes -->|uses CNI| NetworkPlugin
    ControlPlane -->|streams audit logs| APIAudit
    IngressController -->|routes traffic| WorkerNodes

    %% Security Tools
    subgraph "Security Tools & Engines"
        direction TB
        NetPolicy["Network Policies"]:::security
        PodSecurity["Pod Security Admission"]:::security
        OPA["OPA Gatekeeper"]:::security
        AppArmor["AppArmor Profiles"]:::security
        Trivy["Trivy\n(Image Scanning)"]:::security
        Falco["Falco\n(Runtime Analysis)"]:::security
    end
    click NetPolicy "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/01-network-policy-restrict/setup.yaml"
    click PodSecurity "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/06-pod-security-admission/pod-non-root.yaml"
    click OPA "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/07-opa-gatekeeping/opa-constraint-template-annotation.yaml"
    click AppArmor "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/05-apparmor-network-call/pod-setup.sh"
    click Trivy "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/09-image-scanning-trivy/trivy-setup.md"
    click Falco "https://github.com/bmuschko/cks-crash-course/blob/master/exercises/10-behavioral-analysis-falco/falco-install.sh"

    ControlPlane -->|admits via| OPA
    WorkerNodes -->|enforces| AppArmor
    WorkerNodes -->|enforces| PodSecurity
    ControlPlane -->|enforces| NetPolicy
    WorkerNodes -->|scan images| Trivy
    WorkerNodes -->|monitor runtime| Falco

    %% Exercise Modules
    subgraph "Exercise Modules"
        direction TB
        ex1["01 Network Policy"] 
        ex2["02 TLS Ingress"]
        ex5["05 AppArmor + Network"]
        ex6["06 Pod Security"]
        ex7["07 OPA Gatekeeper"]
        ex9["09 Image Scanning"]
        ex10["10 Behavioral Analysis"]
        ex12["12 Audit Logging"]
    end

    Workstation -->|applys manifests| ex1
    Workstation -->|applys manifests| ex2
    Workstation -->|applys manifests| ex5
    Workstation -->|applys manifests| ex6
    Workstation -->|applys manifests| ex7
    Workstation -->|applys manifests| ex9
    Workstation -->|applys manifests| ex10
    Workstation -->|applys manifests| ex12

    ex1 --> NetPolicy
    ex2 --> IngressController
    ex5 --> AppArmor
    ex5 --> NetPolicy
    ex6 --> PodSecurity
    ex7 --> OPA
    ex9 --> Trivy
    ex10 --> Falco
    ex12 --> APIAudit

    %% Styles
    classDef infra fill:#B3CDE3,stroke:#000,color:#000;
    classDef control fill:#CCEBC5,stroke:#000,color:#000;
    classDef network fill:#FED9A6,stroke:#000,color:#000;
    classDef security fill:#FBB4AE,stroke:#000,color:#000;
    classDef audit fill:#DECBE4,stroke:#000,color:#000;
```
