-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
cannot apply networking.k8s.io/v1 - updates to networkpolicy spec are forbidden #53906
Comments
/sig area/kubectl |
@kubernetes/sig-network-bugs |
@boeboe: Reiterating the mentions to trigger a notification: In response to this:
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. |
For compatibility reasons, without qualifying the resource, the You can qualify the API group you want to fetch. This will fetch the policies from the
Or even more specifically, the
If you are scripting |
…l get gives back beta which make us to run ansible without any issue Refer: kubernetes/kubernetes#53906
@liggitt can you please re-open this issue, since one cannot specify a fully-qualifying resource when applying through a yaml file ... or to rephrase, we were fully qualifying our yaml files using apiVersion: networking.k8s.io/v1, but this brakes kubectl apply -f nwp.yaml expected behaviour.
When trying to fully qualify as you mention in your reply....
Bottom line it boils down to this error...
... which should not happen since no changes where made on the networkpolicy. There is a mismatch between backwards compatible read vs non-forward compatible apply/update. |
Resources in a yaml file are always fully qualified (they include the full api group and version) That syntax for fully specifying a resource, api group, and api version is specific to Your subsequent the following get would show it in the expected version
|
The apply issue is likely related to defaulting or validation in the v1 group alone. The returned extensions/v1beta1 content for an unqualified get is unrelated |
May be related #51955 |
/assign |
This is expected if running on a k8s < v1.8 cluster, since updates to NP were only introduced in v1.8. If you try to update on a v1.8 cluster is should succeed.
I think you've got the wrong apiVersion in your manifest - |
apply on network policy was working on k8s < 1.7, that is, if the policy applied was exactly the same as the one in the cluster (hence your remark indeed that updates are only supported from 1.8 onwards). My point is that on 1.7 an apply (with a no-update operation, as in yaml == cluster state) does not work since apiVersion issue legacy vs new. |
@boeboe oh yes, I see what you mean. Thanks for clarifying. |
the objects as seen internally by the validation code are:
note the ingress rule this is the troublesome line:
which initializes the From field to an empty slice when converting, even if the starting object has a nil |
…master Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Ensure network policy conversion round trips nil from field xref kubernetes#53906 ```release-note NONE ```
Automatic merge from submit-queue. Ensure network policy conversion round trips nil from fields Fixes #53906 (inability to apply network policies against v1 in 1.7) * Changes non-mutation check to API equality (which treats nil and [] slices identically) * Fixed bug in manual conversion that took an input of `nil` and produced an output of `[]` ```release-note Restores the ability to apply network policy objects against the networking.k8s.io/v1 API ```
fixed by #54109 |
Hi all,
/sig area/kubectl
/sig sig/network
@kubernetes/sig-network-bugs
We made the upstep from k8s 1.6 to 1.7.8 on our k8s clusters. As good k8s citizens, we have updated our NetworkPolicy yaml deployment files to use the new networking.k8s.io/v1 apiVersion. It appears however that a retrieval of NetworkPolicies deployed this way, still use the extensions/v1beta1 apiVersion. I suppose this is due to backwards compatibility concerns, which I can perfectly understand.
What is the issue however, is that we deploy our NetworkPolicies (in an automated way, using a cluster applier process within each namespace, that pulls the yaml config from git and applies them periodically) using "kubectl apply -f *.yaml". The kubectl client however refuses to do so, since he detects a false change between what's deployed (extensions/v1beta1) and what's to be deployed (networking.k8s.io/v1). I'd expect the same compatibility check/measures at apply time (not only at fetch/retrieval time).
Does anyone have any advice on how to get around this? We know that we could write a more advanced cluster applier process that circumvents this corner cases in an if-then-else matter, but I would expect the kubectl client to handle those things, or am I overlooking a certain kubectl feature here?
Best regards,
Bart
The text was updated successfully, but these errors were encountered: