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

SECURESIGN-842 | Operator's metrics are not consumed by OCP monitor #557

Merged
merged 2 commits into from
Aug 21, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ jobs:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=90s

- name: Install prometheus
run: |
LATEST=$(curl -s https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest | jq -cr .tag_name)
curl -sL https://github.com/prometheus-operator/prometheus-operator/releases/download/${LATEST}/bundle.yaml | kubectl create -f -
kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus-operator -n default

- name: Deploy operator container
env:
OPENSHIFT: false
Expand Down Expand Up @@ -247,6 +253,11 @@ jobs:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=90s

#install Prometheus
LATEST=$(curl -s https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest | jq -cr .tag_name)
curl -sL https://github.com/prometheus-operator/prometheus-operator/releases/download/${LATEST}/bundle.yaml | kubectl create -f -
kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=prometheus-operator -n default

#install OLM
kubectl create -f https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.25.0/crds.yaml
# wait for a while to be sure CRDs are installed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
control-plane: operator-controller-manager
name: rhtas-controller-manager-metrics-service
spec:
ports:
- name: metrics
port: 8080
targetPort: metrics
selector:
control-plane: operator-controller-manage
status:
loadBalancer: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app.kubernetes.io/component: metrics
app.kubernetes.io/created-by: rhtas-operator
app.kubernetes.io/instance: controller-manager-metrics-monitor
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: servicemonitor
app.kubernetes.io/part-of: rhtas-operator
control-plane: operator-controller-manager
name: rhtas-operator-controller-manager-metrics-monitor
spec:
endpoints:
- path: /metrics
port: metrics
selector:
matchLabels:
control-plane: operator-controller-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
control-plane: operator-controller-manager
name: rhtas-operator-controller-manager-metrics-service
spec:
ports:
- name: metrics
port: 8080
targetPort: metrics
selector:
control-plane: operator-controller-manager
status:
loadBalancer: {}
4 changes: 4 additions & 0 deletions bundle/manifests/rhtas-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ spec:
containers:
- args:
- --leader-elect
JasonPowr marked this conversation as resolved.
Show resolved Hide resolved
- --metrics-bind-address=0.0.0.0:8080
command:
- /manager
env:
Expand All @@ -868,6 +869,9 @@ spec:
initialDelaySeconds: 15
periodSeconds: 20
name: manager
ports:
- containerPort: 8080
name: metrics
readinessProbe:
httpGet:
path: /readyz
Expand Down
6 changes: 5 additions & 1 deletion config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ resources:
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
#- ../certmanager
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus
- ../prometheus

patches:
- path: manager_openshift_patch.yaml
target:
kind: Deployment
name: operator-controller-manager
- path: manager_metrics_patch.yaml
target:
kind: Deployment
name: operator-controller-manager
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
Expand Down
17 changes: 17 additions & 0 deletions config/default/manager_metrics_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This patch exposes metrics endpoint in plain HTTP 8080 port
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: operator-controller-manager
spec:
template:
spec:
containers:
- name: manager
args:
- "--leader-elect"
- "--metrics-bind-address=0.0.0.0:8080"
ports:
- containerPort: 8080
name: metrics
1 change: 1 addition & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
resources:
- manager.yaml
- metrics_service.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
Expand Down
13 changes: 13 additions & 0 deletions config/manager/metrics_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
control-plane: operator-controller-manager
name: operator-controller-manager-metrics-service
spec:
ports:
- name: metrics
port: 8080
targetPort: metrics
selector:
control-plane: operator-controller-manager
6 changes: 1 addition & 5 deletions config/prometheus/monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ metadata:
spec:
endpoints:
- path: /metrics
port: https
scheme: https
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
tlsConfig:
insecureSkipVerify: true
port: metrics
selector:
matchLabels:
control-plane: operator-controller-manager
Loading