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
Namespace has no effect when exposing deployment with --dry-run=client #97492
Conversation
This is how to reproduce. $ kubectl create ns testns $ kubectl -n testns create deployment test-deploy --image=nginx $ kubectl -n testns expose deployment.apps/test-deploy --port=80 --dry-run=client -o yaml apiVersion: v1 kind: Service metadata: creationTimestamp: null labels: app: test-deploy name: test-deploy spec: ports: - port: 80 protocol: TCP targetPort: 80 selector: app: test-deploy status: loadBalancer: {} If --dry-run=client is not specified, namespace element is contained in the yaml.
Hi @masap. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Type: corev1.ServiceTypeLoadBalancer, | ||
}, | ||
}, | ||
expected: "namespace: testns", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this the expected output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though exact result is as follows, this code checks only namespace because we are only interested in it.
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
svc: test
name: foo
namespace: testns
spec:
ports:
- port: 14
protocol: UDP
targetPort: 14
selector:
func: stream
type: LoadBalancer
status:
loadBalancer: {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knight42 Is there any comment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
/ok-to-test
/triage accepted |
if meta, err := meta.Accessor(object); err == nil && o.EnforceNamespace { | ||
meta.SetNamespace(o.Namespace) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soltysh @deads2k Is it preferable to take this route, and manipulate the generated object before printing.. or would it be better to, in the generator, add the namespace to the generated object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That code seems to be used in the run
command as well.
kubernetes/staging/src/k8s.io/kubectl/pkg/cmd/run/run.go
Lines 677 to 679 in 8b24d1f
if meta, err := meta.Accessor(actualObj); err == nil && o.EnforceNamespace { | |
meta.SetNamespace(o.Namespace) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok temporary solution, we're slowly getting rid of generators which will clear this situation.
/lgtm |
@knight42 Thanks! |
/assign @deads2k |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
if meta, err := meta.Accessor(object); err == nil && o.EnforceNamespace { | ||
meta.SetNamespace(o.Namespace) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ok temporary solution, we're slowly getting rid of generators which will clear this situation.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: masap, soltysh The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This is how to reproduce.
If
--dry-run=client
is not specified, namespace element is contained in the yaml.Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: