Skip to content
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

remove coreos-operator dependancy #19

Merged
merged 6 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions Kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,11 @@ NOTE: After using `kubectl create -f ...` to deploy something to Kubernetes, use
is fully running before moving onto the next step.

## Prometheus

To obtain metrics from the deployed services, we will use the
[coreos prometheus operator](https://coreos.com/operators/prometheus/docs/latest/user-guides/getting-started.html)
project. To install, use the following command:

```
kubectl create -f https://raw.githubusercontent.com/coreos/prometheus-operator/v0.11.0/bundle.yaml
```

Add configuration to locate service monitors based on label "team: frontend":
Add configuration to locate service monitors based on label "scrape: true":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "locate services to be monitored based..."


```
kubectl create -f prometheus-kubernetes.yml
```

The actual service monitors will be configured with the deployed services.

TODO: Currently there is one service monitor per service - using the label associated with the app. However
it may be good to try having a single service monitor with a more generic label, which the services can
be associated with.

Open the Prometheus dashboard using the link returned from:

```
Expand Down
24 changes: 2 additions & 22 deletions OpenShift.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@ This example will use [minishift](https://docs.openshift.org/latest/minishift/ge
First step is to start this environment:

```
minishift start --openshift-version=v3.6.0-alpha.2
minishift start
```

You can use a more [recent version](https://github.com/openshift/origin/releases) if available.

NOTE: The alpha version is currently required, as the previous stable version does not include Kubernetes RBAC authorizaion
support.

When fully started, then launch the dashboard using the link displayed following `The server is accessible via web console at:
`. Log in using the credentials `developer/developer` and navigate to the `New Project` overview page.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The next line contains "Kubernetes", could you change this to "OpenShift" - looks like I missed that (copy/paste) :)

Expand All @@ -20,31 +15,16 @@ is fully running before moving onto the next step.

## Prometheus

To obtain metrics from the deployed services, we will use the
[coreos prometheus operator](https://coreos.com/operators/prometheus/docs/latest/user-guides/getting-started.html)
project. To install, use the following command:
Add configuration to locate service monitors based on label "scrape: true":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above (for k8s)


```
oc login -u system:admin

oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:myproject:default
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:myproject:prometheus-operator

oc create -f https://raw.githubusercontent.com/coreos/prometheus-operator/v0.11.0/bundle.yaml
```

Add configuration to locate service monitors based on label "team: frontend":

```
oc create -f prometheus-kubernetes.yml
```

The actual service monitors will be configured with the deployed services.

TODO: Currently there is one service monitor per service - using the label associated with the app. However
it may be good to try having a single service monitor with a more generic label, which the services can
be associated with.

The next step is to create a route to make the Prometheus UI URL accessible:

```
Expand Down
71 changes: 59 additions & 12 deletions prometheus-kubernetes.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,75 @@
apiVersion: monitoring.coreos.com/v1alpha1
kind: Prometheus
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: prometheus
spec:
serviceMonitorSelector:
matchLabels:
team: frontend
version: v1.6.3
resources:
requests:
memory: 400Mi
replicas: 1
template:
metadata:
labels:
app: prometheus
spec:
containers:
- image: prom/prometheus:v2.0.0
name: prometheus
command:
- "/bin/prometheus"
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--storage.tsdb.retention=24h"
ports:
- name: web
containerPort: 9090
protocol: TCP
volumeMounts:
- mountPath: "/prometheus"
name: data
- mountPath: "/etc/prometheus"
name: config
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 500m
memory: 2500Mi
volumes:
- emptyDir: {}
name: data
- configMap:
name: prometheus
name: config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: service
relabel_configs:
- source_labels: [__meta_kubernetes_service_label_scrape]
action: keep
regex: true
---
apiVersion: v1
kind: Service
metadata:
name: prometheus
spec:
type: NodePort
type: LoadBalancer
ports:
- name: web
nodePort: 30900
port: 9090
protocol: TCP
targetPort: web
selector:
prometheus: prometheus

app: prometheus
31 changes: 3 additions & 28 deletions simple/services-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ metadata:
name: ordermgr
labels:
app: ordermgr
scrape: "true"
spec:
type: LoadBalancer
selector:
Expand All @@ -49,19 +50,6 @@ spec:
protocol: TCP
targetPort: web
---
apiVersion: monitoring.coreos.com/v1alpha1
kind: ServiceMonitor
metadata:
name: ordermgr
labels:
team: frontend
spec:
selector:
matchLabels:
app: ordermgr
endpoints:
- port: web
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
Expand Down Expand Up @@ -101,6 +89,7 @@ metadata:
name: accountmgr
labels:
app: accountmgr
scrape: "true"
spec:
type: LoadBalancer
selector:
Expand All @@ -109,18 +98,4 @@ spec:
- name: web
port: 8080
protocol: TCP
targetPort: web
---
apiVersion: monitoring.coreos.com/v1alpha1
kind: ServiceMonitor
metadata:
name: accountmgr
labels:
team: frontend
spec:
selector:
matchLabels:
app: accountmgr
endpoints:
- port: web

targetPort: web