# kentik/kagent-helm architecture

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

- Interactive diagram: https://gitdiagram.com/kentik/kagent-helm
- Repository: https://github.com/kentik/kagent-helm

## Overview

#### Purpose and entry points
This repository is a Helm 3 chart that renders Kubernetes resources for Kentik Universal Agent (`kagent`). Operators install or upgrade it with `helm install` / `helm upgrade`; Helm package metadata and defaults enter through `Chart.yaml` and `values.yaml`. Values are contract-validated by `contracts/values.schema.json`.

#### Deployment-pattern selection
`deploymentType` is the top-level control boundary: StatefulSet is the default for stable pod identity and PVC-backed persistence; DaemonSet targets one agent per node for node-local monitoring. Templates conditionally render the appropriate immutable workload type, so switching patterns requires uninstall/reinstall rather than in-place upgrade.
- `templates/statefulset.yaml`
- `templates/daemonset.yaml`
- `values.yaml`

#### Agent runtime and registration
The rendered workload runs the external `kentik/kagent` container image. Configuration passes company ID, release/channel/log/API settings, and optional overrides into the container; the provisioning token is isolated in a Kubernetes Secret and consumed through a secret reference. The agent registers/connects to Kentik’s gRPC API (`grpc.api.kentik.com:443`) and awaits authorization in the Kentik Portal.
- `templates/statefulset.yaml`
- `templates/daemonset.yaml`
- `templates/secret-provisioning-token.yaml`

#### Identity and persistence boundary
The agent’s ed25519 keypair is its durable identity and must survive pod recreation. The chart supports secret, PVC, hostPath, or emptyDir keypair backends, while application data can use PVC, hostPath, or emptyDir. StatefulSet supports per-pod PVCs and stable ordinal identity; DaemonSet operationally requires hostPath for persistent storage. Secret-backed keys are expected to be provisioned before installation and are copied into the runtime key directory by workload initialization.
- `templates/statefulset.yaml`
- `templates/daemonset.yaml`
- `templates/pvc.yaml`

#### Kubernetes support resources
The chart establishes the workload’s Kubernetes identity and optional access controls: ServiceAccount is normally created, RBAC resources are opt-in, and helper templates provide consistent release/name labels. PVC manifests supply persistent claims when selected by values.
- `templates/serviceaccount.yaml`
- `templates/role.yaml`
- `templates/rolebinding.yaml`

#### Network and configuration controls
An optional ConfigMap supplies advanced environment-level settings, with workload environment values taking precedence. An optional NetworkPolicy constrains egress, intended to allow DNS, Kentik API HTTPS/gRPC traffic, and optionally SNMP target networks. These are cluster-enforced boundaries and depend on a CNI that implements NetworkPolicy.
- `templates/configmap.yaml`
- `templates/networkpolicy.yaml`
- `values.yaml`

#### Secret provisioning and delivery
The chart creates the registration-token Secret, but keypair Secrets are an external lifecycle concern when `persistence.keypair.type=secret`. Helper scripts generate provisioning tokens and per-replica PEM-secret manifests; production users may instead synchronize Kubernetes Secrets from Vault or cloud secret managers. Scaling a StatefulSet requires identity material for each new ordinal before scaling.
- `generate-provisioning-token.sh`
- `generate-secrets.sh`
- `templates/secret-provisioning-token.yaml`

#### Validation and CI
Schema validation constrains chart inputs, while CI and Helm-oriented tests validate rendered manifests across the two workload patterns and persistence/token choices.
- `contracts/values.schema.json`
- `.github/workflows/ci.yaml`
- `tests/validation_test.yaml`

Main entry points: [`values.yaml`](https://github.com/kentik/kagent-helm/blob/main/values.yaml) (Chart values), [`tests/validation_test.yaml`](https://github.com/kentik/kagent-helm/blob/main/tests/validation_test.yaml) (Helm validation tests), [`templates/statefulset.yaml`](https://github.com/kentik/kagent-helm/blob/main/templates/statefulset.yaml) (StatefulSet template), [`templates/daemonset.yaml`](https://github.com/kentik/kagent-helm/blob/main/templates/daemonset.yaml) (DaemonSet template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chart["Chart inputs &amp; rendering"]
  node_chart_metadata["Chart metadata<br/>Helm chart<br/>[Chart.yaml]"]
  node_values["Chart values<br/>Helm defaults<br/>[values.yaml]"]
  node_schema["Values schema<br/>input contract<br/>[values.schema.json]"]
  node_statefulset["StatefulSet template<br/>conditional workload<br/>[statefulset.yaml]"]
  node_daemonset["DaemonSet template<br/>conditional workload<br/>[daemonset.yaml]"]
end

subgraph group_k8s["Kubernetes resources"]
  node_service_identity["ServiceAccount &amp; RBAC<br/>Kubernetes access"]
  node_pvc[("PersistentVolumeClaim<br/>persistent storage<br/>[pvc.yaml]")]
  node_token_secret["Provisioning token Secret<br/>Kubernetes Secret"]
  node_configmap["Advanced ConfigMap<br/>optional configuration<br/>[configmap.yaml]"]
  node_network_policy{{"NetworkPolicy<br/>optional egress boundary<br/>[networkpolicy.yaml]"}}
  node_keypair_storage[("Durable keypair storage<br/>identity backend")]
end

subgraph group_runtime["Agent &amp; external services"]
  node_agent_workload["Rendered agent workload<br/>StatefulSet or DaemonSet"]
  node_kagent["kentik/kagent container<br/>agent runtime"]
  node_kentik_api(("Kentik gRPC API<br/>external service"))
end

subgraph group_delivery["Provisioning &amp; validation"]
  node_token_script["Token generator<br/>provisioning script"]
  node_keypair_script["Keypair secret generator<br/>provisioning script"]
  node_ci["CI validation<br/>chart verification<br/>[ci.yaml]"]
  node_helm_tests["Helm validation tests<br/>test suite"]
end

node_chart_metadata -->|"packages with"| node_values
node_schema -->|"validates"| node_values
node_values -->|"selects default"| node_statefulset
node_values -->|"selects node mode"| node_daemonset
node_statefulset -->|"renders"| node_agent_workload
node_daemonset -->|"renders"| node_agent_workload
node_agent_workload -->|"runs"| node_kagent
node_service_identity -->|"supplies identity/access"| node_agent_workload
node_pvc -->|"mounts when selected"| node_agent_workload
node_keypair_storage -->|"mounts identity"| node_agent_workload
node_token_secret -->|"injects token"| node_agent_workload
node_configmap -->|"adds optional settings"| node_agent_workload
node_network_policy -->|"constrains egress"| node_agent_workload
node_kagent -->|"registers/connects"| node_kentik_api
node_token_script -->|"generates token for"| node_token_secret
node_keypair_script -->|"provisions secret-backed keys"| node_keypair_storage
node_ci -->|"runs"| node_helm_tests
node_helm_tests -.->|"validates"| node_statefulset
node_helm_tests -.->|"validates"| node_daemonset

click node_chart_metadata "https://github.com/kentik/kagent-helm/blob/main/Chart.yaml"
click node_values "https://github.com/kentik/kagent-helm/blob/main/values.yaml"
click node_schema "https://github.com/kentik/kagent-helm/blob/main/contracts/values.schema.json"
click node_statefulset "https://github.com/kentik/kagent-helm/blob/main/templates/statefulset.yaml"
click node_daemonset "https://github.com/kentik/kagent-helm/blob/main/templates/daemonset.yaml"
click node_service_identity "https://github.com/kentik/kagent-helm/blob/main/templates/serviceaccount.yaml"
click node_pvc "https://github.com/kentik/kagent-helm/blob/main/templates/pvc.yaml"
click node_token_secret "https://github.com/kentik/kagent-helm/blob/main/templates/secret-provisioning-token.yaml"
click node_configmap "https://github.com/kentik/kagent-helm/blob/main/templates/configmap.yaml"
click node_network_policy "https://github.com/kentik/kagent-helm/blob/main/templates/networkpolicy.yaml"
click node_token_script "https://github.com/kentik/kagent-helm/blob/main/generate-provisioning-token.sh"
click node_keypair_script "https://github.com/kentik/kagent-helm/blob/main/generate-secrets.sh"
click node_ci "https://github.com/kentik/kagent-helm/blob/main/.github/workflows/ci.yaml"
click node_helm_tests "https://github.com/kentik/kagent-helm/blob/main/tests/validation_test.yaml"

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_chart_metadata,node_values,node_schema,node_statefulset,node_daemonset toneBlue
class node_service_identity,node_pvc,node_token_secret,node_configmap,node_network_policy,node_keypair_storage toneAmber
class node_agent_workload,node_kagent,node_kentik_api toneMint
class node_token_script,node_keypair_script,node_ci,node_helm_tests toneRose
```

## Components

### Chart inputs & rendering

- [Chart metadata](https://github.com/kentik/kagent-helm/blob/main/Chart.yaml): Helm chart · `Chart.yaml`
- [Chart values](https://github.com/kentik/kagent-helm/blob/main/values.yaml): Helm defaults · Selects deployment, persistence, access, and network options. · `values.yaml`
- [Values schema](https://github.com/kentik/kagent-helm/blob/main/contracts/values.schema.json): input contract · `contracts/values.schema.json`
- [StatefulSet template](https://github.com/kentik/kagent-helm/blob/main/templates/statefulset.yaml): conditional workload · Default pattern with stable ordinals and per-pod PVCs. · `templates/statefulset.yaml`
- [DaemonSet template](https://github.com/kentik/kagent-helm/blob/main/templates/daemonset.yaml): conditional workload · One node-local agent per node. · `templates/daemonset.yaml`

### Kubernetes resources

- [ServiceAccount & RBAC](https://github.com/kentik/kagent-helm/blob/main/templates/serviceaccount.yaml): Kubernetes access · ServiceAccount is normally created; RBAC is opt-in. · `templates/serviceaccount.yaml`
- [PersistentVolumeClaim](https://github.com/kentik/kagent-helm/blob/main/templates/pvc.yaml): persistent storage · `templates/pvc.yaml`
- [Provisioning token Secret](https://github.com/kentik/kagent-helm/blob/main/templates/secret-provisioning-token.yaml): Kubernetes Secret · Injects the registration token by secret reference. · `templates/secret-provisioning-token.yaml`
- [Advanced ConfigMap](https://github.com/kentik/kagent-helm/blob/main/templates/configmap.yaml): optional configuration · Workload environment values take precedence. · `templates/configmap.yaml`
- [NetworkPolicy](https://github.com/kentik/kagent-helm/blob/main/templates/networkpolicy.yaml): optional egress boundary · Requires a NetworkPolicy-enforcing CNI. · `templates/networkpolicy.yaml`
- **Durable keypair storage**: identity backend · Secret, PVC, hostPath, or emptyDir; secret keys are externally provisioned.

### Agent & external services

- **Rendered agent workload**: StatefulSet or DaemonSet · Runs the selected immutable workload pattern.
- **kentik/kagent container**: agent runtime · Uses durable ed25519 identity and runtime configuration.
- **Kentik gRPC API**: external service · grpc.api.kentik.com:443 registration and telemetry endpoint.

### Provisioning & validation

- [Token generator](https://github.com/kentik/kagent-helm/blob/main/generate-provisioning-token.sh): provisioning script · `generate-provisioning-token.sh`
- [Keypair secret generator](https://github.com/kentik/kagent-helm/blob/main/generate-secrets.sh): provisioning script · Generates per-replica PEM Secret manifests before StatefulSet scaling. · `generate-secrets.sh`
- [CI validation](https://github.com/kentik/kagent-helm/blob/main/.github/workflows/ci.yaml): chart verification · Validates rendered patterns and persistence/token choices. · `.github/workflows/ci.yaml`
- [Helm validation tests](https://github.com/kentik/kagent-helm/blob/main/tests/validation_test.yaml): test suite · `tests/validation_test.yaml`

## Connections

- Chart metadata → Chart values: packages with
- Values schema → Chart values: validates
- Chart values → StatefulSet template: selects default
- Chart values → DaemonSet template: selects node mode
- StatefulSet template → Rendered agent workload: renders
- DaemonSet template → Rendered agent workload: renders
- Rendered agent workload → kentik/kagent container: runs
- ServiceAccount & RBAC → Rendered agent workload: supplies identity/access
- PersistentVolumeClaim → Rendered agent workload: mounts when selected
- Durable keypair storage → Rendered agent workload: mounts identity
- Provisioning token Secret → Rendered agent workload: injects token
- Advanced ConfigMap → Rendered agent workload: adds optional settings
- NetworkPolicy → Rendered agent workload: constrains egress
- kentik/kagent container → Kentik gRPC API: registers/connects
- Token generator → Provisioning token Secret: generates token for
- Keypair secret generator → Durable keypair storage: provisions secret-backed keys
- CI validation → Helm validation tests: runs
- Helm validation tests → StatefulSet template: validates
- Helm validation tests → DaemonSet template: validates
