Skip to content

Commit

Permalink
Merge pull request #231 from VictoriaMetrics/additional-rbac
Browse files Browse the repository at this point in the history
additional rbac for openshift
  • Loading branch information
f41gh7 authored Apr 21, 2021
2 parents 3e2a248 + 173cf0a commit 0ead317
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/v1beta1/vmagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type VMAgentSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Key at Configmap with relabelConfig name",xDescriptors="urn:alm:descriptor:io.kubernetes:ConfigMapKeySelector"
RelabelConfig *v1.ConfigMapKeySelector `json:"relabelConfig,omitempty"`
// InlineRelabelConfig - defines GlobalRelabelConfig for vmagent, can be defined directly at CRD.
// +optional
InlineRelabelConfig []RelabelConfig `json:"inlineRelabelConfig,omitempty"`
// ServiceScrapeSelector defines ServiceScrapes to be selected for target discovery.
// +optional
Expand Down
11 changes: 10 additions & 1 deletion config/examples/vmagent_rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ rules:
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- namespaces
- configmaps
verbs: ["get"]
- nonResourceURLs: ["/metrics"]
- nonResourceURLs: ["/metrics","/metrics/resources"]
verbs: ["get"]
- apiGroups:
- route.openshift.io
- image.openshift.io
resources:
- routers/metrics
- registry/metrics
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
Expand Down
9 changes: 9 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ rules:
- watch
- nonResourceURLs:
- "/metrics"
- "/metrics/resources"
verbs:
- get
- watch
Expand Down Expand Up @@ -390,3 +391,11 @@ rules:
- list
- get
- watch
- apiGroups:
- route.openshift.io
- image.openshift.io
resources:
- routers/metrics
- registry/metrics
verbs:
- get
1 change: 1 addition & 0 deletions controllers/factory/vmagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ func addAdditionalObjectOwnership(cr *victoriametricsv1beta1.VMAgent, rclient cl
UID: cr.UID,
})
object.SetOwnerReferences(existOwners)
victoriametricsv1beta1.MergeFinalizers(object, victoriametricsv1beta1.FinalizerName)

return rclient.Update(context.Background(), object)
}
Expand Down
12 changes: 11 additions & 1 deletion controllers/factory/vmagent/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func buildVMAgentClusterRole(cr *v1beta12.VMAgent) *v12.ClusterRole {
"pods",
"endpointslices",
"configmaps",
"namespaces",
},
},
{
Expand All @@ -144,9 +145,18 @@ func buildVMAgentClusterRole(cr *v1beta12.VMAgent) *v12.ClusterRole {
},
},
{
NonResourceURLs: []string{"/metrics"},
NonResourceURLs: []string{"/metrics", "/metrics/resources"},
Verbs: []string{"get", "list", "watch"},
},
{
APIGroups: []string{"route.openshift.io", "image.openshift.io"},
Verbs: []string{
"get",
},
Resources: []string{
"routers/metrics", "registry/metrics",
},
},
},
}
}

0 comments on commit 0ead317

Please sign in to comment.