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

Adding monitoring orchestration in the operator to collect metrics for Telemetry. #932

Merged
merged 7 commits into from
Jul 1, 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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
liranr23 marked this conversation as resolved.
Show resolved Hide resolved
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
Expand Down Expand Up @@ -90,6 +90,7 @@ require (
github.com/openshift/custom-resource-status v1.1.2 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
Expand Down Expand Up @@ -248,8 +249,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA=
github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down
5 changes: 5 additions & 0 deletions operator/config/rbac/leader_election_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rules:
- events
- configmaps
- secrets
- namespaces
verbs:
- '*'
- apiGroups:
Expand All @@ -39,6 +40,10 @@ rules:
verbs:
- get
- create
- update
- patch
- list
- watch
- apiGroups:
- apps.openshift.io
resources:
Expand Down
7 changes: 7 additions & 0 deletions operator/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- ''
resources:
- namespaces
verbs:
- list
- watch
- apiGroups:
- config.openshift.io
resources:
Expand Down
6 changes: 6 additions & 0 deletions operator/roles/forkliftcontroller/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,9 @@ virt_v2v_dont_request_kvm: "{{ lookup( 'env', 'VIRT_V2V_DONT_REQUEST_KVM') }}"
virt_v2v_extra_args: "{{ lookup( 'env', 'VIRT_V2V_EXTRA_ARGS') }}"

ova_provider_server_fqin: "{{ lookup( 'env', 'OVA_PROVIDER_SERVER_IMAGE') or lookup( 'env', 'RELATED_IMAGE_OVA_PROVIDER_SERVER') }}"

metric_service_name: "{{ app_name }}-metrics"
metric_servicemonitor_name: "{{ app_name }}-metrics"
metric_interval: "30s"
metric_port_name: "metrics"

23 changes: 23 additions & 0 deletions operator/roles/forkliftcontroller/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,29 @@
definition: "{{ lookup('template', 'controller/controller-scc.yml.j2') }}"
when: not k8s_cluster|bool

- when: not k8s_cluster|bool
block:
- name: "Setup metrics service"
k8s:
state: present
definition: "{{ lookup('template', 'monitor/service-metrics.yml.j2') }}"

- name: "Setup metrics service monitor"
k8s:
state: present
definition: "{{ lookup('template', 'monitor/servicemonitor-metrics.yml.j2') }}"

- name: "Add monitoring label to namespace"
k8s:
state: present
definition:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ app_namespace }}"
labels:
openshift.io/cluster-monitoring: "true"

- when: feature_volume_populator|bool
block:
- name: "Setup populator controller deployment"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spec:
app: {{ app_name }}
control-plane: controller-manager
controller-tools.k8s.io: "1.0"
prometheus.forklift.konveyor.io: "true"
annotations:
configHash: "{{ (inventory_volume_path | string) }}"
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: v1
kind: Service
metadata:
labels:
app: {{ app_name }}
service: {{ metric_service_name }}
prometheus.forklift.konveyor.io: "true"
control-plane: controller-manager
controller-tools.k8s.io: "1.0"
name: {{ metric_service_name }}
namespace: {{ app_namespace }}
spec:
ports:
- name: {{ metric_port_name }}
port: 2112
targetPort: 2112
protocol: TCP
selector:
app: {{ app_name }}
prometheus.forklift.konveyor.io: "true"
controller-tools.k8s.io: "1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ metric_servicemonitor_name }}
namespace: {{ app_namespace }}
labels:
app: {{ app_name }}
prometheus.forklift.konveyor.io: "true"
control-plane: controller-manager
spec:
endpoints:
- interval: {{ metric_interval }}
port: {{ metric_port_name }}
namespaceSelector:
matchNames:
- {{ app_namespace }}
selector:
matchLabels:
app: {{ app_name }}
prometheus.forklift.konveyor.io: "true"
4 changes: 3 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ github.com/cespare/xxhash/v2
# github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311
## explicit; go 1.15
github.com/chenzhuoyu/base64x
# github.com/davecgh/go-spew v1.1.1
# github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
## explicit
github.com/davecgh/go-spew/spew
# github.com/emicklei/go-restful/v3 v3.11.0
Expand Down Expand Up @@ -350,6 +350,8 @@ github.com/pkg/errors
# github.com/pkg/profile v1.7.0
## explicit; go 1.13
github.com/pkg/profile
# github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
## explicit
# github.com/prometheus/client_golang v1.17.0
## explicit; go 1.19
github.com/prometheus/client_golang/prometheus
Expand Down
Loading