-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addon for prometheus in openshift 3.7 #51
Open
durandom
wants to merge
1
commit into
minishift:master
Choose a base branch
from
durandom:prom3.7
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,32 @@ | ||
# 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: | ||
|
||
``` | ||
minishift addon remove prometheus-3.7 | ||
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,30 @@ | ||
# 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 minishift addon remove prometheus-3.7 | ||
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 |
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,8 @@ | ||
# Name: prometheus-3.7 | ||
# Description: Remove add on | ||
# Url: https://raw.githubusercontent.com/openshift/origin/master/examples/prometheus/prometheus.yaml | ||
|
||
echo [prometheus] removing all resources | ||
oc delete sa,clusterrolebinding,route,svc,secret,deployment,configmap,daemonset,statefulset -l 'app in (prometheus,prometheus-node-exporter)' -n #{prometheus_namespace} --as=system:admin | ||
|
||
echo prometheus addon removed |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add-on names are decided from the directory names of the add-on, so the name of the add-on for this PR is
prometheus-3.7
. But the readme says that the name isprometheus
. So I am little confused.