# 0jk6/conjur-operator architecture

> Architecture diagram of the GitHub repository 0jk6/conjur-operator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0jk6/conjur-operator
- Repository: https://github.com/0jk6/conjur-operator

## Overview

##### Main Components

a) Core Operator Components:
- Controller Manager (main control loop)
- Custom Resource Definition (CRD) for Conjur type
- Webhook Server (if applicable)
- RBAC Components (ServiceAccount, Roles, RoleBindings)

b) External Systems:
- CyberArk Conjur Vault
- Kubernetes API Server
- Target Kubernetes Secrets

**┌─ Kubernetes Cluster ──────────────────────────────────────────┐**

- ┌─ Operator Namespace ─────────────────────┐                │

- ┌─ Conjur Operator Pod ─────────────┐   │                │

- Controller Manager             │   │                │
- Metrics Server                 │   │                │
- Leader Election               │   │                │
- ┘   │                │

- ┘                │

- ┌─ Target Namespace ──────────────────────┐                │

- Conjur Custom Resource               │                │
- Generated Kubernetes Secrets          │                │

- ┘                │

- ┘

**┌─ External Systems ─────────────────────────┐**

- CyberArk Conjur Vault                    │
- Secrets Storage                        │
- Authentication                         │

- ┘

##### Key Interactions to Highlight

- Controller watching for Conjur CR changes (→)
- API calls to CyberArk Conjur Vault (↔)
- Secret creation/updates in target namespaces (→)
- RBAC permissions and scope (- - ->)

##### Technical Details

Annotations showing:
- Go version requirement (v1.21.0+)
- Kubernetes version compatibility (v1.11.3+)
- Container runtime requirements
- API Group: api.0jk6.github.io/v1alpha1

##### Implementation Notes

- The operator's reconciliation loop
- Secret management workflow
- Security boundaries
- Namespace isolation
- Resource ownership and garbage collection

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph cluster["Kubernetes Cluster"]
        subgraph operator["Operator Namespace"]
            subgraph pod["Conjur Operator Pod"]
                controller["Controller Manager"]:::controller
                metrics["Metrics Server"]:::monitoring
                leader["Leader Election"]:::controller
            end
            sa["ServiceAccount"]:::rbac
            role["RBAC Roles"]:::rbac
            binding["RoleBindings"]:::rbac
        end

        subgraph target["Target Namespace"]
            cr["Conjur Custom Resource"]:::cr
            secrets["Generated K8s Secrets"]:::secret
        end

        apiserver["Kubernetes API Server"]:::k8s
    end

    subgraph external["External Systems"]
        vault["CyberArk Conjur Vault"]:::external
    end

    %% Relationships
    controller --> apiserver
    controller --> cr
    controller --> secrets
    controller <--> vault
    sa --> controller
    role --> sa
    binding --> role
    leader --> controller
    metrics --> controller

    %% Click Events
    click controller "https://github.com/0jk6/conjur-operator/blob/main/internal/controller/conjur_controller.go"
    click cr "https://github.com/0jk6/conjur-operator/blob/main/config/crd/bases/api.0jk6.github.io_conjurs.yaml"
    click sa "https://github.com/0jk6/conjur-operator/blob/main/config/rbac/service_account.yaml"
    click role "https://github.com/0jk6/conjur-operator/blob/main/config/rbac/role.yaml"
    click binding "https://github.com/0jk6/conjur-operator/blob/main/config/rbac/role_binding.yaml"
    click leader "https://github.com/0jk6/conjur-operator/blob/main/config/rbac/leader_election_role.yaml"
    click metrics "https://github.com/0jk6/conjur-operator/blob/main/config/prometheus/monitor.yaml"

    %% Legend
    classDef controller fill:#90EE90,stroke:#333,stroke-width:2px
    classDef monitoring fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef rbac fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef cr fill:#FFD700,stroke:#333,stroke-width:2px
    classDef secret fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef k8s fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef external fill:#FF6B6B,stroke:#333,stroke-width:2px

    %% Legend Nodes
    L1["Controller Components"]:::controller
    L2["Monitoring"]:::monitoring
    L3["RBAC Components"]:::rbac
    L4["Custom Resources"]:::cr
    L5["Secrets"]:::secret
    L6["Kubernetes Native"]:::k8s
    L7["External Systems"]:::external
```
