Skip to content

Commit e04cfc0

Browse files
package-server-manager: add a PodMonitor, expose metrics
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 08aa6dd commit e04cfc0

6 files changed

+75
-1
lines changed

Diff for: cmd/package-server-manager/main.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func run(cmd *cobra.Command, args []string) error {
6262
if err != nil {
6363
return err
6464
}
65+
metricsAddr, err := cmd.Flags().GetString("metrics")
66+
if err != nil {
67+
return err
68+
}
6569

6670
ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
6771
setupLog := ctrl.Log.WithName("setup")
@@ -73,7 +77,7 @@ func run(cmd *cobra.Command, args []string) error {
7377
mgr, err := ctrl.NewManager(restConfig, manager.Options{
7478
Scheme: setupScheme(),
7579
Namespace: namespace,
76-
MetricsBindAddress: defaultMetricsPort,
80+
MetricsBindAddress: metricsAddr,
7781
LeaderElection: !disableLeaderElection,
7882
LeaderElectionNamespace: namespace,
7983
LeaderElectionID: leaderElectionConfigmapName,

Diff for: cmd/package-server-manager/start.go

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func newStartCmd() *cobra.Command {
1616
cmd.Flags().String("namespace", defaultNamespace, "configures the metadata.namespace that contains the packageserver csv resource")
1717
cmd.Flags().String("health", defaultHealthCheckPort, "configures the health check port that the kubelet is configured to probe")
1818
cmd.Flags().String("pprof", defaultPprofPort, "configures the pprof port that the process exposes")
19+
cmd.Flags().String("metrics", defaultMetricsPort, "configures the metrics port that the process exposes")
1920
cmd.Flags().Bool("disable-leader-election", false, "configures whether leader election will be disabled")
2021

2122
return cmd

Diff for: manifests/0000_50_olm_06-psm-operator.deployment.ibm-cloud-managed.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ spec:
4141
- $(PACKAGESERVER_NAME)
4242
- --namespace
4343
- $(PACKAGESERVER_NAMESPACE)
44+
- "--metrics=:9090"
4445
image: quay.io/operator-framework/olm@sha256:de396b540b82219812061d0d753440d5655250c621c753ed1dc67d6154741607
4546
imagePullPolicy: IfNotPresent
47+
ports:
48+
- containerPort: 9090
49+
name: metrics
4650
env:
4751
- name: PACKAGESERVER_NAME
4852
value: packageserver

Diff for: manifests/0000_50_olm_06-psm-operator.deployment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@ spec:
4141
- $(PACKAGESERVER_NAME)
4242
- --namespace
4343
- $(PACKAGESERVER_NAMESPACE)
44+
- "--metrics=:9090"
4445
image: quay.io/operator-framework/olm@sha256:de396b540b82219812061d0d753440d5655250c621c753ed1dc67d6154741607
4546
imagePullPolicy: IfNotPresent
47+
ports:
48+
- containerPort: 9090
49+
name: metrics
4650
env:
4751
- name: PACKAGESERVER_NAME
4852
value: packageserver

Diff for: manifests/0000_90_olm_00-pod-monitor.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: PodMonitor
3+
metadata:
4+
name: package-server-manager
5+
namespace: openshift-operator-lifecycle-manager
6+
labels:
7+
app: package-server-manager
8+
annotations:
9+
include.release.openshift.io/ibm-cloud-managed: "true"
10+
include.release.openshift.io/self-managed-high-availability: "true"
11+
spec:
12+
podMetricsEndpoints:
13+
- name: metrics
14+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
15+
interval: 30s
16+
metricRelabelings:
17+
- action: drop
18+
regex: etcd_(debugging|disk|request|server).*
19+
sourceLabels:
20+
- __name__
21+
jobLabel: component
22+
namespaceSelector:
23+
matchNames:
24+
- openshift-operator-lifecycle-manager
25+
selector:
26+
matchLabels:
27+
app: package-server-manager

Diff for: scripts/generate_crds_manifests.sh

+34
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ spec:
151151
- \$(PACKAGESERVER_NAME)
152152
- --namespace
153153
- \$(PACKAGESERVER_NAMESPACE)
154+
- "--metrics=:9090"
154155
image: quay.io/operator-framework/olm@sha256:de396b540b82219812061d0d753440d5655250c621c753ed1dc67d6154741607
155156
imagePullPolicy: IfNotPresent
157+
ports:
158+
- containerPort: 9090
159+
name: metrics
156160
env:
157161
- name: PACKAGESERVER_NAME
158162
value: packageserver
@@ -402,6 +406,36 @@ subjects:
402406
name: system:authenticated
403407
EOF
404408

409+
cat <<EOF > manifests/0000_90_olm_00-pod-monitor.yaml
410+
apiVersion: monitoring.coreos.com/v1
411+
kind: PodMonitor
412+
metadata:
413+
name: package-server-manager
414+
namespace: openshift-operator-lifecycle-manager
415+
labels:
416+
app: package-server-manager
417+
annotations:
418+
include.release.openshift.io/ibm-cloud-managed: "true"
419+
include.release.openshift.io/self-managed-high-availability: "true"
420+
spec:
421+
podMetricsEndpoints:
422+
- name: metrics
423+
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
424+
interval: 30s
425+
metricRelabelings:
426+
- action: drop
427+
regex: etcd_(debugging|disk|request|server).*
428+
sourceLabels:
429+
- __name__
430+
jobLabel: component
431+
namespaceSelector:
432+
matchNames:
433+
- openshift-operator-lifecycle-manager
434+
selector:
435+
matchLabels:
436+
app: package-server-manager
437+
EOF
438+
405439
add_ibm_managed_cloud_annotations "${ROOT_DIR}/manifests"
406440

407441
find "${ROOT_DIR}/manifests" -type f -exec $SED -i "/^#/d" {} \;

0 commit comments

Comments
 (0)