Skip to content

Commit

Permalink
registration-service: new Service to /metrics (#1051)
Browse files Browse the repository at this point in the history
new k8s Service to scrape the HTTP metrics from the registration
service, but without exposing them to the current Route
(the metrics will be exposed in a separate port in the
registration service pods)

see codeready-toolchain/registration-service#436

---------

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Jul 2, 2024
1 parent 9bd7110 commit f282cde
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestReconcile(t *testing.T) {
Exists().
HasConditions(
toolchainconfig.ToSyncComplete(),
toolchainconfig.ToRegServiceDeploying("updated resources: [ServiceAccount: registration-service Role: registration-service RoleBinding: registration-service Deployment: registration-service Service: registration-service Route: registration-service Service: api Route: api Service: proxy-metrics-service]")).
toolchainconfig.ToRegServiceDeploying("updated resources: [ServiceAccount: registration-service Role: registration-service RoleBinding: registration-service Deployment: registration-service Route: registration-service Service: registration-service Service: regsvc-metrics Route: api Service: api Service: proxy-metrics-service]")).
HasNoSyncErrors()

// check member1 config
Expand Down Expand Up @@ -274,7 +274,7 @@ func TestReconcile(t *testing.T) {
Exists().
HasConditions(
toolchainconfig.ToSyncFailure(),
toolchainconfig.ToRegServiceDeploying("updated resources: [ServiceAccount: registration-service Role: registration-service RoleBinding: registration-service Deployment: registration-service Service: registration-service Route: registration-service Service: api Route: api Service: proxy-metrics-service]")).
toolchainconfig.ToRegServiceDeploying("updated resources: [ServiceAccount: registration-service Role: registration-service RoleBinding: registration-service Deployment: registration-service Route: registration-service Service: registration-service Service: regsvc-metrics Route: api Service: api Service: proxy-metrics-service]")).
HasSyncErrors(map[string]string{"missing-member": "specific member configuration exists but no matching toolchaincluster was found"})
})
})
Expand Down
81 changes: 56 additions & 25 deletions deploy/registration-service/registration-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ objects:
- name: registration-service
image: ${IMAGE}
ports:
- containerPort: 8080
- containerPort: 8081
- containerPort: 8082
- containerPort: 8080 # registration service
- containerPort: 8081 # proxy
- containerPort: 8082 # proxy metrics
name: metrics
- containerPort: 8083 # registration service metrics
name: regsvc-metrics
command:
- registration-service
imagePullPolicy: IfNotPresent
Expand Down Expand Up @@ -140,24 +142,8 @@ objects:
requests:
cpu: "50m"
memory: "100M"
- kind: Service
apiVersion: v1
metadata:
name: registration-service
namespace: ${NAMESPACE}
labels:
provider: codeready-toolchain
run: registration-service
spec:
ports:
- name: "8080"
protocol: TCP
port: 80
targetPort: 8080
selector:
run: registration-service
type: ClusterIP
sessionAffinity: null

# route for the registration service
- kind: Route
apiVersion: v1
metadata:
Expand All @@ -177,24 +163,48 @@ objects:
tls:
termination: edge
wildcardPolicy: None

# service associated with the registration service route
- kind: Service
apiVersion: v1
metadata:
name: api
name: registration-service
namespace: ${NAMESPACE}
labels:
provider: codeready-toolchain
run: registration-service
spec:
ports:
- name: "8081"
- name: "8080"
protocol: TCP
port: 80
targetPort: 8081
targetPort: 8080
selector:
run: registration-service
type: ClusterIP
sessionAffinity: null

# internal service for the registration service, used by Prometheus to scrape the metrics
- kind: Service
apiVersion: v1
metadata:
name: regsvc-metrics
namespace: ${NAMESPACE}
labels:
provider: codeready-toolchain
run: registration-service
spec:
ports:
- name: regsvc-metrics
protocol: TCP
port: 80
targetPort: regsvc-metrics
selector:
run: registration-service
type: ClusterIP
sessionAffinity: null

# route for the proxy
- kind: Route
apiVersion: v1
metadata:
Expand All @@ -206,7 +216,6 @@ objects:
name: api
namespace: ${NAMESPACE}
spec:
host: ''
port:
targetPort: "8081"
to:
Expand All @@ -216,6 +225,28 @@ objects:
tls:
termination: edge
wildcardPolicy: None

# service associated with the proxy route
- kind: Service
apiVersion: v1
metadata:
name: api
namespace: ${NAMESPACE}
labels:
provider: codeready-toolchain
run: registration-service
spec:
ports:
- name: "8081"
protocol: TCP
port: 80
targetPort: 8081
selector:
run: registration-service
type: ClusterIP
sessionAffinity: null

# internal service for the proxy, used by Prometheus to scrape the metrics
- kind: Service
apiVersion: v1
metadata:
Expand Down

0 comments on commit f282cde

Please sign in to comment.