Skip to content

Improve Annotation Format #12226

Closed
Closed
@alexhersh

Description

@alexhersh

I am working on implementing network policy rules in Kubernetes annotations and am hitting a limitation in how Kubernetes parses dictionary values in the pod spec.

I would like to put nested lists within annotation values, but annotations are expected to be single "key": "value" string pairs. To get around this I am tokenizing my data as a single string and then marshaling it separately in my code, but the result is unreadable and not intuitive.

For example, I would like to format my pod config like:

"annotations": {
    "rule1": [
        {
            "labels": {
                "name": "pod1"
            }
        },
        {
            "protocol": "tcp"
        }
    ]
}

but my workaround looks like:

"annotations": {
    "rule1": "[{\"labels\": {\"name\": \"pod1\"}},{\"protocol\": \"tcp\"}]"
}

One line solutions are cool and all, but this design is not very easy to program or debug, nor is it suitable for larger annotations. I would much prefer to have more robust annotation support natively in the Kubernetes pod spec.

If you agree that this feature is worth implementing, I can go ahead and try to build it in myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiIndicates an issue on api area.area/extensibilitypriority/backlogHigher priority than priority/awaiting-more-evidence.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions