HTTP Provider
HTTP TargetSource Discovery Provider
The TargetSource resource enables dynamic discovery of network devices from external sources. The operator automatically creates, updates, and deletes Target resources based on discovered devices.
apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetSource
metadata:
name: targetsource-1
spec:
provider:
# see Discovery Providers section
targetPort: 57400
targetProfile: default
targetLabels:
source: inventory
| Field | Type | Required | Description |
|---|---|---|---|
provider | object | Yes | Provider-specific discovery configuration. Exactly one provider must be configured |
targetPort | int32 | No | Default port used if the discovered target does not provide a port. |
targetProfile | string | Yes | Reference to TargetProfile applied to all targets |
targetLabels | map[string]string | No | Labels added to all discovered targets |
TargetSource supports the following discovery providers:
| Provider | Description |
|---|---|
http | Discover targets from an HTTP JSON endpoint. Configuration |
Each generated Target receives an ownership label identifying the originating TargetSource:
operator.gnmic.dev/targetsource: targetsource-1
This label is automatically managed by the operator and is used to:
TargetSourceThe operator.gnmic.dev/targetsource label is reserved and always takes precedence over any provider-supplied labels.
Additional labels can be applied to all generated targets using spec.targetLabels:
apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetSource
metadata:
name: targetsource-1
spec:
provider:
http:
url: http://targetsource-1:8080/targets
targetLabels:
datacenter: dc-a
environment: production
All targets discovered from this source will have:
datacenter: dc-aenvironment: productionThis enables Pipelines to select targets using label selectors.
Discovery providers may return additional labels for each target. These labels are applied directly to the generated Target resource.
The gnmic_operator_ label prefix is reserved for operator-specific behavior. Labels using this prefix are interpreted by the operator and are not applied directly to the generated Target resource.
Supported operator labels:
| Label | Description |
|---|---|
gnmic_operator_target_profile | Overrides the TargetProfile configured in the TargetSource |
If the same label key is defined in multiple places, labels are applied in the following order (highest precedence first):
TargetSource ownership label (operator.gnmic.dev/targetsource)TargetSource.spec.targetLabelsThe TargetSource status shows discovery state:
status:
status: Synced
targetsCount: 42
lastSync: "2024-01-15T10:30:00Z"
| Field | Description |
|---|---|
status | Current sync status (Synced, Error, Pending) |
targetsCount | Number of targets discovered |
lastSync | Timestamp of last successful sync |
When a TargetSource discovers a new device:
Target resource is createdTargetProfile referenced in spec.targetProfile is assignedspec.targetLabels are appliedTargetSource is set as the owner referenceOn each discovery cycle, existing Target resources are reconciled with the latest discovered state:
Target resource is updated and overwrittenManual changes to
Targetresources managed by aTargetSourceare overwritten on every reconciliation cycle.
When a device is no longer returned by the discovery provider:
Target resource is deletedWhen a TargetSource is deleted:
Target resources owned by it are deleted via owner referencesHTTP TargetSource Discovery Provider