# giantswarm/silence-operator architecture

> Architecture diagram of the GitHub repository giantswarm/silence-operator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/giantswarm/silence-operator
- Repository: https://github.com/giantswarm/silence-operator

## Overview

Silence Operator turns Kubernetes Silence custom resources into Alertmanager silences. Users submit either the legacy cluster-scoped v1alpha1 resource or the recommended namespace-scoped v1alpha2 resource; the corresponding reconciler reads it, derives matchers, timing and tenant context, and asks the silence service to synchronize or remove the Alertmanager silence. The service compares desired and existing state through the Alertmanager client. The README also documents label-based resource filtering and namespace filtering for v1alpha2. Controller excerpts establish the main calls; startup wiring and some configuration flow are not fully shown.

Main entry points: [`internal/controller/silence_controller.go`](https://github.com/giantswarm/silence-operator/blob/main/internal/controller/silence_controller.go) (Legacy reconciler), [`internal/controller/silence_v2_controller.go`](https://github.com/giantswarm/silence-operator/blob/main/internal/controller/silence_v2_controller.go) (Namespaced reconciler), [`pkg/service/silence.go`](https://github.com/giantswarm/silence-operator/blob/main/pkg/service/silence.go) (Silence synchronization), [`cmd/main.go`](https://github.com/giantswarm/silence-operator/blob/main/cmd/main.go) (Operator process)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apis["Silence APIs"]
  node_legacy_api["Legacy Silence API<br/>[silence_types.go]"]
  node_current_api["Namespaced Silence API<br/>[silence_types.go]"]
end

subgraph group_reconcile["Reconciliation"]
  node_legacy_controller["Legacy reconciler"]
  node_current_controller["Namespaced reconciler"]
  node_config["Runtime configuration<br/>[config.go]"]
  node_operator["Operator process<br/>[main.go]"]
end

subgraph group_logic["Sync Logic"]
  node_tenancy["Tenant extraction<br/>[tenancy.go]"]
  node_service["Silence synchronization<br/>[silence.go]"]
end

subgraph group_integration["Alertmanager Integration"]
  node_am_client["Alertmanager client<br/>[alertmanager.go]"]
end

node_user(("Kubernetes user"))
node_kube[("Kubernetes API")]
node_alertmanager["Alertmanager"]

node_user -->|"submits resource"| node_kube
node_kube -->|"notifies changes"| node_legacy_controller
node_kube -->|"notifies changes"| node_current_controller
node_legacy_controller -->|"reads and updates"| node_kube
node_current_controller -->|"reads and updates"| node_kube
node_legacy_controller -->|"extracts tenant"| node_tenancy
node_current_controller -->|"extracts tenant"| node_tenancy
node_legacy_controller -->|"syncs silence"| node_service
node_current_controller -->|"syncs silence"| node_service
node_service -->|"checks and mutates"| node_am_client
node_am_client -->|"HTTP requests"| node_alertmanager
node_operator -.->|"runs controller"| node_legacy_controller
node_operator -.->|"runs controller"| node_current_controller

click node_legacy_api "https://github.com/giantswarm/silence-operator/blob/main/api/v1alpha1/silence_types.go"
click node_current_api "https://github.com/giantswarm/silence-operator/blob/main/api/v1alpha2/silence_types.go"
click node_legacy_controller "https://github.com/giantswarm/silence-operator/blob/main/internal/controller/silence_controller.go"
click node_current_controller "https://github.com/giantswarm/silence-operator/blob/main/internal/controller/silence_v2_controller.go"
click node_config "https://github.com/giantswarm/silence-operator/blob/main/pkg/config/config.go"
click node_tenancy "https://github.com/giantswarm/silence-operator/blob/main/pkg/tenancy/tenancy.go"
click node_service "https://github.com/giantswarm/silence-operator/blob/main/pkg/service/silence.go"
click node_am_client "https://github.com/giantswarm/silence-operator/blob/main/pkg/alertmanager/alertmanager.go"
click node_operator "https://github.com/giantswarm/silence-operator/blob/main/cmd/main.go"

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_legacy_api,node_current_api,node_user toneBlue
class node_legacy_controller,node_current_controller,node_config,node_operator,node_kube toneAmber
class node_tenancy,node_service toneMint
class node_am_client toneRose
class node_alertmanager toneIndigo
```

## Components

### Silence APIs

- [Legacy Silence API](https://github.com/giantswarm/silence-operator/blob/main/api/v1alpha1/silence_types.go): `api/v1alpha1/silence_types.go`
- [Namespaced Silence API](https://github.com/giantswarm/silence-operator/blob/main/api/v1alpha2/silence_types.go): `api/v1alpha2/silence_types.go`

### Reconciliation

- [Legacy reconciler](https://github.com/giantswarm/silence-operator/blob/main/internal/controller/silence_controller.go): `internal/controller/silence_controller.go`
- [Namespaced reconciler](https://github.com/giantswarm/silence-operator/blob/main/internal/controller/silence_v2_controller.go): `internal/controller/silence_v2_controller.go`
- [Runtime configuration](https://github.com/giantswarm/silence-operator/blob/main/pkg/config/config.go): `pkg/config/config.go`
- [Operator process](https://github.com/giantswarm/silence-operator/blob/main/cmd/main.go): `cmd/main.go`

### Sync Logic

- [Tenant extraction](https://github.com/giantswarm/silence-operator/blob/main/pkg/tenancy/tenancy.go): `pkg/tenancy/tenancy.go`
- [Silence synchronization](https://github.com/giantswarm/silence-operator/blob/main/pkg/service/silence.go): `pkg/service/silence.go`

### Alertmanager Integration

- [Alertmanager client](https://github.com/giantswarm/silence-operator/blob/main/pkg/alertmanager/alertmanager.go): `pkg/alertmanager/alertmanager.go`

### Other components

- **Kubernetes user**
- **Kubernetes API**
- **Alertmanager**

## Connections

- Kubernetes user → Kubernetes API: submits resource (evidence: `README.md`)
- Kubernetes API → Legacy reconciler: notifies changes (evidence: `README.md`)
- Kubernetes API → Namespaced reconciler: notifies changes (evidence: `README.md`)
- Legacy reconciler → Kubernetes API: reads and updates (evidence: `internal/controller/silence_controller.go`)
- Namespaced reconciler → Kubernetes API: reads and updates (evidence: `internal/controller/silence_v2_controller.go`)
- Legacy reconciler → Tenant extraction: extracts tenant (evidence: `internal/controller/silence_controller.go`)
- Namespaced reconciler → Tenant extraction: extracts tenant (evidence: `internal/controller/silence_v2_controller.go`)
- Legacy reconciler → Silence synchronization: syncs silence (evidence: `internal/controller/silence_controller.go`)
- Namespaced reconciler → Silence synchronization: syncs silence (evidence: `internal/controller/silence_v2_controller.go`)
- Silence synchronization → Alertmanager client: checks and mutates (evidence: `pkg/service/silence.go`)
- Alertmanager client → Alertmanager: HTTP requests (evidence: `pkg/alertmanager/alertmanager.go`)
- Operator process → Legacy reconciler: runs controller
- Operator process → Namespaced reconciler: runs controller
