Skip to content
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

In-cluster namespace for kubectl cannot be overridden by metadata.namespace in JSON #44835

Closed
anguslees opened this issue Apr 24, 2017 · 1 comment
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@anguslees
Copy link
Member

This is similar to #43662, but that report (and fix) focussed on the in-cluster namespace vs configured .kube/config context namespace. I have a similar issue with the in-cluster namespace vs an explicit metadata.namespace in the JSON/YAML file I'm passing to kubectl create -f

When run in-cluster, kubectl 1.5+ (including 1.6.0) refuses to allow me to create a resource in another namespace via an explicit metadata.namespace property on a resource.

kubectl 1.4.x honours .metadata.namespace when run in-cluster as expected. All versions honour metadata.namespace when run out-of-cluster.

(No .kube/config, just using in-cluster defaults)
% cat /var/run/secrets/kubernetes.io/serviceaccount/namespace
foo
% jq .metadata.namespace echo.json 
"foo2"
% ./kubectl-1.6.0 create -f echo.json 
error: the namespace from the provided object "foo2" does not match the namespace "foo". You must pass '--namespace=foo2' to perform this operation.
% ./kubectl-1.5.6 create -f echo.json 
error: the namespace from the provided object "foo2" does not match the namespace "foo". You must pass '--namespace=foo2' to perform this operation.
% ./kubectl-1.4.7 create -f echo.json 
deployment "echoheaders" created

I don't want to / can't provide an explicit --namespace arg or context declaration as suggested by the error text, because this is an automated deployment pipeline that creates resources in multiple namespaces. I just want the client to do-what-I-say without imposing additional client-side restrictions 😛

@liggitt liggitt added kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI. labels Apr 24, 2017
@liggitt liggitt self-assigned this Apr 24, 2017
@liggitt
Copy link
Member

liggitt commented Apr 24, 2017

Fixed in #44862

k8s-github-robot pushed a commit that referenced this issue Apr 25, 2017
Automatic merge from submit-queue

Stop treating in-cluster-config namespace as an override

Fixes #44835

The namespace of an in-cluster config should behave like the namespace specified in a kubeconfig file... it should be used as the default namespace, but be able to be overridden by namespaces specified in yaml files passed to `kubectl create -f`.

```release-note
Restored the ability of kubectl running inside a pod to consume resource files specifying a different namespace than the one the pod is running in.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

No branches or pull requests

2 participants