Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Fix manifest kustomization for metrics service #202

Merged
merged 1 commit into from
Apr 22, 2022

Conversation

erikgb
Copy link
Contributor

@erikgb erikgb commented Apr 19, 2022

Also removed unused ClusterRole and ClusterRoleBinding that is supposed to grant access through kube-rbac-proxy, which is currently not in use in HNC.

Tested: Verified that metrics service works as annotated by prometheus service annotations

Fixes #115

With this change, I can scrape metrics as described by metrics-service prometheus annotations:

$ kubectl -n hnc-system run -it --rm --restart=Never curl --image=curlimages/curl sh
If you don't see a command prompt, try pressing enter.
/ $ curl http://hnc-controller-manager-metrics-service:8080/metrics

Before this change, this fails:

$ kubectl -n hnc-system run -it --rm --restart=Never curl --image=curlimages/curl sh
If you don't see a command prompt, try pressing enter.
/ $ curl https://hnc-controller-manager-metrics-service:8443/metrics
curl: (7) Failed to connect to hnc-controller-manager-metrics-service port 8443 after 0 ms: Connection refused
/ $ 

Another option is to configure the kube-rbac-proxy. Please let me know if that solution is preferred.

/cc @adrianludwin

Also removed unused ClusterRole and ClusterRoleBinding that is supposed to grant access through kube-rbac-proxy, which is currently not in use in HNC.

Tested: Verified that metrics service works as annotated by prometheus service annotations
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 19, 2022
@@ -40,9 +40,6 @@ spec:
- /manager
args:
- "--webhook-server-port=9443"
# If /config/default/manager_auth_proxy_patch.yaml is used, the port in
# --metrics-addr must match the value of --upstream passed to
# kube-rbac-proxy.
- "--metrics-addr=:8080"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't just changing this to 8443 fix our issue and still allow us to use HTTPS? I'm not sure we want to take a step back in security and not use HTTPS for metrics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't just changing this to 8443 fix our issue and still allow us to use HTTPS? I'm not sure we want to take a step back in security and not use HTTPS for metrics.

No, there is nothing providing a HTTPS listener (on port 8443). Then we need to include the kube-rbac-proxy sidecar and route all metrics scrape request through its HTTPS listener - forwarding the request to the controller-manager metrics HTTP endpoint. That is an alternative mentioned in the PR description, though more complex, and I don't see the true benefit of this. I expect many K8s distros to block namespace ingress traffic by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we took out kube-rbac-proxy a while ago (it has a bunch of problems from a supply chain perspective) and I'd rather not put it back in without good justification.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need rbac proxy for https, that is only needed for authz. We already serve https traffic for the webhook on 9443. So I guess I don't see why we couldn't also use it (or have the option) for 8443 for metrics. However, that is probably out of scope of this PR if metrics are currently broken.

I created this to revisit this.

Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm
/hold
/assign @rjbez17

I think this is good unless Ryan has any remaining concerns.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 22, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 22, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, erikgb

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 22, 2022
@rjbez17
Copy link
Contributor

rjbez17 commented Apr 22, 2022

I opened #204 to follow up on my concerns.

/hold cancel
/lgtm

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 22, 2022
@k8s-ci-robot k8s-ci-robot merged commit fdf83ab into kubernetes-retired:master Apr 22, 2022
@erikgb
Copy link
Contributor Author

erikgb commented Apr 22, 2022

@rjbez17 @adrianludwin Thanks for accepting this PR. I think this is a bugfix, and should be cherry-picked to the v1.0 branch. The metrics setup is borked in the 1.0 release. WDYT?

@adrianludwin
Copy link
Contributor

adrianludwin commented Apr 24, 2022 via email

@erikgb
Copy link
Contributor Author

erikgb commented Apr 24, 2022

sgtm, I'd happily approve that and then release v1.0.1.

Nice, here is the cherry-pick PR: #207

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metrics svc port mismatch on the release/installation file
4 participants