diff --git a/example/README.md b/example/README.md new file mode 100644 index 00000000..d0ea23f1 --- /dev/null +++ b/example/README.md @@ -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 + diff --git a/example/deploy.yaml b/example/deploy.yaml new file mode 100644 index 00000000..bd4a9e89 --- /dev/null +++ b/example/deploy.yaml @@ -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 + } + } + } +} \ No newline at end of file