Skip to content

Commit 1133f71

Browse files
Merge pull request #305 from clobrano/bundle-ocp-metrics-1
Add Prometheus configuration to bundle OCP
2 parents d2c4fb9 + df551f1 commit 1133f71

File tree

11 files changed

+174
-10
lines changed

11 files changed

+174
-10
lines changed

.github/workflows/pre-submit.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ jobs:
2626
- name: Build
2727
run: make manager
2828

29-
- name: Test
29+
- name: Verify no bundle changes and run unit-tests
3030
run: make manifests bundle-k8s bundle-reset test
3131

32-
- name: Test container build
33-
run: make container-build
32+
- name: Test container build K8s
33+
run: make container-build-k8s
34+
35+
- name: Test container build OCP
36+
run: make container-build-ocp
3437

3538
e2e-k8s:
3639
runs-on: ubuntu-22.04

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,15 @@ bundle-reset: ## Revert all version or build date related changes
427427
sed -r -i "/replaces:.*/d" ${CSV}
428428

429429
.PHONY: bundle-build-ocp
430-
bundle-build-ocp: bundle-ocp bundle-update ## Build the bundle image.
430+
bundle-build-ocp: bundle-ocp bundle-update ## Build the bundle image for OCP.
431431
podman build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
432432

433433
.PHONY: bundle-build-k8s
434434
bundle-build-k8s: bundle-k8s bundle-update ## Build the bundle image for k8s.
435435
podman build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
436436

437437
.PHONY: bundle-build-metrics
438-
bundle-build-metrics: bundle-metrics bundle-update ## Build the bundle image for k8s.
438+
bundle-build-metrics: bundle-metrics bundle-update ## Build the bundle image for K8s with metric related configuration
439439
podman build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
440440

441441
.PHONY: bundle-push
@@ -482,18 +482,19 @@ deploy-snr:
482482

483483
##@ Targets used by CI
484484

485-
.PHONY: container-build
486-
container-build: ## Build containers
485+
.PHONY: container-build-ocp
486+
container-build-ocp: ## Build containers for OCP
487487
make docker-build bundle-build-ocp
488488

489489
.PHONY: container-build-k8s
490-
container-build-k8s: ## Build containers
490+
container-build-k8s: ## Build containers for K8s
491491
make docker-build bundle-build-k8s
492492

493493
.PHONY: container-build-metrics
494-
container-build-metrics: ## Build containers
494+
container-build-metrics: ## Build containers for K8s with metric related configuration
495495
make docker-build bundle-build-metrics
496496

497+
497498
.PHONY: container-push
498499
container-push: ## Push containers (NOTE: catalog can't be build before bundle was pushed)
499500
make docker-push bundle-push index-build index-push
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app.kubernetes.io/component: controller-manager
6+
app.kubernetes.io/instance: metrics
7+
annotations:
8+
service.beta.openshift.io/serving-cert-secret-name: node-healthcheck-tls
9+
name: controller-manager-metrics-service
10+
namespace: system
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: controller-manager
5+
namespace: system
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
- name: kube-rbac-proxy
11+
args:
12+
- "--secure-listen-address=0.0.0.0:8443"
13+
- "--http2-disable"
14+
- "--upstream=http://127.0.0.1:8080/"
15+
- "--logtostderr=true"
16+
- "--v=10"
17+
- "--tls-cert-file=/etc/tls/private/tls.crt"
18+
- "--tls-private-key-file=/etc/tls/private/tls.key"
19+
volumeMounts:
20+
- name: tls-config
21+
mountPath: /etc/tls/private
22+
readOnly: true
23+
volumes:
24+
- name: tls-config
25+
secret:
26+
secretName: node-healthcheck-tls
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
14
resources:
25
- ../base
36
- ../../optional/console-plugin
7+
- ../../optional/prometheus-ocp
48

59
patches:
610
- path: clusterserviceversion_patch.yaml
711
target:
812
kind: ClusterServiceVersion
13+
- path: deployment_patch.yaml
14+
target:
15+
kind: Deployment
16+
name: controller-manager
17+
- path: auth_proxy_service_patch.yaml
18+
target:
19+
kind: Service
20+
name: controller-manager-metrics-service
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: ca-bundle
5+
namespace: system
6+
annotations:
7+
service.beta.openshift.io/inject-cabundle: "true"
8+
data: {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
resources:
5+
- ca-configmap.yaml
6+
7+
components:
8+
- ../../patches/common
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
# Prometheus Monitor Service (Metrics)
3+
apiVersion: monitoring.coreos.com/v1
4+
kind: ServiceMonitor
5+
metadata:
6+
labels:
7+
app.kubernetes.io/component: controller-manager
8+
name: node-healthcheck-controller-manager-metrics-monitor
9+
namespace: system
10+
spec:
11+
endpoints:
12+
- interval: 5s
13+
port: https
14+
scheme: https
15+
authorization:
16+
type: Bearer
17+
credentials:
18+
name: prometheus-user-workload-token
19+
key: token
20+
tlsConfig:
21+
ca:
22+
configMap:
23+
name: node-healthcheck-ca-bundle
24+
key: service-ca.crt
25+
serverName: node-healthcheck-controller-manager-metrics-service.system.svc
26+
selector:
27+
matchLabels:
28+
app.kubernetes.io/component: controller-manager
29+
app.kubernetes.io/name: node-healthcheck-operator
30+
app.kubernetes.io/instance: metrics
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# User Workload Prometheus configuration
2+
3+
Use the following steps to create a bundle predisposed for OpenShift User Workload Prometheus (UWP) Monitoring [1].
4+
5+
1. Configure the Monitoring stack, if not already done [2]
6+
2. Enable monitoring for user-defined projects [3]
7+
3. Ensure NHC bundle with monitoring supported (>= v0.8.0) is installed [4]
8+
4. Once the bundle is installed, create a new UWP token Secret from an existing `prometheus-user-workload-token` Secret
9+
10+
IMPORTANT NOTE: use the operator's namespace (e.g. `openshift-workload-availability`).
11+
12+
```bash
13+
# Get the existing prometheus-user-workload-token Secret
14+
existingPrometheusTokenSecret=$(kubectl get secret --namespace openshift-user-workload-monitoring | grep prometheus-user-workload-token | awk '{print $1}')
15+
16+
# Create a new Secret in the operator's namespace
17+
kubectl get secret ${existingPrometheusTokenSecret} --namespace=openshift-user-workload-monitoring -o yaml | \
18+
sed '/namespace: .*==/d;/ca.crt:/d;/serviceCa.crt/d;/creationTimestamp:/d;/resourceVersion:/d;/uid:/d;/annotations/d;/kubernetes.io/d;' | \
19+
sed 's/namespace: .*/namespace: openshift-workload-availability/' | \
20+
sed 's/name: .*/name: prometheus-user-workload-token/' | \
21+
sed 's/type: .*/type: Opaque/' | \
22+
> prom-token.yaml
23+
24+
kubectl apply -f prom-token.yaml
25+
```
26+
27+
5. Create a new ServiceMonitor from `config/optional/prometheus-ocp/monitor.yaml` in the operator's namespace (e.g. `openshift-workload-availability`)
28+
29+
```bash
30+
sed -i 's/system/openshift-workload-availability/g' monitor.yaml
31+
kubectl apply -f monitor.yaml
32+
```
33+
34+
[1]: https://docs.openshift.com/container-platform/4.15/monitoring/enabling-monitoring-for-user-defined-projects.html
35+
[2]: https://docs.openshift.com/container-platform/4.15/monitoring/configuring-the-monitoring-stack.html
36+
[3]: https://docs.openshift.com/container-platform/4.15/monitoring/enabling-monitoring-for-user-defined-projects.html#enabling-monitoring-for-user-defined-projects_enabling-monitoring-for-user-defined-projects
37+
[4]: for testing purposes, you can build the bundle with `hack/ocp/test_create_bundle_ocp_image_in_quay.sh`

config/optional/prometheus/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ resources:
55
- monitor.yaml
66

77
components:
8-
- ../../patches/common
8+
- ../../patches/common

0 commit comments

Comments
 (0)