-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #50 addon for prometheus in openshift 3.7
prometheus for openshift 3.7
- Loading branch information
Showing
4 changed files
with
643 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Prometheus Add-on | ||
An addon that will deploy Prometheus, Node-Exporter and AlertManager. | ||
|
||
NOTE: Requires Origin >= 3.7.0-rc.0 | ||
|
||
Verify you have installed these addons, by following the [general readme](../../README.adoc#download-and-use-community-add-ons). | ||
|
||
## Deploy prometheus | ||
To deploy prometheus do: | ||
|
||
``` | ||
minishift addon apply prometheus --addon-env prometheus_namespace=kube-system | ||
``` | ||
|
||
_NOTE_: You should provide the namespace where it will be installed with the addon-env prometheus_namespace, like this: | ||
|
||
## Use prometheus | ||
Prometheus will be available at: | ||
|
||
``` | ||
minishift openshift service prometheus -n <prometheus_namespace> | ||
``` | ||
|
||
_NOTE_: There service is exposed though SSL, so use https to access it. | ||
|
||
## Delete prometheus | ||
Delete prometheus with: | ||
|
||
``` | ||
oc delete sa,clusterrolebinding,route,svc,secret,deployment,configmap,daemonset,statefulset -l 'app in (prometheus,prometheus-node-exporter)' -n <prometheus_namespace> --as=system:admin | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# node-exporter is an optional component that collects host level metrics from the nodes | ||
# in the cluster. This group of resources will require the 'hostaccess' level of privilege, which | ||
# should only be granted to namespaces that administrators can access. | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: prometheus-node-exporter | ||
# You must grant hostaccess via: oadm policy add-scc-to-user -z prometheus-node-exporter hostaccess | ||
# in order for the node-exporter to access the host network and mount /proc and /sys from the host | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
prometheus.io/scrape: "true" | ||
labels: | ||
app: prometheus-node-exporter | ||
name: prometheus-node-exporter | ||
spec: | ||
clusterIP: None | ||
ports: | ||
- name: scrape | ||
port: 9100 | ||
protocol: TCP | ||
targetPort: 9100 | ||
selector: | ||
app: prometheus-node-exporter | ||
- apiVersion: extensions/v1beta1 | ||
kind: DaemonSet | ||
metadata: | ||
name: prometheus-node-exporter | ||
labels: | ||
app: prometheus-node-exporter | ||
role: monitoring | ||
spec: | ||
updateStrategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
app: prometheus-node-exporter | ||
role: monitoring | ||
name: prometheus-exporter | ||
spec: | ||
serviceAccountName: prometheus-node-exporter | ||
hostNetwork: true | ||
hostPID: true | ||
containers: | ||
- image: openshift/prometheus-node-exporter:v0.14.0 | ||
args: | ||
- "--collector.procfs=/host/proc" | ||
- "--collector.sysfs=/host/sys" | ||
name: node-exporter | ||
ports: | ||
- containerPort: 9100 | ||
name: scrape | ||
resources: | ||
requests: | ||
memory: 30Mi | ||
cpu: 100m | ||
limits: | ||
memory: 50Mi | ||
cpu: 200m | ||
volumeMounts: | ||
- name: proc | ||
readOnly: true | ||
mountPath: /host/proc | ||
- name: sys | ||
readOnly: true | ||
mountPath: /host/sys | ||
volumes: | ||
- name: proc | ||
hostPath: | ||
path: /proc | ||
- name: sys | ||
hostPath: | ||
path: /sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Name: prometheus-3.7 | ||
# Description: This template creates a Prometheus instance preconfigured to gather OpenShift and Kubernetes platform and node metrics and report them to admins. It is protected by an OAuth proxy that only allows access for users who have view access to the prometheus namespace. You may customize where the images (built from openshift/prometheus and openshift/oauth-proxy) are pulled from via template parameters. | ||
# Url: https://raw.githubusercontent.com/openshift/origin/master/examples/prometheus/prometheus.yaml | ||
# OpenShift-Version: >=3.7.0 | ||
# Required-Vars: prometheus_namespace | ||
|
||
oc new-app -f prometheus.yaml -p NAMESPACE=#{prometheus_namespace} -n #{prometheus_namespace} | ||
oc create -f node-exporter.yaml -n #{prometheus_namespace} | ||
oc adm policy add-scc-to-user -z prometheus-node-exporter -n #{prometheus_namespace} hostaccess | ||
|
||
# Add labels to things for easy removal | ||
oc label svc/prometheus app=prometheus -n #{prometheus_namespace} | ||
oc label svc/alerts app=prometheus -n #{prometheus_namespace} | ||
oc label configmap/prometheus app=prometheus -n #{prometheus_namespace} | ||
oc label secret/alerts-proxy app=prometheus -n #{prometheus_namespace} | ||
oc label secret/prometheus-proxy app=prometheus -n #{prometheus_namespace} | ||
oc label secret/prometheus-tls app=prometheus -n #{prometheus_namespace} | ||
oc label sa/prometheus app=prometheus -n #{prometheus_namespace} | ||
oc label sa/prometheus-node-exporter app=prometheus -n #{prometheus_namespace} | ||
oc label routes/prometheus app=prometheus -n #{prometheus_namespace} | ||
oc label routes/alerts app=prometheus -n #{prometheus_namespace} | ||
oc label clusterrolebinding/prometheus-cluster-reader app=prometheus -n #{prometheus_namespace} | ||
oc label configmaps/prometheus-alerts app=prometheus -n #{prometheus_namespace} | ||
|
||
echo You have installed #{addon-name} | ||
echo To access #{addon-name} go to https://prometheus-#{prometheus_namespace}.#{routing-suffix} | ||
echo | ||
echo To delete: | ||
echo oc delete sa,clusterrolebinding,route,svc,secret,deployment,configmap,daemonset,statefulset -l 'app in (prometheus,prometheus-node-exporter)' -n #{prometheus_namespace} --as=system:admin |
Oops, something went wrong.