plugin

package module
v0.0.0-...-6afa73d Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 17 Imported by: 0

README

CoreSMD CoreDNS Plugin

The CoreSMD CoreDNS plugin provides dynamic DNS resolution for OpenCHAMI clusters by integrating with the State Management Database (SMD). This plugin enables automatic DNS record generation for compute nodes, BMCs, and other components managed by SMD.

Features

  • Dynamic DNS Records: Automatic A, PTR, and CNAME record generation
  • SMD Integration: Real-time data from State Management Database
  • Multiple Record Types: Support for forward and reverse DNS lookups
  • Prometheus Metrics: Built-in monitoring and metrics collection
  • Readiness Reporting: Health checks and readiness endpoints
  • Cache Integration: Shared cache with CoreDHCP plugins

Installation

The CoreSMD CoreDNS plugin is included in the CoreSMD binary. No additional installation is required.

Configuration

Basic Configuration
. {
    coresmd {
        smd_url https://smd.cluster.local
        ca_cert /path/to/ca.crt
        cache_duration 30s
    }
    prometheus 0.0.0.0:9153
    forward . 8.8.8.8
}
Advanced Configuration with Custom Zones
. {
    coresmd {
        smd_url https://smd.cluster.local
        ca_cert /path/to/ca.crt
        cache_duration 30s
        zone cluster.local {
            nodes nid{04d}
        }
        zone test.local {
            nodes node{04d}
        }
    }
    prometheus 0.0.0.0:9153
    forward . 8.8.8.8
}
Configuration Options
Option Type Default Description
smd_url string required SMD API endpoint URL
ca_cert string "" Path to CA certificate for SMD TLS
cache_duration duration "30s" Cache refresh interval
zone block auto Zone configuration block
Zone Configuration

Each zone block supports the following options:

Option Type Description
nodes string Node hostname pattern (e.g., "nid{04d}")

DNS Record Types

A Records

Forward DNS resolution for nodes and BMCs:

nid0001.cluster.local.    IN A    192.168.1.10
x3000c1s1b1.cluster.local. IN A    192.168.1.100
PTR Records

Reverse DNS resolution:

10.1.168.192.in-addr.arpa. IN PTR nid0001.cluster.local.
100.1.168.192.in-addr.arpa. IN PTR x3000c1s1b1.cluster.local.
CNAME Records

Alias support (when configured):

alias.cluster.local. IN CNAME target.cluster.local.

Monitoring

Prometheus Metrics

The plugin exposes the following Prometheus metrics:

  • coredns_coresmd_requests_total - Total DNS requests by type
  • coredns_coresmd_request_duration_seconds - Request duration histogram
  • coredns_coresmd_cache_hits_total - Cache hit count by record type
  • coredns_coresmd_cache_misses_total - Cache miss count by record type
  • coredns_coresmd_smd_cache_age_seconds - SMD cache age
  • coredns_coresmd_smd_cache_size - SMD cache entry count
Health Checks

The plugin implements readiness reporting:

  • Ready: Returns true when SMD cache is populated and fresh
  • Health: Returns true when the plugin is healthy

Examples

Basic DNS Server
# Corefile
. {
    coresmd {
        smd_url https://smd.cluster.local
        cache_duration 30s
    }
    prometheus 0.0.0.0:9153
    forward . 8.8.8.8
}
Multi-Zone Configuration
# Corefile
. {
    coresmd {
        smd_url https://smd.cluster.local
        ca_cert /etc/ssl/certs/smd-ca.crt
        cache_duration 60s
        zone cluster.local {
            nodes nid{04d}
        }
        zone mgmt.local {
            nodes mgmt{04d}
        }
    }
    prometheus 0.0.0.0:9153
    forward . 8.8.8.8
}
Docker Deployment
# docker-compose.yml
version: '3.8'
services:
  coredns:
    image: coresmd/coredns:latest
    ports:
      - "53:53/udp"
      - "53:53/tcp"
      - "9153:9153"
    volumes:
      - ./Corefile:/etc/coredns/Corefile
      - ./certs:/etc/ssl/certs
    command: ["-conf", "/etc/coredns/Corefile"]
Kubernetes Deployment
# coredns-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: coredns
  namespace: kube-system
spec:
  replicas: 2
  selector:
    matchLabels:
      app: coredns
  template:
    metadata:
      labels:
        app: coredns
    spec:
      containers:
      - name: coredns
        image: coresmd/coredns:latest
        ports:
        - containerPort: 53
          name: dns
          protocol: UDP
        - containerPort: 53
          name: dns-tcp
          protocol: TCP
        - containerPort: 9153
          name: metrics
          protocol: TCP
        volumeMounts:
        - name: config-volume
          mountPath: /etc/coredns
        - name: certs-volume
          mountPath: /etc/ssl/certs
        args:
        - "-conf"
        - "/etc/coredns/Corefile"
      volumes:
      - name: config-volume
        configMap:
          name: coredns-config
      - name: certs-volume
        secret:
          secretName: smd-certs

Troubleshooting

Common Issues
  1. SMD Connection Failed

    • Verify SMD URL is accessible
    • Check CA certificate path and validity
    • Ensure network connectivity
  2. No DNS Records Generated

    • Check SMD cache is populated
    • Verify zone configuration matches SMD data
    • Review plugin logs for errors
  3. Cache Not Updating

    • Verify cache duration setting
    • Check SMD API endpoint health
    • Review cache refresh logs
Debug Mode

Enable debug logging:

. {
    coresmd {
        smd_url https://smd.cluster.local
        cache_duration 30s
    }
    log
    prometheus 0.0.0.0:9153
}
Health Check

Check plugin health:

# Check readiness
curl http://localhost:9153/ready

# Check metrics
curl http://localhost:9153/metrics | grep coresmd

Integration with CoreDHCP

The CoreDNS plugin shares the same SMD cache infrastructure as the CoreDHCP plugins, ensuring consistency between DHCP leases and DNS records.

Version Information

The plugin reports version information at startup:

INFO[0000] initializing coresmd/coredns v1.0.0 (clean), built 2024-01-01T00:00:00Z

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RequestCount is the total number of DNS requests processed by the coresmd plugin
	RequestCount = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: "coresmd",
		Name:      "requests_total",
		Help:      "Counter of DNS requests made to the coresmd plugin.",
	}, []string{"server", "zone", "type"})

	// RequestDuration is the time taken to process DNS requests
	RequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: plugin.Namespace,
		Subsystem: "coresmd",
		Name:      "request_duration_seconds",
		Buckets:   plugin.TimeBuckets,
		Help:      "Histogram of the time (in seconds) each request took.",
	}, []string{"server", "zone"})

	// CacheHits is the number of successful cache lookups
	CacheHits = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: "coresmd",
		Name:      "cache_hits_total",
		Help:      "Counter of successful cache lookups in the coresmd plugin.",
	}, []string{"server", "zone", "record_type"})

	// CacheMisses is the number of failed cache lookups
	CacheMisses = promauto.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: "coresmd",
		Name:      "cache_misses_total",
		Help:      "Counter of failed cache lookups in the coresmd plugin.",
	}, []string{"server", "zone", "record_type"})

	// SMDCacheAge is the age of the SMD cache in seconds
	SMDCacheAge = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: plugin.Namespace,
		Subsystem: "coresmd",
		Name:      "smd_cache_age_seconds",
		Help:      "Age of the SMD cache in seconds.",
	}, []string{"server"})

	// SMDCacheSize is the number of entries in the SMD cache
	SMDCacheSize = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: plugin.Namespace,
		Subsystem: "coresmd",
		Name:      "smd_cache_size",
		Help:      "Number of entries in the SMD cache.",
	}, []string{"server", "type"})
)

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	Next plugin.Handler
	// contains filtered or unexported fields
}

Plugin represents the coresmd plugin

func (Plugin) Health

func (p Plugin) Health() bool

func (Plugin) Name

func (p Plugin) Name() string

Name returns the plugin name

func (Plugin) OnShutdown

func (p Plugin) OnShutdown() error

func (*Plugin) OnStartup

func (p *Plugin) OnStartup() error

OnStartup is called when the plugin starts up

func (Plugin) OnStartupComplete

func (p Plugin) OnStartupComplete() error

func (Plugin) Ready

func (p Plugin) Ready() bool

Ready checks if the plugin's cache is initialized, has been updated at least once (i.e., LastUpdated is non-zero), and is not older than 5 minutes. It implements the ready.Readiness interface (Ready() bool) for https://coredns.io/plugins/ready/. Returns true if the cache is ready, otherwise false.

func (Plugin) ServeDNS

func (p Plugin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS handles DNS requests for the coresmd plugin

type Zone

type Zone struct {
	Name        string // Zone name (e.g., "cluster.local")
	NodePattern string // Pattern for node records (e.g., "nid{04d}.cluster.local")
}

Zone represents a DNS zone configuration

type ZoneManager

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

ZoneManager handles zone operations and record lookups

func NewZoneManager

func NewZoneManager(zones []Zone) *ZoneManager

NewZoneManager creates a new zone manager

func (*ZoneManager) FindZone

func (zm *ZoneManager) FindZone(domain string) *Zone

FindZone finds the appropriate zone for a given domain name

Jump to

Keyboard shortcuts

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