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
Kubernetes SD: Support networking.k8s.io/v1 Ingress #9205
Conversation
Signed-off-by: Takashi Kusumi <tkusumi@zlab.co.jp>
I'm a little worried about the maintainability aspect of this, we already have open PRs about adding more functionality to the ingress service discovery, is there any way we could make this work without duplication? |
@brancz Thank you for your comment. I agree with you that it is difficult to maintain. AFAIK, we cannot convert v1beta1 Ingress to v1 Ingress properly without importing k8s.io/kubernetes, which is not supported as libraries. So how about we introduce an adaptor for v1 and v1beta1? I pushed my adaptor implementation to a different branch.
|
Alternatively, we can convert only necessary fields of v1beta1 Ingress to v1 Ingress manually. But I think it is prone to programming errors when we will see another field in the future. I pushed the implementation with partial conversion to a different branch.
|
I think I like the adaptor implementation better as with the partial conversion the next contributor will probably assume that some value is there when it might not be because the partial conversion doesn't cover it yet. I'd be happy with moving ahead with the adaptor implementation. |
Signed-off-by: Takashi Kusumi <tkusumi@zlab.co.jp>
Closing/reopening for CI to run |
lgtm on green |
There are linting failures, could you please look at them @tksm :
|
Signed-off-by: Takashi Kusumi <tkusumi@zlab.co.jp>
@roidelapluie Thank you for pointing it out. I fixed the lint issue in 3ab8559 . |
Squash merging to make the cherry-pick simpler. |
…I for `role: ingress` and `role: endpointslices` This should fix service discovery for these roles in Kubernetes v1.22 and newer versions. See https://kubernetes.io/docs/reference/using-api/deprecation-guide/#ingress-v122 The corresponding change in Prometheus - prometheus/prometheus#9205
…I for `role: ingress` and `role: endpointslices` This should fix service discovery for these roles in Kubernetes v1.22 and newer versions. See https://kubernetes.io/docs/reference/using-api/deprecation-guide/#ingress-v122 The corresponding change in Prometheus - prometheus/prometheus#9205
Signed-off-by: Takashi Kusumi tkusumi@zlab.co.jp
Fixes: #9199
This PR is to support the
networking.k8s.io/v1
Ingress for Kubernetes v1.22 and later. Thenetworking.k8s.io/v1beta1
Ingress that Kubernetes SD currently uses was removed in Kubernetes v1.22.Since the
networking.k8s.io/v1
Ingress is not available below Kubernetes v1.19, I made it support bothnetworking.k8s.io/v1
andnetworking.k8s.io/v1beta1
for backward compatibility. Which Ingress API Kubernetes SD will use is decided based on the Kubernetes version. If the Kubernetes version >= 1.19, it will usenetworking.k8s.io/v1
, otherwise it will usenetworking.k8s.io/v1beta1
.Notes for reviewers
networking.k8s.io/v1
Ingress is introduced in Kubernetes v1.19v1
Ingress is GA since v1.19, so I made it check the Kubernetes version for the API availability rather than calling ServerSupportsVersion(), which makes many API requests.v1beta1
toV1beta1
suffixed functions. We can remove the suffixed functions after we stop support for Kubernetes below v1.19.v1
andv1beta1
needs the Kubernetes internal package, so I gave up on the conversion.I confirmed that Ingress discovery with this PR worked in the following Kubernetes versions on minikube.
v1beta1
v1beta1
v1beta1
,v1
v1
v1
v1
Here is my confirmation procedure.
Confirmation procedure on minikube
Start minikube
Start minikube with the specific Kubernetes version.
Build the Prometheus image on minikube
Deploy the custom Prometheus with Ingress setting
Here is the manifest for custom Prometheus with Ingress setting. The image name for Prometheus might need to be changed.
https://gist.github.com/tksm/2de340ba5b057ce8f099f8541c8cb400#file-prometheus-deploy-yaml
Create an Ingress resource for test
For Kubernetes v1.19 and later. create an Ingress resource with v1.
https://gist.github.com/tksm/2de340ba5b057ce8f099f8541c8cb400#file-ingress-v1-yaml
For below Kubernetes v1.19, create an Ingress resource with v1beta1.
https://gist.github.com/tksm/2de340ba5b057ce8f099f8541c8cb400#file-ingress-v1beta1-yaml
Check an Ingress target is added
Open the Prometheus Web UI.
Check an ingress target is added and its labels are correctly set in Prometheus UI (
/targets
).