Skip to content

Commit

Permalink
create stub CR for KRP authorize access to Thanos Querier
Browse files Browse the repository at this point in the history
  • Loading branch information
raptorsun committed Nov 8, 2023
1 parent 7b8cc2c commit ec9abfe
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 31 deletions.
8 changes: 8 additions & 0 deletions assets/cluster-monitoring-operator/cluster-role-view.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ rules:
- namespaces
verbs:
- get
- apiGroups:
- monitoring.coreos.com
resources:
- prometheuses/query
verbs:
- get
- create
- update
6 changes: 3 additions & 3 deletions assets/thanos-querier/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ spec:
- --tls-cert-file=/etc/tls/private/tls.crt
- --tls-private-key-file=/etc/tls/private/tls.key
- --tls-cipher-suites=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
- --ignore-paths=/-/healthy,/-/ready
- --allow-paths=/api/v1/query,/api/v1/query_range,/api/v1/format_query,/api/v1/series,/api/v1/labels,/api/v1/label/*/values,/api/v1/query_exemplars,/api/v1/targets,/api/v1/rules,/api/v1/alerts,/api/v1/targets/metadata,/api/v1/metadata,/api/v1/alertmanagers,/api/v1/status/*
- -v=10
image: quay.io/brancz/kube-rbac-proxy:v0.15.0
livenessProbe:
failureThreshold: 4
httpGet:
path: /-/healthy
port: 9091
port: 9090
scheme: HTTPS
initialDelaySeconds: 30
periodSeconds: 30
Expand All @@ -106,7 +106,7 @@ spec:
failureThreshold: 20
httpGet:
path: /-/ready
port: 9091
port: 9090
scheme: HTTPS
initialDelaySeconds: 5
periodSeconds: 5
Expand Down
10 changes: 5 additions & 5 deletions assets/thanos-querier/kube-rbac-proxy-web-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ stringData:
config.yaml: |-
"authorization":
"resourceAttributes":
"apiGroup": ""
"resource": "namespaces"
"apiGroup": "monitoring.coreos.com"
"resource": "prometheuses"
"subresource": "query"
"verbs":
- "get"
- "create"
- "update"
"static":
- "resourceRequest": true
"user":
"name": "system:serviceaccount:openshift-monitoring:prometheus-k8s"
- "resourceRequest": true
"user":
"name": "system:serviceaccount:openshift-user-workload-monitoring:thanos-ruler"
type: Opaque
17 changes: 12 additions & 5 deletions jsonnet/components/cluster-monitoring-operator.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,18 @@ function(params) {
metadata: {
name: 'cluster-monitoring-view',
},
rules: [{
apiGroups: [''],
resources: ['namespaces'],
verbs: ['get'],
}],
rules: [
{
apiGroups: [''],
resources: ['namespaces'],
verbs: ['get'],
},
{
apiGroups: ['monitoring.coreos.com'],
resources: ['prometheuses/query'],
verbs: ['get', 'create', 'update'],
},
],
},

// This role enables read/write access to the platform Alertmanager API through OAuth proxy.
Expand Down
43 changes: 25 additions & 18 deletions jsonnet/components/thanos-querier.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ function(params)
stringData: {
'config.yaml': std.manifestYamlDoc({
authorization: {
resourceAttributes:
{
apiGroup: '',
resource: 'namespaces',
verbs: ['get'],
},
resourceAttributes: {
apiGroup: 'monitoring.coreos.com',
resource: 'prometheuses',
subresource: 'query',
verbs: ['get', 'create', 'update'],
},
static: [
{
// allow prometheus-k8s to get/post queries from/to thanos querier
Expand All @@ -170,13 +170,6 @@ function(params)
},
resourceRequest: true,
},
{
// allow thanos ruler to get/post queries from/to thanos querier
user: {
name: 'system:serviceaccount:openshift-user-workload-monitoring:thanos-ruler',
},
resourceRequest: true,
},
],
},
}),
Expand Down Expand Up @@ -428,9 +421,22 @@ function(params)
'--tls-cert-file=/etc/tls/private/tls.crt',
'--tls-private-key-file=/etc/tls/private/tls.key',
'--tls-cipher-suites=' + cfg.tlsCipherSuites,
'--ignore-paths=' + std.join(',', [
'/-/healthy',
'/-/ready',
/* all Prometheus API endpoints except /api/v1/admin */
'--allow-paths=' + std.join(',', [
'/api/v1/query',
'/api/v1/query_range',
'/api/v1/format_query',
'/api/v1/series',
'/api/v1/labels',
'/api/v1/label/*/values',
'/api/v1/query_exemplars',
'/api/v1/targets',
'/api/v1/rules',
'/api/v1/alerts',
'/api/v1/targets/metadata',
'/api/v1/metadata',
'/api/v1/alertmanagers',
'/api/v1/status/*',
]),
'-v=10',
],
Expand All @@ -454,7 +460,7 @@ function(params)
livenessProbe: {
httpGet: {
path: '/-/healthy',
port: 9091,
port: 9090,
scheme: 'HTTPS',
},
initialDelaySeconds: 30,
Expand All @@ -464,7 +470,7 @@ function(params)
readinessProbe: {
httpGet: {
path: '/-/ready',
port: 9091,
port: 9090,
scheme: 'HTTPS',
},
initialDelaySeconds: 5,
Expand Down Expand Up @@ -658,4 +664,5 @@ function(params)

},
},

}
8 changes: 8 additions & 0 deletions manifests/0000_50_cluster-monitoring-operator_02-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ rules:
- namespaces
verbs:
- get
- apiGroups:
- monitoring.coreos.com
resources:
- prometheuses/query
verbs:
- get
- create
- update
- apiGroups:
- ""
resourceNames:
Expand Down

0 comments on commit ec9abfe

Please sign in to comment.