Skip to content

Can't add service annotation #35

Closed

Description

@dannymcerlean1

Hi, really nice project! Reporting a small issue I found when trying to add annotations/labels to a service.

Bug Report

When creating a Server object, I'm unable to add annotations or labels to the associated k8 service.

1. Minimal reproduce step (Required)

import manifests
import konfig.models.kube.frontend
import konfig.models.kube.frontend.container
import konfig.models.kube.frontend.service

import konfig.models.kube.frontend
import konfig.models.kube.frontend.container
import konfig.models.kube.frontend.service

temporalCodecServer: frontend.Server {
    name = "test"
    namespace = "test"
    needNamespace = False
    image = "TEST"
    mainContainer = container.Main {
        env.GET_HOSTS_FROM: {
            value = "dns"
        }
        ports = [
            {
                containerPort = 8080
            }
        ]
    }
    services = [
        service.Service {
           name = "serviceToAnnotate"
            annotations = {
                "key" = "value"
            }
        }
    ]
}

2. What did you expect to see? (Required)

something like this:

apiVersion: v1
kind: Service
metadata:
  name: TEST
  namespace: test
  annotations:
    key: "value
spec:
  ports:
    - port: 8080
  selector:
    app.kubernetes.io/name: sampleapp

3. What did you see instead (Required)

Above service without annotations

4. What is your KCL components version? (Required)

My kcl.mod file looks like this:

[package]
name = "test"
version = "0.0.1"

[dependencies]
konfig = { git = "https://github.com/kcl-lang/konfig" }

[profile]
entries = [
    "main.k",
    "${konfig:KCL_MOD}/models/kube/render/render.k"
]

I am using the latest version (0.10.0)

Above example is for annotations, I see the same behavior for labels.

Activity

  1. added
    bug
    on Dec 1, 2025
  2. Peefy commented on Aug 30, 2026

    @Peefy
    Contributor

    Closing — this was fixed by #36 (commit 29910fc — fix(render, backend, mixins): align imports and work around kcl 0.12.x evaluator quirk). The root cause was a kcl 0.12.x evaluator quirk where reads of config.X inside a dict literal that also invoked MetadataBuilder(config) | {...} resolved to Undefined, silently dropping annotations and labels.

    I just reproduced your exact example (frontend.Server with annotations = { "key" = "value" } on a nested service.Service) against the merged main and the rendered YAML correctly includes:

    apiVersion: v1
    kind: Service
    metadata:
      annotations:
        key: value
      labels:
        app: demo
      name: serviceToAnnotate
      namespace: sampleappns-prod
    spec:
      selector:
        app.kubernetes.io/name: sampleapp

    Thank you for the clear reproducer — it was essential for diagnosing this one. Closing in favor of the already-landed #36.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions