Skip to content

Commit

Permalink
Merge pull request #8 from runitmisra/6_operations_service
Browse files Browse the repository at this point in the history
Added servicemonitor, metrics support and operations svc
  • Loading branch information
tittuvarghese authored Oct 24, 2023
2 parents b7d5035 + 7cf16fe commit 0e7f14b
Show file tree
Hide file tree
Showing 11 changed files with 331 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
**/.DS_Store
**/.DS_Store

# VSCode local workspace configurations
.vscode
40 changes: 40 additions & 0 deletions examples/fabric-orderer/orderer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,46 @@ global:
dataStorageSize: "10Gi"
certStorageSize: "50M"
storageClass: standard

## Configuration for the Operations Service: https://hyperledger-fabric.readthedocs.io/en/latest/operations_service.html
operations:
serviceName: operations
serviceType: ClusterIP
servicePort: 8443

metrics:
## Select metrics provider. Possible values are "prometheus", "statsd" or "disabled"
provider: prometheus

## Only applicable if provider is "prometheus"
## A serviceMonitor will be created for each peer with the configuration provided below
serviceMonitor:
enabled: true
additionalLabels: {}
namespace: ""

## This should be equal to the operations port name
portName: operations
scrapeInterval: 30s
honorLabels: true
relabelings: []
metricRelabelings: []

## Default: scrape .Release.Namespace only
## To scrape all, use the following:
## namespaceSelector:
## any: true
namespaceSelector:
any: true
targetLabels: []

## Configuration for statsd provider
## Statsd prefix will be the peer identity name
statsd:
network: udp
address: 127.0.0.1:8125
writeInterval: 10s

env:
- name: FABRIC_LOGGING_SPEC
value: INFO
Expand Down
45 changes: 41 additions & 4 deletions examples/fabric-peer/initialpeerorg/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,46 @@ global:
imagePullPolicy: Always
serviceAccount:
annotations: []


## Configuration for the Operations Service: https://hyperledger-fabric.readthedocs.io/en/latest/operations_service.html
operations:
serviceName: operations
serviceType: ClusterIP
servicePort: 9443

metrics:
## Select metrics provider. Possible values are "prometheus", "statsd" or "disabled"
provider: disabled

## Only applicable if provider is "prometheus"
## A serviceMonitor will be created for each peer with the configuration provided below
serviceMonitor:
enabled: false
additionalLabels: {}
namespace: ""

## This should be equal to the operations port name
portName: operations
scrapeInterval: 30s
honorLabels: true
relabelings: []
metricRelabelings: []

## Default: scrape .Release.Namespace only
## To scrape all, use the following:
## namespaceSelector:
## any: true
namespaceSelector:
any: true
targetLabels: []

## Configuration for statsd provider
## Statsd prefix will be the peer identity name
statsd:
network: udp
address: 127.0.0.1:8125
writeInterval: 10s

useCouchDB: true
couchImageRegistry: docker.io
couchImageRepo: couchdb
Expand Down Expand Up @@ -173,6 +212,4 @@ additonalEnvironmentVars:
- name: CORE_VM_ENDPOINT
value: http://localhost:2375
- name: DOCKER_HOST
value: tcp://localhost:2375
- name: CORE_OPERATIONS_LISTENADDRESS
value: 0.0.0.0:9443
value: tcp://localhost:2375
39 changes: 39 additions & 0 deletions examples/fabric-peer/org1/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,45 @@ global:
imagePullPolicy: Always
serviceAccount:
annotations: []

## Configuration for the Operations Service: https://hyperledger-fabric.readthedocs.io/en/latest/operations_service.html
operations:
serviceName: operations
serviceType: ClusterIP
servicePort: 9443

metrics:
## Select metrics provider. Possible values are "prometheus", "statsd" or "disabled"
provider: disabled

## Only applicable if provider is "prometheus"
## A serviceMonitor will be created for each peer with the configuration provided below
serviceMonitor:
enabled: false
additionalLabels: {}
namespace: ""

## This should be equal to the operations port name
portName: operations
scrapeInterval: 30s
honorLabels: true
relabelings: []
metricRelabelings: []

## Default: scrape .Release.Namespace only
## To scrape all, use the following:
## namespaceSelector:
## any: true
namespaceSelector:
any: true
targetLabels: []

## Configuration for statsd provider
## Statsd prefix will be the peer identity name
statsd:
network: udp
address: 127.0.0.1:8125
writeInterval: 10s

useCouchDB: true
couchImageRegistry: docker.io
Expand Down
41 changes: 40 additions & 1 deletion examples/fabric-peer/org2/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,46 @@ global:
imagePullPolicy: Always
serviceAccount:
annotations: []


## Configuration for the Operations Service: https://hyperledger-fabric.readthedocs.io/en/latest/operations_service.html
operations:
serviceName: operations
serviceType: ClusterIP
servicePort: 9443

metrics:
## Select metrics provider. Possible values are "prometheus", "statsd" or "disabled"
provider: disabled

## Only applicable if provider is "prometheus"
## A serviceMonitor will be created for each peer with the configuration provided below
serviceMonitor:
enabled: false
additionalLabels: {}
namespace: ""

## This should be equal to the operations port name
portName: operations
scrapeInterval: 30s
honorLabels: true
relabelings: []
metricRelabelings: []

## Default: scrape .Release.Namespace only
## To scrape all, use the following:
## namespaceSelector:
## any: true
namespaceSelector:
any: true
targetLabels: []

## Configuration for statsd provider
## Statsd prefix will be the peer identity name
statsd:
network: udp
address: 127.0.0.1:8125
writeInterval: 10s

useCouchDB: true
couchImageRegistry: docker.io
couchImageRepo: couchdb
Expand Down
16 changes: 16 additions & 0 deletions helm-charts/fabric-orderer/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,23 @@ spec:
args:
- orderer
env:
- name: ORDERER_OPERATIONS_LISTENADDRESS
value: 0.0.0.0:8443
{{- tpl (toYaml $.Values.global.env) $ | nindent 12 }}
- name: ORDERER_METRICS_PROVIDER
{{- if eq "prometheus" $.Values.global.metrics.provider }}
value: "prometheus"
{{- else if eq "statsd" $.Values.global.metrics.provider }}
value: "statsd"
- name: ORDERER_METRICS_STATSD_NETWORK
value: {{ $.Values.global.metrics.statsd.network }}
- name: ORDERER_METRICS_STATSD_ADDRESS
value: {{ $.Values.global.metrics.statsd.address }}
- name: ORDERER_METRICS_STATSD_WRITEINTERVAL
value: {{ $.Values.global.metrics.statsd.writeInterval }}
{{- else }}
value: "disabled"
{{- end }}
ports:
- name: http
containerPort: {{ $.Values.global.containerPort }}
Expand Down
19 changes: 19 additions & 0 deletions helm-charts/fabric-orderer/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@ spec:
selector:
{{- include "fabric-orderer.selectorLabels" $ | nindent 4 }}
app: {{ .name }}-{{ include "fabric-orderer.fullname" $ }}
---
apiVersion: v1
kind: Service
metadata:
name: operations-{{ .name }}-{{ include "fabric-orderer.fullname" $ }}
labels:
orderer: {{ .identity_name }}
{{- include "fabric-orderer.labels" $ | nindent 4 }}
app: {{ .name }}-{{ include "fabric-orderer.fullname" $ }}
spec:
type: ClusterIP
ports:
- port: {{ $.Values.global.operations.servicePort }}
targetPort: 8443
protocol: TCP
name: {{ $.Values.global.operations.serviceName }}
selector:
{{- include "fabric-orderer.selectorLabels" $ | nindent 4 }}
app: {{ .name }}-{{ include "fabric-orderer.fullname" $ }}
{{- end }}
48 changes: 48 additions & 0 deletions helm-charts/fabric-orderer/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if and (eq "prometheus" $.Values.global.metrics.provider) $.Values.global.metrics.serviceMonitor.enabled }}
{{- range .Values.orderers }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ .name }}-{{ include "fabric-orderer.name" $ }}
labels:
orderer: {{ .identity_name }}
{{- include "fabric-orderer.labels" $ | nindent 4 }}
{{- if $.Values.global.metrics.serviceMonitor.additionalLabels }}
{{- toYaml $.Values.global.metrics.serviceMonitor.additionalLabels | nindent 4 }}
{{- end }}
{{- if $.Values.global.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.global.metrics.serviceMonitor.namespace | quote }}
{{- end }}
spec:
endpoints:
- port: {{ $.Values.global.metrics.serviceMonitor.portName }}
interval: {{ $.Values.global.metrics.serviceMonitor.scrapeInterval }}
{{- if $.Values.global.metrics.serviceMonitor.honorLabels }}
honorLabels: true
{{- end }}
{{- if $.Values.global.metrics.serviceMonitor.relabelings }}
relabelings: {{ toYaml $.Values.global.metrics.serviceMonitor.relabelings | nindent 8 }}
{{- end }}
{{- if $.Values.global.metrics.serviceMonitor.metricRelabelings }}
metricRelabelings: {{ toYaml $.Values.global.metrics.serviceMonitor.metricRelabelings | nindent 8 }}
{{- end }}
jobLabel: {{ .identity_name }}
{{- if $.Values.global.metrics.serviceMonitor.namespaceSelector }}
namespaceSelector: {{ toYaml $.Values.global.metrics.serviceMonitor.namespaceSelector | nindent 4 }}
{{- else }}
namespaceSelector:
matchNames:
- {{ $.Release.Namespace }}
{{- end }}
{{- if $.Values.global.metrics.serviceMonitor.targetLabels }}
targetLabels:
{{- range $.Values.global.metrics.serviceMonitor.targetLabels }}
- {{ $ }}
{{- end }}
{{- end }}
selector:
matchLabels:
orderer: {{ .identity_name }}
{{- end }}
{{- end }}
22 changes: 18 additions & 4 deletions helm-charts/fabric-peer/templates/peer-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ spec:
port: {{ .peerServicePort | default $.Values.global.peerServicePort }}
targetPort: 7051
protocol: TCP
- name: health
port: 9443
targetPort: 9443
protocol: TCP
selector:
app: {{ .name }}-{{ include "fabric-peer.name" $ }}
{{- include "fabric-peer.selectorLabels" $ | nindent 4 }}
Expand All @@ -47,4 +43,22 @@ spec:
app: {{ .name }}-{{ include "fabric-peer.name" $ }}
{{- include "fabric-peer.selectorLabels" $ | nindent 4 }}
{{- end }}
---
apiVersion: v1
kind: Service
metadata:
name: operations-{{ .name }}-{{ include "fabric-peer.name" $ }}
labels:
peer: {{ .identity_name }}
{{- include "fabric-peer.labels" $ | nindent 4 }}
spec:
type: {{ .operationsServiceType | default $.Values.global.operations.serviceType }}
ports:
- name: {{ .operationsServiceName | default $.Values.global.operations.serviceName }}
port: {{ .operationsServicePort | default $.Values.global.operations.servicePort }}
targetPort: 9443
protocol: TCP
selector:
app: {{ .name }}-{{ include "fabric-peer.name" $ }}
{{- include "fabric-peer.selectorLabels" $ | nindent 4 }}
{{- end }}
18 changes: 18 additions & 0 deletions helm-charts/fabric-peer/templates/peer-sts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,24 @@ spec:
- name: CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS
value: {{ .core_ledger_state_couchdbconfig_couchdbaddress | default $.Values.global.core_ledger_state_couchdbconfig_couchdbaddress | quote }}
{{- end }}
- name: CORE_OPERATIONS_LISTENADDRESS
value: 0.0.0.0:9443
- name: CORE_METRICS_PROVIDER
{{- if eq "prometheus" $.Values.global.metrics.provider }}
value: "prometheus"
{{- else if eq "statsd" $.Values.global.metrics.provider }}
value: "statsd"
- name: CORE_METRICS_STATSD_NETWORK
value: {{ $.Values.global.metrics.statsd.network }}
- name: CORE_METRICS_STATSD_ADDRESS
value: {{ $.Values.global.metrics.statsd.address }}
- name: CORE_METRICS_STATSD_WRITEINTERVAL
value: {{ $.Values.global.metrics.statsd.writeInterval }}
- name: CORE_METRICS_STATSD_PREFIX
value: {{ .identity_name }}
{{- else }}
value: "disabled"
{{- end }}
{{- if $.Values.additonalEnvironmentVars.peer }}
{{- tpl (toYaml $.Values.additonalEnvironmentVars.peer) $ | nindent 12 }}
{{- end }}
Expand Down
Loading

0 comments on commit 0e7f14b

Please sign in to comment.