Create k8s controllers based on kube-apiserver version detected #2735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes:
k8s: set up informers / controllers based on api-server version
Since kubernetes automatically adds a v1 network policy to both v1 and
v1beta1 resources and a v1beta1 network policy also to both v1 and
v1beta1 resources, it will be useless to watch for both resource types
at the same time. For that reason it was added a kube-apiserver version
detection to set up the necessary informers / controllers based on the
kube-apiserver version detected.
For example, if kube-apiserver is running with version 1.6. only the
Cilium TPR (v1) and the kubernetes network policy v1beta1 controllers
will be started. If kube-apiserver is running with version 1.8 only the
Cilium CRD (v2) and the kubernetes network policy v1 controllers will be
started
pkg/k8s: mirror parseNetworkPolicy for kubernetes NP v1beta1
Fixes: Deleting then adding a policy in quick succession causes invocation of wrong Kubernetes NetworkPolicy watcher #2731