1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/monitoring-deploying-a-sample-service.adoc
2022-06-01 14:26:30 +00:00

88 lines
1.9 KiB
Plaintext

// Module included in the following assemblies:
//
// * monitoring/managing-metrics.adoc
:_content-type: PROCEDURE
[id="deploying-a-sample-service_{context}"]
= Deploying a sample service
To test monitoring of a service in a user-defined project, you can deploy a sample service.
.Procedure
. Create a YAML file for the service configuration. In this example, it is called `prometheus-example-app.yaml`.
. Add the following deployment and service configuration details to the file:
+
[source,yaml]
----
apiVersion: v1
kind: Namespace
metadata:
name: ns1
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: prometheus-example-app
name: prometheus-example-app
namespace: ns1
spec:
replicas: 1
selector:
matchLabels:
app: prometheus-example-app
template:
metadata:
labels:
app: prometheus-example-app
spec:
containers:
- image: ghcr.io/rhobs/prometheus-example-app:0.4.1
imagePullPolicy: IfNotPresent
name: prometheus-example-app
---
apiVersion: v1
kind: Service
metadata:
labels:
app: prometheus-example-app
name: prometheus-example-app
namespace: ns1
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
name: web
selector:
app: prometheus-example-app
type: ClusterIP
----
+
This configuration deploys a service named `prometheus-example-app` in the user-defined `ns1` project. This service exposes the custom `version` metric.
. Apply the configuration to the cluster:
+
[source,terminal]
----
$ oc apply -f prometheus-example-app.yaml
----
+
It takes some time to deploy the service.
. You can check that the pod is running:
+
[source,terminal]
----
$ oc -n ns1 get pod
----
+
.Example output
[source,terminal]
----
NAME READY STATUS RESTARTS AGE
prometheus-example-app-7857545cb7-sbgwq 1/1 Running 0 81m
----