Skip to content

extraServerBlocks feature broken after refactoring - location mismatch between schema and template #2120

Description

@angelbarrera92

Problem

The extraServerBlocks feature is not working due to a refactoring issue. The feature was originally added in PR #1709 (commit 518a2ce) as a global setting at k8gb.coredns.extraServerBlocks, but was later moved to be per-zone in the schema (k8gb.dnsZones[].extraServerBlocks) without updating the template accordingly.

Current Behavior

Original Implementation (PR #1709 - Sept 2024)

The feature was added as a global setting:

  • Location: k8gb.coredns.extraServerBlocks (root level)
  • Schema: Defined in k8gbCoredns object
  • Template: Accessed as .Values.k8gb.coredns.extraServerBlocks
  • Use case: Add glue records for other clusters in k8gb's CoreDNS for cluster discovery

Current State (Broken)

After refactoring to support multiple DNS zones, the location changed:

Template (chart/k8gb/templates/coredns/cm.yaml lines 38-40):

{{- end }}
    {{- with .extraServerBlocks -}}
    {{- tpl . $ | nindent 4 }}
    {{- end }}
{{- end }}

This is outside the {{- range .Values.k8gb.dnsZones }} loop and tries to access .extraServerBlocks (which would be .Values.extraServerBlocks - doesn't exist).

Schema (values.schema.json lines 532-564):
Defines extraServerBlocks as a property inside the k8gbDnsZone definition:

"k8gbDnsZone": {
    "type": "object",
    "properties": {
        "loadBalancedZone": {...},
        "parentZone": {...},
        "dnsZoneNegTTL": {...},
        "extraPlugins": {...},
        "extraServerBlocks": {
            "type": "string"
        }
    },
    ...
}

This causes:

  1. Schema validation errors when trying to define it at root level: additional properties 'extraServerBlocks' not allowed
  2. Silent failure when defined correctly inside DNS zones (the template can't access it from the wrong context)

Design Analysis: Per-Zone vs Global?

After analyzing the original PR #1709, the intended design was clearly global:

  • The use case was to add glue records for cluster discovery
  • Extra server blocks define different DNS zones not managed by k8gb
  • Having it per-zone would cause duplicate server blocks with multiple k8gb zones
  • The original configuration was at k8gb.coredns.extraServerBlocks (global level)

During the refactoring to support multiple DNS zones (dnsZonednsZones[]), the setting was mistakenly moved to per-zone in the schema without updating the template.

Steps to Reproduce

  1. Add extraServerBlocks to a DNS zone in values.yaml:

    k8gb:
      dnsZones:
        - parentZone: "example.com"
          loadBalancedZone: "cloud.example.com"
          extraServerBlocks: |
            test.example.com:5353 {
                forward . 8.8.8.8
            }
  2. Run helm template .

  3. Observe that the extraServerBlocks content is not included in the rendered Corefile

Additional Context

Historical Timeline

  1. PR Allow configuration of extra coredns server blocks #1709 (Sept 2024): Feature added as k8gb.coredns.extraServerBlocks (global)
  2. Later refactoring: DNS zones structure changed from single dnsZone to array dnsZones[]
  3. Migration issue: extraServerBlocks was moved to per-zone in schema but template wasn't updated
  4. Current state: Broken - neither global nor per-zone works

Original Use Case (PR #1709)

"The goal of this PR is to allow configuration of the glue records of the other clusters in k8gb's coreDNS... it allows k8gb to do cluster discovery without depending on any infrastructure outside of the cluster."

This suggests global intent - one extra server block for glue records that applies to all k8gb zones.

Current Documentation Issues

  • The README.md documents extraServerBlocks as being inside the dnsZones array (line 95)
  • The default values.yaml shows it with a test value but provides no clear example
  • No clear guidance on whether it should be global or per-zone

Workaround

Currently there is no workaround - the feature is broken because:

  • Cannot define at root level (schema validation fails)
  • Cannot use per-zone (template doesn't access it)

Users must wait for this fix to use extraServerBlocks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Planned

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions