Skip to content

Possible Bug: kubectl get --export for singular item omits namespace #41880

@cknowles

Description

@cknowles

When exporting using a command of the form kubectl get <resourceType> <resourceName> -o yaml --namespace=<namespace> --export the namespace is included in the export when resourceName is omitted but it is missing when specifying resourceName.

Similar to several of the --export items such as #28551 and those inside #38768. However, I could not find a direct report of this particular issue. Perhaps some overlap with #33767 but not sure.

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

Kubernetes version (use kubectl version):

✗ kubectl version
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3", GitCommit:"029c3a408176b55c30846f0faedf56aae5992e9b", GitTreeState:"clean", BuildDate:"2017-02-17T20:49:14Z", GoVersion:"go1.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.3+coreos.0", GitCommit:"8fc95b64d0fe1608d0f6c788eaad2c004f31e7b7", GitTreeState:"clean", BuildDate:"2017-02-15T19:52:15Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration: AWS
  • OS (e.g. from /etc/os-release): Mac OS, Sierra

What happened:

When exporting using a command of the form kubectl get <resourceType> <resourceName> -o yaml --namespace=<namespace> --export the namespace is included in the export when resourceName is omitted but it is missing when specifying resourceName.

What you expected to happen:

namespace should be included in the export even when specifying a resourceName.

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

As an example here is this performed in the kube-system namespace for deployments and the kube-dns deployment, however the same problem occurs for at least services and ingresses plus for all namespaces.

✗ kubectl get deployment -o yaml --namespace=kube-system --export | grep namespace   
    namespace: kube-system
    selfLink: /apis/extensions/v1beta1/namespaces/kube-system/deployments/heapster-v1.2.0
                fieldPath: metadata.namespace
    namespace: kube-system
    selfLink: /apis/extensions/v1beta1/namespaces/kube-system/deployments/kube-dns
    namespace: kube-system
    selfLink: /apis/extensions/v1beta1/namespaces/kube-system/deployments/kube-dns-autoscaler
          - --namespace=kube-system

✗ kubectl get deployment kube-dns -o yaml --namespace=kube-system --export | grep namespace
  selfLink: /apis/extensions/v1beta1/namespaces//deployments/kube-dns

Metadata

Metadata

Labels

sig/cliCategorizes an issue or PR as relevant to SIG CLI.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions