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 all 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 services to be monitored based on annotations: prometheus.io/scrape: "true".

```
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
29 changes: 4 additions & 25 deletions OpenShift.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,33 @@ 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) :)

NOTE: After using `oc create -f ...` to deploy something to Kubernetes, use the console to check that it
NOTE: After using `oc create -f ...` to deploy something to OpenShift, use the console to check that it
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 services to be monitored based on annotations: prometheus.io/scrape: "true".

```
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:

```
oc create route edge prometheus --service=prometheus
```

Go to the OpenShift console Overview, expand the entry for `prometheus-prometheus` and you will see a link of the form https://prometheus-myproject.192.168.42.161.nip.io/ which can be used to open the Prometheus console.
Go to the OpenShift console Overview, expand the entry for `prometheus` and you will see a link of the form https://prometheus-myproject.192.168.42.161.nip.io/ which can be used to open the Prometheus console.

## OpenTracing

Expand Down
88 changes: 76 additions & 12 deletions prometheus-kubernetes.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,92 @@
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: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
- source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
action: replace
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name
---
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
33 changes: 5 additions & 28 deletions simple/services-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ spec:
metadata:
labels:
app: ordermgr
annotations:
prometheus.io/scrape: "true"
spec:
containers:
- name: ordermgr
Expand Down Expand Up @@ -49,19 +51,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 All @@ -72,6 +61,8 @@ spec:
metadata:
labels:
app: accountmgr
annotations:
prometheus.io/scrape: "true"
spec:
containers:
- name: accountmgr
Expand Down Expand Up @@ -109,18 +100,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