Skip to content

Commit

Permalink
chore(RHTAPWATCH-568): Add authentication to Service and ServiceMonitor
Browse files Browse the repository at this point in the history
Signed-off-by: Kousalya Lakshmanan <[email protected]>
  • Loading branch information
klakshma21 committed Jan 22, 2024
1 parent 1f9bdee commit 254349d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@ metadata:
name: exporter-sa
namespace: appstudio-grafana-datasource-exporter
---
apiVersion: v1
kind: Secret
metadata:
name: metrics-reader
namespace: appstudio-grafana-datasource-exporter
annotations:
kubernetes.io/service-account.name: exporter-sa
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: exporter-cluster-role
rules:
- apiGroups: ['grafana.integreatly.org']
resources: ['grafanas']
verbs: ["get"]
- nonResourceURLs:
- /metrics
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand All @@ -41,9 +51,9 @@ metadata:
app: grafana-datasource-exporter
spec:
ports:
- name: http
port: 8090
targetPort: http
- name: https
port: 8443
targetPort: https
selector:
app: grafana-datasource-exporter
---
Expand All @@ -67,8 +77,8 @@ spec:
- name: grafana-datasource-exporter
image: quay.io/redhat-appstudio/o11y-prometheus-exporters:v0.1
ports:
- containerPort: 8090
name: http
- containerPort: 8443
name: https
resources:
limits:
cpu: 100m
Expand All @@ -77,6 +87,7 @@ spec:
cpu: 100m
memory: 10Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
---
Expand All @@ -88,8 +99,13 @@ metadata:
spec:
endpoints:
- path: /metrics
port: http
scheme: http
port: https
scheme: https
bearerTokenSecret:
name: "metrics-reader"
key: token
tlsConfig:
insecureSkipVerify: true
selector:
matchLabels:
app: grafana-datasource-exporter
4 changes: 2 additions & 2 deletions exporters/dsexporter/dsexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func main() {
exporter := NewCustomCollector()
reg.MustRegister(exporter)

fmt.Println("Server is listening on http://localhost:8090/metrics")
fmt.Println("Server is listening on http://localhost:8443/metrics")

http.Handle("/metrics", promhttp.HandlerFor(
reg,
Expand All @@ -52,5 +52,5 @@ func main() {
Registry: reg,
},
))
http.ListenAndServe(":8090", nil)
http.ListenAndServe(":8443", nil)
}

0 comments on commit 254349d

Please sign in to comment.