Staging repository just for `constants`

136 views
Skip to first unread message

Davanum Srinivas

unread,
Apr 23, 2026, 7:09:12 AM (10 days ago) Apr 23
to sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Hi sig-arch / sig-api-machinery,

I would like to propose a small new staging module, k8s.io/constants, with a working implementation in PR #135896.

Well-known Kubernetes constants are scattered across apimachinery/pkg/util/validation, apimachinery/pkg/api/validate/content, apimachinery/pkg/apis/meta/v1/validation, and a dozen well_known_*.go files under api/core/v1, api/networking, api/discovery, cloud-provider/api, and kubelet/pkg/apis. 

Concretely, k8s.io/api/resource/v1 pulls in the entirety of util/validation — regex engine, error aggregation, the whole surface — for a single integer (issue #127889). External consumers pay the same tax whenever they need a well-known label key or DNS length limit.

The proposal is a zero-dependency staging module at k8s.io/constants with five subpackages.

- rfc/ — length constants for Kubernetes name-like fields (docs describe the Kubernetes grammars, not strict RFC compliance; aligned with KEP-5311 and kube-openapi#384).
- limits/ — LabelValueMaxLength, LabelKeyMaxLength, FieldManagerMaxLength.
- labels/, annotations/, taints/ — well-known keys. Identifiers drop the package-name prefix (labels.Hostname, not labels.LabelHostname).

The PR should be hopefully small, non-behavioural, and non-breaking. I'll add this to an upcoming sig-arch meeting agenda, if that works!

thanks,
Dims

--
Davanum Srinivas :: https://twitter.com/dims

Ricardo Pchevuzinske Katz

unread,
Apr 23, 2026, 8:39:06 AM (10 days ago) Apr 23
to Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
I am a +1 on this. As someone constantly trying to find all of the well known keys, and all of the definitions of RFCs and limits (I was just doing it yesterday) I think this will be a huge gain with minimal effort.

Thanks Dims!

--
You received this message because you are subscribed to the Google Groups "sig-architecture" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sig-architectu...@kubernetes.io.
To view this discussion visit https://groups.google.com/a/kubernetes.io/d/msgid/sig-architecture/CANw6fcFAi%3D0O36iicjOTxb2cRVL4T9qikBxFmfvoNHj-v3X9BA%40mail.gmail.com.

Benjamin Elder

unread,
Apr 23, 2026, 12:08:01 PM (10 days ago) Apr 23
to Ricardo Pchevuzinske Katz, Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
I +1 the question in the PR if this should be an actual repo instead of a staging repo, so it's easier to depend on.

I think staging only makes sense if we expect to modify these frequently in lockstep with the main repo.

Otherwise +1 to the concept to move these to a dedicated zero-dependency repo.

Davanum Srinivas

unread,
Apr 23, 2026, 12:18:17 PM (10 days ago) Apr 23
to Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Ben,

I want to see over time how we use it. if we see for like 3 consecutive releases we don't end up updating this repo, we would then just cut the cord and use the staged repo on its own. (for example).

(Don't want to decide now basically)

thanks,
Dims

Benjamin Elder

unread,
Apr 23, 2026, 12:24:01 PM (10 days ago) Apr 23
to Davanum Srinivas, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Have we ever in-place converted a staging repo?

I think we should decide now, because it impacts the versioning scheme.

Staging repo auto-version-tags won't make much sense to continue if we try to cut the cord.

We could abandon and come up with a new name, but that seems bad.

Davanum Srinivas

unread,
Apr 23, 2026, 12:26:48 PM (10 days ago) Apr 23
to Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Nope. we haven't. this would be the first time. we talked about CRI repo for sure, but no.

Joe Betz

unread,
Apr 23, 2026, 12:27:03 PM (10 days ago) Apr 23
to Benjamin Elder, Ricardo Pchevuzinske Katz, Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
+1

It sounds like all the constants migrating to this model will be stable API-related constants? My only high level thought is that we have a LOT of constants in the codebase that don't need to be migrated to this module, so having clear guidelines for what belongs in this module will be valuable.

David Eads

unread,
Apr 23, 2026, 12:57:44 PM (10 days ago) Apr 23
to Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Why have a separate constants repository instead of having constants related to our API defined in k8s.io/api?

DE2


To unsubscribe from this group and stop receiving emails from it, send an email to sig-api-machin...@kubernetes.io.

Davanum Srinivas

unread,
Apr 23, 2026, 1:27:02 PM (10 days ago) Apr 23
to David Eads, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io

David Eads

unread,
Apr 23, 2026, 1:49:45 PM (10 days ago) Apr 23
to Davanum Srinivas, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
But why would someone who doesn't use k8s.io/api use a constant like the one linked for kube API validation?  And why would we want to provide constants that aren't related to our API?

DE2


Davanum Srinivas

unread,
Apr 23, 2026, 1:53:35 PM (10 days ago) Apr 23
to David Eads, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
David,

I would love it if you could please poke at it and come up with alternatives :) 

thanks,
Dims

Tim Hockin

unread,
Apr 23, 2026, 2:42:26 PM (10 days ago) Apr 23
to Davanum Srinivas, David Eads, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
In theory someone might want the constants in a controller or client which only uses custom resources, making the k8s.io/api dep not necessary?

Practically, there might be value is using those same constants in other libs like k8s.io/utils/net using the same values for protocols or IPFamilies but that is a weak argument.

David Eads

unread,
Apr 23, 2026, 2:59:12 PM (10 days ago) Apr 23
to Tim Hockin, Davanum Srinivas, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
 In theory someone might want the constants in a controller or client which only uses custom resources, making the k8s.io/api dep not necessary?
That person would be fine using k8s.io/apimachinery where the current example lives.

DE2

Tim Hockin

unread,
Apr 23, 2026, 3:01:20 PM (10 days ago) Apr 23
to David Eads, Davanum Srinivas, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Personally, I kind of feel like metav1 and friends should ALSO live in k8s.io/api but that's a different discussion :)

David Eads

unread,
Apr 24, 2026, 11:51:50 AM (9 days ago) Apr 24
to Tim Hockin, Davanum Srinivas, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
So from the original list

- rfc/ — length constants for Kubernetes name-like fields (docs describe the Kubernetes grammars, not strict RFC compliance; aligned with KEP-5311 and kube-openapi#384).
- limits/ — LabelValueMaxLength, LabelKeyMaxLength, FieldManagerMaxLength.
- labels/, annotations/, taints/ — well-known keys. Identifiers drop the package-name prefix (labels.Hostname, not labels.LabelHostname).

limits, labels, annotations, and taints are all tightly associated with our k8s.io/api.  Anyone using them with our API, already depends on k8s.io/api, so they could live there.  Anyone using them with just CRDs, already depends on k8s.io/apimachinery, so that dep chain doesn't really get notably deeper.  Is anyone using them without our API and without CRDs?  If so, what are they doing with them?

rfc constants seem like an odd thing other projects to rely on kube for if they aren't working with our API or CRDs.

I may have missed the example in the messages, but do we have a concrete example of the project that wants to rely on these kube-API associated details but does not want to rely on kube API and apimachinery libraries?

DE2

Davanum Srinivas

unread,
Apr 24, 2026, 12:06:06 PM (9 days ago) Apr 24
to David Eads, Tim Hockin, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io

David Eads

unread,
Apr 24, 2026, 2:05:59 PM (9 days ago) Apr 24
to Davanum Srinivas, Tim Hockin, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Given the scope of the proposed change, I'm not seeing the value in moving a few constants before the far larger change is agreed.  I'm in favor of a client and API that allows co-existence of multiple versions without conflict where the version of the client is tied to client behavior not API version.  At first blush, I'd create a brand new client project and possibly a brand new (or generated?) API than adapt what we have.

That idea is an interesting one, but a constants repo is not what is holding that back.

DE2

Davanum Srinivas

unread,
Apr 24, 2026, 2:40:05 PM (9 days ago) Apr 24
to David Eads, Tim Hockin, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
I was afraid you were going to say that when i posted that issue url :) FWIW, i think that's one example and we should not be over indexing on just that one. we can talk more in sig-arch call.

Patrick Ohly

unread,
Apr 24, 2026, 4:07:10 PM (9 days ago) Apr 24
to David Eads, Davanum Srinivas, Tim Hockin, Joe Betz, Benjamin Elder, Ricardo Pchevuzinske Katz, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
"'David Eads' via sig-architecture" <sig-arch...@kubernetes.io>
writes:

> Given the scope of the proposed change, I'm not seeing the value in moving
> a few constants before the far larger change is agreed.

I'm with David here. As I said in
https://github.com/kubernetes/kubernetes/issues/127888#issuecomment-2395538443,
doing just one small step without knowing what the next ones are doesn't
really help us - it creates work and churn and might ultimately be
futile.

> I'm in favor of a
> client and API that allows co-existence of multiple versions without
> conflict where the version of the client is tied to client behavior not API
> version. At first blush, I'd create a brand new client project and
> possibly a brand new (or generated?) API than adapt what we have.

While interesting, I'm wary about how much effort that'll be and the
lack of adoption. If it's completely incompatible with the current
client-go, then all of the existing code will continue to use client-go.

I prefer to investigate splitting up client-go into different modules,
with the exact same import paths and package APIs. That's expected to be
completely transparent to consumers, as discussed in the issue. Tackle
the hard problems first, not the simple ones!

Once we have that, then we may be able to identify modules which really
benefit from severing the apimachinery dependency while still being
useful for apps on their own.

--
Best Regards

Patrick Ohly
Cloud Software Architect

Lubomir I. Ivanov

unread,
Apr 24, 2026, 4:36:30 PM (9 days ago) Apr 24
to Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
> Concretely, k8s.io/api/resource/v1 pulls in the entirety of util/validation — regex engine, error aggregation, the whole surface — for a single integer (issue #127889).

there is also the aspect that moving constants will break consumers.

i'd just fork the constants and add comments in all locations (origin
& forks). on origin, enumerating the consumers on a best effort, and
on the forks explaining to keep this in sync with origin to pulling
entire modules. linters can help here too.

lubomir
--

Lubomir I. Ivanov

unread,
Apr 24, 2026, 4:37:37 PM (9 days ago) Apr 24
to Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
> with origin to pulling

* instead of pulling

lubomir
--

Davanum Srinivas

unread,
Apr 24, 2026, 4:41:57 PM (9 days ago) Apr 24
to Lubomir I. Ivanov, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
"moving constants will break consumers." i think i left the old ones there, if i missed something happy to fix.

Lubomir I. Ivanov

unread,
Apr 24, 2026, 5:03:56 PM (9 days ago) Apr 24
to Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
ok, i see what you did in the PR, it's just a reference ALA 'const
PoolNameMaxLength = rfc.DNS1123SubdomainMaxLength'
where 'rfc' is a package from the new `constants` module. this works
nicely and it doesn't 'move' constants, per se.
so +1.

lubomir
--

Tim Hockin

unread,
Apr 24, 2026, 5:25:23 PM (9 days ago) Apr 24
to Lubomir I. Ivanov, Davanum Srinivas, sig-arch...@kubernetes.io, sig-api-...@kubernetes.io
Reply all
Reply to author
Forward
0 new messages