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

Bug 1904578: Configure metrics scraping #107

Merged
merged 1 commit into from Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions manifests/0000_90_cluster-storage-operator_01_prometheusrbac.yaml
@@ -0,0 +1,32 @@
# Role for accessing metrics exposed by the cluster-storage-operator
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: prometheus
namespace: openshift-cluster-storage-operator
rules:
- apiGroups:
- ""
resources:
- services
- endpoints
- pods
verbs:
- get
- list
- watch
---
# Grant cluster-monitoring access to openshift-cluster-storage-operator metrics
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: prometheus
namespace: openshift-cluster-storage-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: prometheus
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: openshift-monitoring
49 changes: 49 additions & 0 deletions manifests/0000_90_cluster-storage-operator_02_servicemonitor.yaml
@@ -0,0 +1,49 @@
# Configure cluster-monitoring for cluster-storage-operator
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: cluster-storage-operator
namespace: openshift-cluster-storage-operator
annotations:
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 30s
path: /metrics
port: https
scheme: https
tlsConfig:
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
serverName: cluster-storage-operator-metrics.openshift-cluster-storage-operator.svc
jobLabel: component
selector:
matchLabels:
app: cluster-storage-operator-metrics

---

# Configure cluster-monitoring for vsphere-problem-detector
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: vsphere-problem-detector
namespace: openshift-cluster-storage-operator
annotations:
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
spec:
endpoints:
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
interval: 30s
path: /metrics
port: https
scheme: https
tlsConfig:
caFile: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
serverName: vsphere-problem-detector-metrics.openshift-cluster-storage-operator.svc
jobLabel: component
selector:
matchLabels:
app: vsphere-problem-detector-metrics
1 change: 1 addition & 0 deletions manifests/06_operator_cr.yaml
Expand Up @@ -9,3 +9,4 @@ metadata:
spec:
managementState: Managed
logLevel: Normal
operatorLogLevel: Normal
47 changes: 47 additions & 0 deletions manifests/09_metrics_service.yaml
@@ -0,0 +1,47 @@
# Expose operator metrics
apiVersion: v1
kind: Service
metadata:
annotations:
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
service.alpha.openshift.io/serving-cert-secret-name: cluster-storage-operator-serving-cert
labels:
app: cluster-storage-operator-metrics
name: cluster-storage-operator-metrics
namespace: openshift-cluster-storage-operator
spec:
ports:
- name: https
port: 443
protocol: TCP
targetPort: 8443
selector:
Copy link
Member

Choose a reason for hiding this comment

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

I think CSO's metric setup is busted. In deployment we say:

          ports:
          - containerPort: 60000
            name: metrics

And then since we don't specify port in startup command, it will default to 8443, but then where does 443 comes from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point about the containerPort, fixed to 8443.

Copy link
Member

@gnufied gnufied Dec 4, 2020

Choose a reason for hiding this comment

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

we as such don't have to change the port I think. We can as well leave it same as target port.

name: cluster-storage-operator
sessionAffinity: None
type: ClusterIP

---

# Expose vsphere-problem-detector metrics
apiVersion: v1
kind: Service
metadata:
annotations:
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
service.alpha.openshift.io/serving-cert-secret-name: vsphere-problem-detector-serving-cert
labels:
app: vsphere-problem-detector-metrics
name: vsphere-problem-detector-metrics
namespace: openshift-cluster-storage-operator
spec:
ports:
- name: https
port: 443
protocol: TCP
targetPort: 8444
selector:
name: cluster-storage-operator
sessionAffinity: None
type: ClusterIP
19 changes: 17 additions & 2 deletions manifests/09_deployment.yaml → manifests/10_deployment.yaml
Expand Up @@ -37,7 +37,7 @@ spec:
image: quay.io/openshift/origin-cluster-storage-operator:latest
terminationMessagePolicy: FallbackToLogsOnError
ports:
- containerPort: 60000
- containerPort: 8443
name: metrics
command:
- cluster-storage-operator
Expand Down Expand Up @@ -86,16 +86,31 @@ spec:
requests:
cpu: 10m
memory: 20Mi
volumeMounts:
- mountPath: /var/run/secrets/serving-cert
name: cluster-storage-operator-serving-cert
- name: vsphere-problem-detector
image: quay.io/openshift/origin-vsphere-problem-detector:latest
args:
- start
- --listen=0.0.0.0:8444
ports:
- containerPort: 8444
name: metrics
name: vsphere-metrics
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 10m
memory: 100Mi
volumeMounts:
- mountPath: /var/run/secrets/serving-cert
name: vsphere-problem-detector-serving-cert
volumes:
- name: cluster-storage-operator-serving-cert
secret:
secretName: cluster-storage-operator-serving-cert
optional: true
- name: vsphere-problem-detector-serving-cert
secret:
secretName: vsphere-problem-detector-serving-cert
optional: true
File renamed without changes.