Target & TargetProfile

Configuring network device targets

Target

The Target resource represents a network device to collect telemetry from. The target definition is kept as simple as possible to remain automation and scale friendly.

Basic Configuration

apiVersion: operator.gnmic.dev/v1alpha1
kind: Target
metadata:
  name: router1
  labels:
    vendor: vendorA
    role: core
    site: dc1
spec:
  address: 10.0.0.1:57400
  profile: default-profile

Spec Fields

FieldTypeRequiredDescription
addressstringYesDevice address (host:port)
profilestringYesReference to TargetProfile

Using Labels

Labels are essential for pipeline selection. Any label can be used but some obvious ones include:

metadata:
  labels:
    vendor: vendorA    # Device vendor
    role: core         # Network role
    site: datacenter-1 # Physical location
    env: production    # Environment
    tier: critical     # Importance level

Pipelines can then select targets:

# Select all vendorA core routers in production
targetSelectors:
  - matchLabels:
      vendor: vendorA
      role: core
      env: production

TargetProfile

The TargetProfile resource defines shared connection settings for targets.

Basic Configuration

apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetProfile
metadata:
  name: default-profile
spec:
  credentialsRef: device-credentials
  tls: {}
  encoding: json_ietf
  timeout: 10s

Spec Fields

FieldTypeRequiredDescription
credentialsRefstringNoReference to credentials Secret
tls.serverNamestringNoTLS serverName override value
tls.maxVersionstringNoTLS Maximum version: 1.1, 1.2 or 1.3
tls.minVersionstringNoTLS Minimum version: 1.1, 1.2 or 1.3
tls.cipherSuites[]stringNoList of supported TLS cipher suites
timeoutdurationNogRPC timeout, defaults to 10s
retryTimerdurationNogNMI RPC retry timer, defaults to 2s
encodingstringNOgNMI encoding. Is overwritten by the subscription encoding
labelsmapNOA set of labels added to the device’s exported metrics
proxystringNOA socks5 proxy address used to reach the targets
gzipCompressionboolNOIf true, gzip is used to compress gNMI data on the wire
tcpKeepAlivedurationNOTCP keepalive duration
grpcKeepAlive.timedurationNOgRPC keep alive time (interval)
grpcKeepAlive.timeoutdurationNOgRPC keep alive timeout
grpcKeepAlive.permitWithoutStreamboolNOIf true gRPC keepalives are sent when there is no active stream

Credentials Secret

Create a Secret with device credentials:

kubectl create secret generic device-credentials \
  --from-literal=username=admin \
  --from-literal=password=secretpassword

Or with a token:

kubectl create secret generic device-credentials \
  --from-literal=token=eyJhbGciOiJIUzI1NiIs...

Reference it in the profile:

spec:
  credentialsRef: device-credentials

TLS Configuration

The TargetProfile controls connection-level TLS settings for gNMI connections. For client certificate authentication (mTLS), see Cluster Client TLS.

TLS Configuration Overview

┌─────────────────────────────────────────────────────────────────────┐
│                        TLS Configuration                            │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│   TargetProfile.tls          Cluster.clientTLS                      │
│   ─────────────────          ─────────────────                      │
│   • Enable/disable TLS       • Client certificate (tls-cert)        │
│   • TLS version settings     • Client private key (tls-key)         │
│   • Cipher suites            • CA bundle for server verification    │
│   • Server name override                                            │
│                                                                     │
│              Both combine to form the complete TLS config           │
└─────────────────────────────────────────────────────────────────────┘

When tls is not specified, connections are unencrypted:

apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetProfile
metadata:
  name: insecure-profile
spec:
  credentialsRef: device-credentials

TLS without Server Certificate Verification

Enable TLS encryption but skip verification of the device’s certificate. This is common when devices use self-signed certificates:

apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetProfile
metadata:
  name: tls-skip-verify-profile
spec:
  credentialsRef: device-credentials
  tls: {}  # Enables TLS with skip-verify

Note: At the cluster level, a clientTLS.issuerRef can still be set - the client will send its certificates during the TLS handshake but it will not verify the server certificates as long as the clientTLS.bundleRef is not set.

This results in:

  • ✅ Encrypted connection
  • ❌ No verification of device identity (vulnerable to MITM)

Mutual TLS (mTLS) with Client Certificates

For full mTLS where gNMIc authenticates to devices using client certificates, configure clientTLS at the Cluster level:

# 1. TargetProfile - connection settings
apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetProfile
metadata:
  name: mtls-profile
spec:
  credentialsRef: device-credentials
  tls:
    minVersion: "1.2"
---
# 2. Cluster - client certificates for mTLS
apiVersion: operator.gnmic.dev/v1alpha1
kind: Cluster
metadata:
  name: secure-cluster
spec:
  replicas: 3
  image: ghcr.io/openconfig/gnmic:latest
  clientTLS:
    issuerRef: gnmic-client-ca-issuer  # cert-manager Issuer
    bundleRef: target-ca-bundle        # CA to verify device certs

This results in:

  • ✅ Encrypted connection
  • ✅ gNMIc authenticates to devices with client certificate
  • ✅ Device server certificates verified against CA bundle

See Cluster Client TLS for complete setup instructions.

TLS with Custom Settings

Configure specific TLS parameters:

apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetProfile
metadata:
  name: custom-tls-profile
spec:
  credentialsRef: device-credentials
  tls:
    serverName: router1.example.com   # Override SNI
    minVersion: "1.2"                 # Minimum TLS 1.2
    maxVersion: "1.3"                 # Maximum TLS 1.3
    cipherSuites:                     # Restrict cipher suites
      - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
      - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

Note: For serverName setting to apply the cluster spec must include a trustBundle under spec.clientTLS.trustBundle

TLS Configuration Summary

ScenarioTargetProfile ConfigCluster Config
No TLStls not set-
TLS (skip verify)tls: {}-
TLS + client verifytls: {}clientTLS.issuerRef only
TLS + server verifytls: {}clientTLS.bundleRef only
Full mTLStls: {}clientTLS.issuerRef + clientTLS.bundleRef

Multiple Profiles

Use different profiles for different device types:

# Profile for vendorA devices
apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetProfile
metadata:
  name: vendorA-profile
spec:
  credentialsRef: vendorA-credentials
  encoding: json_ietf
  timeout: 10s
---
# Profile for vendorB devices
apiVersion: operator.gnmic.dev/v1alpha1
kind: TargetProfile
metadata:
  name: vendorB-profile
spec:
  credentialsRef: vendorB-credentials
  tls: {}
  encoding: json_ietf
  timeout: 15s

Then reference the appropriate profile in each target:

apiVersion: operator.gnmic.dev/v1alpha1
kind: Target
metadata:
  name: vendorA-router1
spec:
  address: 10.0.0.1:57400
  profile: vendorA-profile
---
apiVersion: operator.gnmic.dev/v1alpha1
kind: Target
metadata:
  name: vendorB-router1
spec:
  address: 10.0.0.2:57400
  profile: vendorB-profile