Skip to content

Commit

Permalink
Merge pull request #19 from yadneshk/ocp_deploy
Browse files Browse the repository at this point in the history
Add manifests to deploy Metricly on top of OpenShift
  • Loading branch information
yadneshk authored Dec 4, 2024
2 parents 75c74a5 + 9d2f624 commit 97a3176
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
- **Podman** (for containerized deployment)
- **Prometheus** (for metrics scraping)

---

### **Installation**

Expand Down Expand Up @@ -149,6 +148,20 @@ localhost/metricly:latest

Prebuilt images with latest commits are pushed to [Quay](https://quay.io/repository/yadneshk/metricly?tab=tags).

**Deploy on OpenShift**
```bash
oc new-project monitoring
oc create -f manifests/metricly/security-ctx-constraint.yml
oc create -f manifests/metricly/service-account.yml
oc adm policy add-scc-to-user metricly -z metricly -n monitoring
oc create -f manifests/metricly/config-map.yml
oc create -f manifests/metricly/daemonset.yml
oc create -f manifests/metricly/service.yml
oc expose svc metricly
```
> [!NOTE]
Currently these steps only deploy Metricly, it doesn't prepare any resources for alerts or data visualizations.

---

### **Metrics Exposed**
Expand Down Expand Up @@ -371,7 +384,8 @@ The Metricly exporter provides the following API endpoints:
]
}
}
```
```
---

### **Alertmanager Configuration** ###
Metricly provides a few inbuilt alerts to monitor high utilization of CPU, Memory and Disk usage.
Expand All @@ -384,6 +398,8 @@ Upon meeting condition for any alert, an email notification is sent to the recei

To include more alerts, take a look at `config/prometheus/alerts/`. Similar alerts can be built and added to the same directory.

---

### **Development**

#### **Testing**
Expand Down
15 changes: 15 additions & 0 deletions manifests/metricly/config-map.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: metricly-config
namespace: monitoring
data:
config.yaml: |
server:
address: 0.0.0.0
port: 8080
prometheus:
address: prometheus-service
port: 9090
interval: 10s
debug: true
58 changes: 58 additions & 0 deletions manifests/metricly/daemonset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: metricly
namespace: monitoring
spec:
selector:
matchLabels:
app: metricly
template:
metadata:
annotations:
openshift.io/required-scc: metricly
labels:
app: metricly
spec:
nodeSelector:
kubernetes.io/os: linux
serviceAccountName: metricly
containers:
- name: metricly
image: quay.io/yadneshk/metricly:latest
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- name: config-volume
mountPath: /etc/metricly
readOnly: true
- name: host-filesystem
mountPath: /host/root/
mountPropagation: HostToContainer
readOnly: true
env:
- name: PROC_CPU_STAT
value: /host/root/proc/stat
- name: PROC_MEMORY_INFO
value: /host/root/proc/meminfo
- name: PROC_NETWORK_DEV
value: /host/root/proc/net/dev
- name: PROC_DISK_MOUNTS
value: /host/root/proc/mounts
- name: PROC_DISK_STATS
value: /host/root/proc/diskstats
- name: IGNORE_MOUNTS
value: "overlay,shm"
securityContext:
runAsUser: 0
volumes:
- name: config-volume
configMap:
name: metricly-config
- name: host-filesystem
hostPath:
path: /

---

19 changes: 19 additions & 0 deletions manifests/metricly/security-ctx-constraint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
allowHostDirVolumePlugin: true
allowHostNetwork: true
allowHostPID: true
allowHostPorts: true
allowPrivilegedContainer: true
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata:
annotations:
kubernetes.io/description: SCC specific to Metricly
name: metricly
readOnlyRootFilesystem: false
runAsUser:
type: RunAsAny
seLinuxContext:
type: RunAsAny
seccompProfiles:
- runtime/default
users: []
8 changes: 8 additions & 0 deletions manifests/metricly/service-account.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
automountServiceAccountToken: false
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: metricly
name: metricly
namespace: monitoring
13 changes: 13 additions & 0 deletions manifests/metricly/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: metricly
namespace: monitoring
spec:
selector:
app: metricly
ports:
- protocol: TCP
port: 8080
targetPort: 8080
type: ClusterIP

0 comments on commit 97a3176

Please sign in to comment.