Skip to content

Commit

Permalink
Add monitor resources creation to forklift operator
Browse files Browse the repository at this point in the history
Signed-off-by: Bella Khizgiyaev <[email protected]>
  • Loading branch information
bkhizgiy committed Jul 1, 2024
1 parent 0f92c03 commit 28a704f
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
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
5 changes: 5 additions & 0 deletions operator/roles/forkliftcontroller/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,8 @@ virt_v2v_warm_image_fqin: "{{ lookup( 'env', 'VIRT_V2V_WARM_IMAGE') or lookup( '
virt_v2v_dont_request_kvm: "{{ lookup( 'env', 'VIRT_V2V_DONT_REQUEST_KVM') }}"

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"

0 comments on commit 28a704f

Please sign in to comment.