-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default namespace is incorrectly applied to clusterwide resources #69
Comments
I haven't looked in the code, but looked at the swagger API JSON which Kubenix consumes. It seems this information is curiously not present in the resource definitions, which shows that a pod and a namespace has the same metadata definition: "io.k8s.api.core.v1.Pod": {
"properties": {
"metadata": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
"description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
},
},
},
"io.k8s.api.core.v1.Namespace": {
"properties": {
"metadata": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",
"description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
},
},
}, Perhaps we can the swagger API paths to determine whether an object is namespaced? "paths": {
"/api/v1/namespaces": { },
"/api/v1/namespaces/{namespace}/pods": { },
}, Does seem a bit hacky though... Another angle might be to determine how kubectl does this:
|
BTW, is there any problem you encounter when you specify the namespace on resources that don't need it? Take this example: apiVersion: v1
kind: Namespace
metadata:
name: test
namespace: default It is created fine:
The namespace is simply removed: apiVersion: v1
kind: Namespace
metadata:
creationTimestamp: "2024-07-13T13:47:53Z"
labels:
kubernetes.io/metadata.name: test
name: test
resourceVersion: "23410350"
uid: 1506b413-dbf6-45a5-aaf1-f6a28631641c
spec:
finalizers:
- kubernetes
status:
phase: Active |
Hello,
Defining
kubernetes.namespace
is a practical way to set the namespace to all resources but it's also applied to ones which shouldn't have it.Kubenix should be aware of namespaced/clusterwide resources to decide if the namespace is needed.
I'm not familiar enough with the codebase to open a PR but I can probably do it with some direction pointing :) .
The text was updated successfully, but these errors were encountered: