Skip to content

Commit

Permalink
Merge pull request #239 from vshn/redis_metrics_exported
Browse files Browse the repository at this point in the history
adding VSHNRedis ServiceMonitor to expose Redis metrics in Openshift
  • Loading branch information
wejdross authored Oct 10, 2023
2 parents 9600b70 + 08d6895 commit b5d7fdd
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
32 changes: 32 additions & 0 deletions component/component/vshn_redis.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@ local restoreRole = kube.ClusterRole(restoreRoleName) {
],
};

local helmMonitoringClusterRole = kube.ClusterRole('allow-helm-monitoring-resources') {
rules: [
{
apiGroups: [ 'monitoring.coreos.com' ],
resources: [ 'servicemonitors' ],
verbs: [ '*' ],
},
],
};
local helmMonitoringServiceAccount = kube.ServiceAccount('provider-helm') + {
metadata+: {
namespace: 'syn-crossplane',
},
};
local helmMonitoringClusterRoleBinding = kube.ClusterRoleBinding('system:serviceaccount:syn-crossplane:provider-helm') + {
roleRef_: helmMonitoringClusterRole,
subjects_: [ helmMonitoringServiceAccount ],
};

local restoreClusterRoleBinding = kube.ClusterRoleBinding('appcat:job:redis:restorejob') + {
roleRef_: restoreRole,
subjects_: [ restoreServiceAccount ],
Expand Down Expand Up @@ -377,6 +396,16 @@ local composition =
version: redisParams.helmChartVersion,
},
values: {
metrics: {
enabled: true,
containerSecurityContext: {
enabled: securityContext,
},
serviceMonitor: {
enabled: true,
namespace: '', // patched
},
},
fullnameOverride: 'redis',
global: {
imageRegistry: redisParams.imageRegistry,
Expand Down Expand Up @@ -613,6 +642,8 @@ local composition =
comp.FromCompositeFieldPath('spec.parameters.tls.enabled', 'spec.forProvider.values.tls.enabled'),
comp.FromCompositeFieldPath('spec.parameters.tls.authClients', 'spec.forProvider.values.tls.authClients'),

comp.FromCompositeFieldPathWithTransformPrefix('metadata.labels[crossplane.io/composite]', 'spec.forProvider.values.metrics.serviceMonitor.namespace', 'vshn-redis'),

comp.FromCompositeFieldPathWithTransformMap('spec.parameters.size.plan',
'spec.forProvider.values.master.nodeSelector',
std.mapWithKey(function(key, x)
Expand Down Expand Up @@ -691,6 +722,7 @@ if params.services.vshn.enabled && redisParams.enabled then {
'20_rbac_vshn_redis': xrds.CompositeClusterRoles(xrd),
'20_role_vshn_redisrestore': [ restoreRole, restoreServiceAccount, restoreClusterRoleBinding ],
'20_rbac_vshn_redis_resize': [ resizeClusterRole, resizeServiceAccount, resizeClusterRoleBinding ],
'20_rbac_vshn_redis_metrics_servicemonitor': [ helmMonitoringClusterRole, helmMonitoringClusterRoleBinding ],
'20_plans_vshn_redis': plansCM,
'21_composition_vshn_redis': composition,
'22_prom_rule_sla_redis': promRuleRedisSLA,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
name: allow-helm-monitoring-resources
name: allow-helm-monitoring-resources
rules:
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations: {}
labels:
name: system-serviceaccount-syn-crossplane-provider-helm
name: system:serviceaccount:syn-crossplane:provider-helm
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: allow-helm-monitoring-resources
subjects:
- kind: ServiceAccount
name: provider-helm
namespace: syn-crossplane
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,13 @@ spec:
requests:
cpu: ''
memory: ''
metrics:
containerSecurityContext:
enabled: true
enabled: true
serviceMonitor:
enabled: true
namespace: ''
networkPolicy:
allowExternal: false
enabled: true
Expand Down Expand Up @@ -837,6 +844,14 @@ spec:
- fromFieldPath: spec.parameters.tls.authClients
toFieldPath: spec.forProvider.values.tls.authClients
type: FromCompositeFieldPath
- fromFieldPath: metadata.labels[crossplane.io/composite]
toFieldPath: spec.forProvider.values.metrics.serviceMonitor.namespace
transforms:
- string:
fmt: vshn-redis-%s
type: Format
type: string
type: FromCompositeFieldPath
- fromFieldPath: spec.parameters.size.plan
toFieldPath: spec.forProvider.values.master.nodeSelector
transforms:
Expand Down

0 comments on commit b5d7fdd

Please sign in to comment.