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

add kube deployment objects and readme #3

Closed
wants to merge 3 commits into from
Closed
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
30 changes: 30 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Introduction
This will help you to deploy event-exporter to a kubernetes cluster and gather metrics on kubernetes events.

# How to deploy to a kubernetes cluster
## Assumptions
1. A kubernetes cluster is up and running
2. You have privilage to deploy to that cluster

Run following commands to deploy event-exporter to a cluster

1. Download deploy.yaml file locally
2. Update namespace in ClusterRoleBinding object (line 33)
3. `kubectl --context {add your cluster context} -n {add namespace here} apply -f deploy.yaml`


# How to see event metrics in Prometheus

## Assumptions
Prometheus is currently running and scraping pods in kubernetes
[Kube-state-metrics](https://github.com/kubernetes/kube-state-metrics) is deployed to your cluster

1. Open your prometheus instance
2. Search for metrics 'kubernetes_events'

# Setup alerts in alert manager

Please see references
1. https://prometheus.io/docs/alerting/overview/
2. https://itnext.io/prometheus-with-alertmanager-f2a1f7efabd6

131 changes: 131 additions & 0 deletions example/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
# Source: event-exporter/templates/serviceaccount.yaml
{
"apiVersion": "v1",
"kind": "ServiceAccount",
"metadata": {
"labels": {
"name": "event-exporter"
},
"name": "event-exporter"
}
}
---
# Source: event-exporter/templates/ClusterRoleBinding.yaml
{
"apiVersion": "rbac.authorization.k8s.io/v1beta1",
"kind": "ClusterRoleBinding",
"metadata": {
"labels": {
"name": "event-exporter"
},
"name": "event-exporter"
},
"roleRef": {
"apiGroup": "rbac.authorization.k8s.io",
"kind": "ClusterRole",
"name": "view" #create a specific cluster role and use it instead here
},
"subjects": [
{
"kind": "ServiceAccount",
"name": "event-exporter",
"namespace": "sandbox",
}
]
}
---
# Source: event-exporter/templates/service.yaml
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"annotations": {
"external-dns.alpha.kubernetes.io/hostname": "",
"prometheus.io/scrape": "true",
"service.beta.kubernetes.io/aws-load-balancer-backend-protocol": "http",
"service.beta.kubernetes.io/aws-load-balancer-ssl-ports": "https"
},
"labels": {
"name": "event-exporter"
},
"name": "event-exporter"
},
"spec": {
"ports": [
{
"name": "http",
"port": 80,
"targetPort": 9102
}
],
"selector": {
"app": "event-exporter"
}
}
}
---
# Source: event-exporter/templates/deployment.yaml
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"labels": {
"name": "event-exporter"
},
"name": "event-exporter"
},
"spec": {
"replicas": 1,
"revisionHistoryLimit": 2,
"selector": {
"matchLabels": {
"app": "event-exporter"
}
},
"strategy": {
"type": "RollingUpdate"
},
"template": {
"metadata": {
"annotations": {
"prometheus.io/path": "/metrics",
"prometheus.io/port": "9102",
"prometheus.io/scrape": "true"
},
"labels": {
"app": "event-exporter",
}
},
"spec": {
"containers": [
{
"command": [
"./event_exporter"
],
"env": [ ],
"image": "cargo.caicloud.io/sysinfra/event-exporter",
"imagePullPolicy": "Always",
"name": "event-exporter",
"ports": [
{
"containerPort": 9102,
"name": "http"
}
],
"resources": {
"limits": {
"memory": "100Mi"
},
"requests": {
"memory": "40Mi"
}
}
}
],
"serviceAccountName": "event-exporter",
"terminationGracePeriodSeconds": 30
}
}
}
}