Skip to content
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

Use access to Alertmanager CR to gate access to AM #502

Merged
merged 2 commits into from
Oct 15, 2019

Conversation

cblecker
Copy link
Member

@cblecker cblecker commented Oct 11, 2019

This changes the permissions needed to access Alertmanager's UI, and the ability to view its config or create silences. Instead of having to rely in the ability to see all namespaces, this changes the permissions to the ability to view the Alertmanager CR. This way, access can be specifically granted to users based on the ability to view that CR.

Also fix a makefile syntax issue on systems (such as Darwin) that use a different file path for the make binary.

cc: @RiRa12621 @brancz @sichvoge
ref: https://jira.coreos.com/browse/SREP-1983

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 11, 2019
@cblecker
Copy link
Member Author

/test e2e-aws

@s-urbaniak
Copy link
Contributor

thanks @cblecker, the e2e test failure is valid here. The following alerts are being fired:

✔ALERTS{alertmanager="https://10.131.0.5:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="pending",endpoint="web",instance="10.131.0.7:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-1",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.131.0.5:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="pending",endpoint="web",instance="10.129.2.13:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-0",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.131.0.5:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="firing",endpoint="web",instance="10.131.0.7:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-1",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.131.0.5:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="firing",endpoint="web",instance="10.129.2.13:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-0",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.129.2.10:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="pending",endpoint="web",instance="10.131.0.7:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-1",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.129.2.10:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="pending",endpoint="web",instance="10.129.2.13:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-0",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.129.2.10:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="firing",endpoint="web",instance="10.131.0.7:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-1",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.129.2.10:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="firing",endpoint="web",instance="10.129.2.13:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-0",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.128.2.8:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="pending",endpoint="web",instance="10.131.0.7:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-1",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.128.2.8:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="pending",endpoint="web",instance="10.129.2.13:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-0",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.128.2.8:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="firing",endpoint="web",instance="10.131.0.7:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-1",service="prometheus-k8s",severity="warning"}
✔ALERTS{alertmanager="https://10.128.2.8:9095/api/v1/alerts",alertname="PrometheusErrorSendingAlertsToSomeAlertmanagers",alertstate="firing",endpoint="web",instance="10.129.2.13:9091",job="prometheus-k8s",namespace="openshift-monitoring",pod="prometheus-k8s-0",service="prometheus-k8s",severity="warning"}

The resolution should be failry easy. We need to give Prometheus the permissions expressed in the oauth proxy SAR: '-openshift-sar={"group": "monitoring.coreos.com", "resource": "alertmanagers", "namespace": "openshift-monitoring", "verb": "get"}'

@s-urbaniak
Copy link
Contributor

I believe adding another amRole here should do the trick:

local authenticationRole =
policyRule.new() +
policyRule.withApiGroups(['authentication.k8s.io']) +
policyRule.withResources([
'tokenreviews',
]) +
policyRule.withVerbs(['create']);
local authorizationRole =
policyRule.new() +
policyRule.withApiGroups(['authorization.k8s.io']) +
policyRule.withResources([
'subjectaccessreviews',
]) +
policyRule.withVerbs(['create']);
local namespacesRole =
policyRule.new() +
policyRule.withApiGroups(['']) +
policyRule.withResources([
'namespaces',
]) +
policyRule.withVerbs(['get']);

@s-urbaniak
Copy link
Contributor

and referencing it here:

clusterRole+:
clusterRole.withRulesMixin([authenticationRole, authorizationRole, namespacesRole]),

@cblecker
Copy link
Member Author

@s-urbaniak Thanks for helping to identify the errors. Should this in in addition to the namespacesRole, or instead of the namespacesRole?

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 14, 2019
@cblecker
Copy link
Member Author

@s-urbaniak I'm guessing instead of, and running tests now. If it turns out that prometheus needs both permissions, then I'll add namespaces back in.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 15, 2019
@cblecker
Copy link
Member Author

Turns out it needed to be an in addition to. I've updated the PR, as well as updated the docs to indicate how to grant permissions.

Copy link
Contributor

@s-urbaniak s-urbaniak left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cblecker, s-urbaniak

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 15, 2019
@openshift-merge-robot openshift-merge-robot merged commit 218caf1 into openshift:master Oct 15, 2019
@cblecker cblecker deleted the am-perms branch October 15, 2019 07:40
s-urbaniak added a commit to s-urbaniak/cluster-monitoring-operator that referenced this pull request Oct 15, 2019
This adds the alertmanager policy rule to the existing cluster-monitoring-view
cluster role such that users can access alertmanager with the new subject access review
policy added in openshift#502.
s-urbaniak added a commit to s-urbaniak/cluster-monitoring-operator that referenced this pull request Dec 5, 2019
This reverts commit 218caf1, reversing
changes made to c9d0fa3.
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/cluster-monitoring-operator that referenced this pull request Dec 5, 2019
This reverts commit 218caf1, reversing
changes made to c9d0fa3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants