kubernetes: Custom `Namespace` cluster wide resource reports 404 when trying to GET

What happened: I defined a CRD with a custom group (eg. test.my.domain), and a custom version (eg. v1beta1), with the Kind set to Namespace, and the scope set to Cluster. A more detailed CRD definition is found here.

After I applied this CRD, I created a sample resource, and then tried to list and get the resource using kubectl. Results of kubectl get namespaces.test.my.domain:

$ kubectl get namespaces.test.my.domain 
NAME               AGE
namespace-sample   76m

However, when I do a kubectl get namespaces.test.my.domain namespace-sample:

$ kubectl get namespaces.test.my.domain namespace-sample
Error from server (NotFound): the server could not find the requested resource (get namespaces.test.my.domain namespace-sample)

What you expected to happen: It seems like it doesn’t break on the other resource name that I tried (testresource), which suggests it’s specific to an overlap in naming on the Namespace keyword. I would expect that the group is enough of a differentiator.

How to reproduce it (as minimally and precisely as possible): As above.

Anything else we need to know?:

  • Why would you want to do this? Sounds like a one-way ticket to confusion! - We’re trying to redesign a drop-in abstraction that most people can use in the same manner as a true Namespace, but it just wraps up a bunch more automation that we have behind the scenes that is appropriate for the ways of working in the company. We understand if the answer is just don't use Namespace as a cluster-wide resource kind, but since we were working on this, we figure we’d bring it up as a discussion topic anyway. Our current workaround is to do something like CompanyNamespace, but in its long form seems kind of stutter-y: companynamespaces.company.domain.

Environment:

  • Kubernetes version (use kubectl version):
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.1", GitCommit:"206bcadf021e76c27513500ca24182692aabd17e", GitTreeState:"clean", BuildDate:"2020-09-14T07:30:52Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration: I built the cluster using kind
  • OS (e.g: cat /etc/os-release): Debian GNU/Linux 9 (stretch)
  • Kernel (e.g. uname -a): Linux dev 4.9.0-12-amd64 #1 SMP Debian 4.9.210-1+deb9u1 (2020-06-07) x86_64 GNU/Linux

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 21 (6 by maintainers)

Commits related to this issue

Most upvoted comments