Skip to content

Commit c6a428e

Browse files
jcpowermacpryorda
andauthored
fix(add_openshift): Adding openshift configurations
This PR includes manifests to support installing vmware_exporter in OpenShift and sending prometheus data directly to the existing instance. Co-authored-by: Daniel Pryor <[email protected]>
1 parent a45f0cf commit c6a428e

File tree

6 files changed

+159
-0
lines changed

6 files changed

+159
-0
lines changed

openshift/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Installing vmware_exporter in OpenShift
2+
3+
Create the secret as described in the kubernetes documentation
4+
5+
TODO: Use existing secret
6+
```
7+
read -s VSPHERE_PASSWORD
8+
oc create secret generic -n openshift-vsphere-infra vmware-exporter-password --from-literal=VSPHERE_PASSWORD=$VSPHERE_PASSWORD
9+
```
10+
11+
Modify the `configmap.yaml` for your configuration and apply.
12+
13+
```
14+
oc apply -f configmap.yaml
15+
```
16+
17+
Apply the role, rolebinding, service, deployment and ServiceMonitor
18+
19+
```
20+
oc apply -f rolebinding.yaml
21+
oc apply -f service.yaml
22+
oc apply -f deployment.yaml
23+
oc apply -f servicemonitor.yaml
24+
```
25+
26+
27+

openshift/configmap.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
data:
3+
VSPHERE_COLLECT_DATASTORES: "True"
4+
VSPHERE_COLLECT_HOSTS: "True"
5+
VSPHERE_COLLECT_SNAPSHOTS: "False"
6+
VSPHERE_COLLECT_VMGUESTS: "True"
7+
VSPHERE_COLLECT_VMS: "True"
8+
VSPHERE_FETCH_ALARMS: "True"
9+
VSPHERE_FETCH_CUSTOM_ATTRIBUTES: "True"
10+
VSPHERE_FETCH_TAGS: "True"
11+
VSPHERE_HOST: vcenter
12+
VSPHERE_IGNORE_SSL: "True"
13+
VSPHERE_USER: user
14+
kind: ConfigMap
15+
metadata:
16+
labels:
17+
app: vmware-exporter
18+
name: vmware-exporter-config
19+
namespace: openshift-vsphere-infra

openshift/deployment.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: vmware-exporter
5+
namespace: openshift-vsphere-infra
6+
spec:
7+
progressDeadlineSeconds: 600
8+
replicas: 1
9+
revisionHistoryLimit: 10
10+
selector:
11+
matchLabels:
12+
app: vmware-exporter
13+
k8s-app: vmware-exporter
14+
strategy:
15+
rollingUpdate:
16+
maxSurge: 25%
17+
maxUnavailable: 25%
18+
type: RollingUpdate
19+
template:
20+
metadata:
21+
creationTimestamp: null
22+
labels:
23+
app: vmware-exporter
24+
k8s-app: vmware-exporter
25+
release: vmware-exporter
26+
spec:
27+
containers:
28+
- envFrom:
29+
- configMapRef:
30+
name: vmware-exporter-config
31+
- secretRef:
32+
name: vmware-exporter-password
33+
image: quay.io/jcallen/vmware_exporter:add_metrics
34+
imagePullPolicy: Always
35+
name: vmware-exporter
36+
ports:
37+
- containerPort: 9272
38+
name: http
39+
protocol: TCP
40+
resources: {}
41+
terminationMessagePath: /dev/termination-log
42+
terminationMessagePolicy: File
43+
dnsPolicy: ClusterFirst
44+
restartPolicy: Always
45+
schedulerName: default-scheduler
46+
securityContext: {}
47+
terminationGracePeriodSeconds: 30

openshift/rolebinding.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
kind: Role
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: prometheus-k8s
5+
namespace: openshift-vsphere-infra
6+
rules:
7+
- verbs:
8+
- get
9+
- list
10+
- watch
11+
apiGroups:
12+
- ''
13+
resources:
14+
- services
15+
- endpoints
16+
- pods
17+
---
18+
kind: RoleBinding
19+
apiVersion: rbac.authorization.k8s.io/v1
20+
metadata:
21+
name: prometheus-k8s
22+
namespace: openshift-vsphere-infra
23+
subjects:
24+
- kind: ServiceAccount
25+
name: prometheus-k8s
26+
namespace: openshift-monitoring
27+
roleRef:
28+
apiGroup: rbac.authorization.k8s.io
29+
kind: Role
30+
name: prometheus-k8s

openshift/service.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
k8s-app: vmware-exporter
6+
name: metrics
7+
namespace: openshift-vsphere-infra
8+
spec:
9+
ports:
10+
- name: metrics
11+
port: 9272
12+
protocol: TCP
13+
targetPort: 9272
14+
selector:
15+
k8s-app: vmware-exporter
16+
sessionAffinity: None
17+
type: ClusterIP

openshift/servicemonitor.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: ServiceMonitor
3+
metadata:
4+
labels:
5+
k8s-app: vmware-exporter
6+
name: vmware
7+
namespace: openshift-monitoring
8+
spec:
9+
endpoints:
10+
- interval: 30s
11+
port: metrics
12+
scheme: http
13+
jobLabel: app
14+
namespaceSelector:
15+
matchNames:
16+
- openshift-vsphere-infra
17+
selector:
18+
matchLabels:
19+
k8s-app: vmware-exporter

0 commit comments

Comments
 (0)