Skip to content

Commit

Permalink
fix(add_openshift): Adding openshift configurations
Browse files Browse the repository at this point in the history
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 <daniel@pryorda.net>
  • Loading branch information
jcpowermac and pryorda authored Mar 10, 2021
1 parent a45f0cf commit c6a428e
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 0 deletions.
27 changes: 27 additions & 0 deletions openshift/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Installing vmware_exporter in OpenShift

Create the secret as described in the kubernetes documentation

TODO: Use existing secret
```
read -s VSPHERE_PASSWORD
oc create secret generic -n openshift-vsphere-infra vmware-exporter-password --from-literal=VSPHERE_PASSWORD=$VSPHERE_PASSWORD
```

Modify the `configmap.yaml` for your configuration and apply.

```
oc apply -f configmap.yaml
```

Apply the role, rolebinding, service, deployment and ServiceMonitor

```
oc apply -f rolebinding.yaml
oc apply -f service.yaml
oc apply -f deployment.yaml
oc apply -f servicemonitor.yaml
```



19 changes: 19 additions & 0 deletions openshift/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
data:
VSPHERE_COLLECT_DATASTORES: "True"
VSPHERE_COLLECT_HOSTS: "True"
VSPHERE_COLLECT_SNAPSHOTS: "False"
VSPHERE_COLLECT_VMGUESTS: "True"
VSPHERE_COLLECT_VMS: "True"
VSPHERE_FETCH_ALARMS: "True"
VSPHERE_FETCH_CUSTOM_ATTRIBUTES: "True"
VSPHERE_FETCH_TAGS: "True"
VSPHERE_HOST: vcenter
VSPHERE_IGNORE_SSL: "True"
VSPHERE_USER: user
kind: ConfigMap
metadata:
labels:
app: vmware-exporter
name: vmware-exporter-config
namespace: openshift-vsphere-infra
47 changes: 47 additions & 0 deletions openshift/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: vmware-exporter
namespace: openshift-vsphere-infra
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: vmware-exporter
k8s-app: vmware-exporter
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: vmware-exporter
k8s-app: vmware-exporter
release: vmware-exporter
spec:
containers:
- envFrom:
- configMapRef:
name: vmware-exporter-config
- secretRef:
name: vmware-exporter-password
image: quay.io/jcallen/vmware_exporter:add_metrics
imagePullPolicy: Always
name: vmware-exporter
ports:
- containerPort: 9272
name: http
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
30 changes: 30 additions & 0 deletions openshift/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: prometheus-k8s
namespace: openshift-vsphere-infra
rules:
- verbs:
- get
- list
- watch
apiGroups:
- ''
resources:
- services
- endpoints
- pods
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: prometheus-k8s
namespace: openshift-vsphere-infra
subjects:
- kind: ServiceAccount
name: prometheus-k8s
namespace: openshift-monitoring
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: prometheus-k8s
17 changes: 17 additions & 0 deletions openshift/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: vmware-exporter
name: metrics
namespace: openshift-vsphere-infra
spec:
ports:
- name: metrics
port: 9272
protocol: TCP
targetPort: 9272
selector:
k8s-app: vmware-exporter
sessionAffinity: None
type: ClusterIP
19 changes: 19 additions & 0 deletions openshift/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
k8s-app: vmware-exporter
name: vmware
namespace: openshift-monitoring
spec:
endpoints:
- interval: 30s
port: metrics
scheme: http
jobLabel: app
namespaceSelector:
matchNames:
- openshift-vsphere-infra
selector:
matchLabels:
k8s-app: vmware-exporter

0 comments on commit c6a428e

Please sign in to comment.