cilium

package
v0.0.1-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 28 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cilium projects Cilium CNI state onto Kubernetes Pods and Nodes and normalizes Hubble flows into telemetry events. It does not model Cilium service mesh, Envoy configuration, or L7 policy.

Inputs

The plugin opens no Kubernetes watch. It declares Pods and Nodes as required and CiliumNetworkPolicy, CiliumClusterwideNetworkPolicy, CiliumEndpoint, and CiliumNode as optional capabilities, consuming them through the Kubernetes plugin's per-GVR and resource-coverage collections.

Identity and graph output

Cilium objects keep their Kubernetes identities (kubernetes.io/v1 Object, cluster authority, apiVersion/kind/UID key). CiliumEndpoint and CiliumNode enrich the Pod and Node with the same namespace and name, because Cilium references them by name, instead of creating competing identities; missing or ambiguous matches produce diagnostics and no facet. The "cni-semantics" contribution emits governed-by from selected Pods to Cilium policies and cilium-cni-policy and cilium-cni facets. Policies with L7 rules contribute no rule counts or relationships. Evidence IDs match the Kubernetes plugin's upsert event IDs.

Publication waits for both the object and coverage collections to reach a coherent generation. Unexpected subscription closure publishes a degraded replacement from the last coherent cache and returns an error.

Telemetry

The unexported normalizeHubbleFlow maps one Hubble flow to a telemetry event with the original timestamp, a provider or content-derived retry-stable event ID, and Pod UID or network-destination endpoint claims, and ingestHubbleFlow submits it to the shared pipeline, which commits raw events before any graph rollup. No Hubble Relay transport or resumable cursor is included yet, so nothing calls them outside tests.

The package also implements the cilium-network-policy/v1 remediation action, which declares ingress isolation for a Pod with a CiliumNetworkPolicy.

See https://agent-shield.dev/docs/plugins/cilium/.

Index

Constants

View Source
const CollectionProjection = "cilium/projection"

CollectionProjection signals readiness of the Cilium semantic contribution; its graph assertions are published separately through ReplaceContribution.

View Source
const PluginID = "cilium"

PluginID is the plugin and contribution owner ID.

Variables

This section is empty.

Functions

func Descriptor

func Descriptor() discovery.Descriptor

Descriptor declares the consumed Kubernetes collections and the projection readiness collection. Cilium introduces no identity scheme of its own.

func Project

func Project(clusterID, sourceID string, objects []*unstructured.Unstructured) (graph.Input, error)

Project projects bare objects, deriving evidence IDs from their identity and resource version. It exists for tests and offline evaluation; the plugin uses ProjectObserved with collection event IDs.

Types

type CLIConfig

type CLIConfig struct {
	ClusterID string
	SourceID  string
}

CLIConfig contains Cilium-owned runtime options.

func (*CLIConfig) RegisterFlags

func (config *CLIConfig) RegisterFlags(flags *pflag.FlagSet) error

RegisterFlags registers Cilium flags in the cilium-* namespace.

type Config

type Config struct {
	ClusterID string
	SourceID  string
	Actions   kubernetesplugin.WriteTransport
}

Config identifies the cluster and source shared with the Kubernetes plugin. Actions enables the remediation action; nil leaves it unadvertised.

type Diagnostic

type Diagnostic struct {
	Code     string
	Resource string
}

Diagnostic records an unresolved or unsupported provider object. It is not a graph fact and never implies policy absence.

type ObservedObject

type ObservedObject = coherentcache.Object

ObservedObject is one cached Kubernetes observation with the event ID used as assertion evidence.

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin is the Cilium semantic projection and remediation plugin.

func New

func New(config Config) (*Plugin, error)

New validates config and prepares typed clients for the shared Kubernetes collections.

func (*Plugin) Descriptor

func (plugin *Plugin) Descriptor() discovery.Descriptor

Descriptor implements discovery.Plugin; it returns the same value as the package-level Descriptor, which main also uses before construction.

func (*Plugin) Execute

Execute re-derives the plan, requires the provider state recorded by Prepare to be unchanged, labels the Pod, rechecks for overlapping policy, and creates the policy. If a step after labeling fails, the label is rolled back.

func (*Plugin) KubernetesResources

func (plugin *Plugin) KubernetesResources() []kubernetesplugin.ResourceRequirement

KubernetesResources lists the GVRs the Kubernetes plugin must watch for this plugin.

func (*Plugin) Plan

func (p *Plugin) Plan(ctx context.Context, proposal remediation.Proposal, actionID string) (remediation.Plan, error)

Plan resolves the proposal's target Pod and derives the desired target label and CiliumNetworkPolicy, rejecting targets already selected by an overlapping policy. It writes nothing.

func (*Plugin) Prepare

Prepare submits the desired Pod label and policy as server-side dry runs so admission can reject them before any change, and records the admitted state.

func (*Plugin) RemediationDescriptor

func (p *Plugin) RemediationDescriptor() remediation.Descriptor

RemediationDescriptor advertises the cilium-network-policy/v1 ingress isolation action for Kubernetes Pods when an action transport is configured.

func (*Plugin) Run

func (plugin *Plugin) Run(ctx context.Context, runtime discovery.Runtime) error

Run consumes the Kubernetes collections and replaces the cni-semantics contribution whenever both object and coverage collections reach a new coherent generation.

func (*Plugin) SourceID

func (plugin *Plugin) SourceID() string

SourceID returns the Kubernetes source ID this plugin projects for.

func (*Plugin) Verify

Verify reports satisfied only while the live Pod label and policy still match the digests recorded at execution. It checks declared configuration, not dataplane enforcement.

type ProjectionContext

type ProjectionContext struct {
	ClusterID string
	SourceID  string
}

ProjectionContext scopes projection to one cluster and source.

type ProjectionResult

type ProjectionResult struct {
	Input       graph.Input
	Diagnostics []Diagnostic
}

ProjectionResult is the complete cni-semantics contribution input plus diagnostics for endpoints and nodes that could not be matched.

func ProjectObserved

func ProjectObserved(scope ProjectionContext, observations []ObservedObject) (ProjectionResult, error)

ProjectObserved deterministically projects one coherent snapshot. The result is independent of observation order.

Directories

Path Synopsis
Package api holds typed subsets of the cilium.io/v2 resources the Cilium projector reads.
Package api holds typed subsets of the cilium.io/v2 resources the Cilium projector reads.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL