Skip to content

Commit

Permalink
Merge branch 'master' into feature/Robusta-Resources-Management
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshrvel committed Nov 6, 2023
2 parents 0b15e04 + 3b0b5c6 commit 7143c40
Show file tree
Hide file tree
Showing 44 changed files with 2,354 additions and 1,473 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ generated_values*.yaml
.isort.cfg
skaffold.dev.yaml
tests/last_used_tag.txt
pytest.ini
10 changes: 10 additions & 0 deletions docs/configuration/sinks/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Sinks Reference
webex
kafka
sinks-development
rocketchat

Robusta can report issues and events in your Kubernetes cluster to various destinations, known as sinks.

Expand Down Expand Up @@ -123,6 +124,15 @@ Click a sink for setup instructions.
:link: kafka
:link-type: doc

.. grid-item-card:: :octicon:`cpu;1em;` Rocket.Chat
:class-card: sd-bg-light sd-bg-text-light
:link: rocketchat
:link-type: doc

.. grid-item-card:: :octicon:`cpu;1em;` Mail
:class-card: sd-bg-light sd-bg-text-light
:link: mail
:link-type: doc


**Need support for a new sink?** `Tell us and we'll add it. <https://github.com/robusta-dev/robusta/issues/new?assignees=&labels=&template=feature_request.md&title=New%20Sink:>`_
Expand Down
33 changes: 33 additions & 0 deletions docs/configuration/sinks/mail.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Mail
#################

Robusta can report issues and events in your Kubernetes cluster by sending
emails.

Connecting the mail sink
------------------------------------------------

To set up the mail sink, you need access to an SMTP server. You should also
set the sender and receiver(s) addresses.

As Robusta uses the `Apprise library <https://github.com/caronc/apprise>`_ under the hood for running mail
notifications, you can configure the "mailto" field described below using
the convenient and sophisticated syntax provided by Apprise. For more details
`see here <https://github.com/caronc/apprise/wiki/Notify_email>`_.

Configuring the mail sink
------------------------------------------------

.. admonition:: Add this to your generated_values.yaml

.. code-block:: yaml
sinksConfig:
- mail_sink:
name: mail_sink
mailto: "mailtos://user:password@server&from=a@x&to=b@y,c@z"
(Note the quotes around the value in mailto. It's highly recommended to add
them as this ensures that characters like `:` are handled correctly)

Then do a :ref:`Helm Upgrade <Simple Upgrade>`.
68 changes: 68 additions & 0 deletions docs/configuration/sinks/rocketchat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
Rocket.Chat
#################

Robusta can report issues and events in your Kubernetes cluster to Rocket.Chat.

.. image:: /images/rocketchat1.png
:width: 600


Prerequisites
------------------------------------------------

Before you begin setting up the Rocket.Chat sink, ensure you have the following information ready:

* Server URL
* Personal Access Token
* User ID
* Channel name

**Rocket.Chat Server Setup**

First, you need to set up a Rocket.Chat server. If you haven't done this yet, you can find detailed information on deploying on-prem servers at the following URL: `Rocket.Chat Installation Guide <https://www.rocket.chat/install>`_.

Or if you prefer using RocketChat's cloud SaaS platform, you can follow the instructions at this URL: `Rocket.Chat Cloud Setup <https://cloud.rocket.chat>`_.

**Generating Personal Access Token and User ID**

Follow these steps to generate the required `Personal Access Token` and `User ID`:

1. Log in to your Rocket.Chat server using your valid username and password.

2. Click on your avatar and select `My Account` from the menu.

3. Navigate to `Profile` > `Personal Access Tokens`.

4. Check the `Ignore Two Factor Authentication` option if enabled.

5. Fill in the `Add new Personal Access Token` text field and click the `Add` button.

6. Copy the provided `Personal Access Token` and `User ID` for later use.


.. image:: /images/rocketchat2.png
:width: 1000

Configuring the Rocket.Chat sink
------------------------------------------------

.. admonition:: Add this to your generated_values.yaml

.. code-block:: yaml
sinks_config:
# Rocket.Chat integration params
- rocketchat_sink:
name: main_rocketchat_sink
user_id: <User ID>
channel: <Rocket.Chat channel>
token: <Personal Access Token>
server_url: <Server URL>
Save the file and run

.. code-block:: bash
:name: cb-add-rocketchat-sink
helm upgrade robusta robusta/robusta --values=generated_values.yaml
Binary file added docs/images/highcputhrottling.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rocketchat1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/rocketchat2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/setup-robusta/configuration-secrets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Robusta can pull values from Kubernetes secrets for:
* Sink Configuration
* Global Config
* Action Parameters
* Robusta RSA keys

To do so, first define an environment variable based on a Kubernetes secret. Add to Robusta's Helm values:

Expand All @@ -40,3 +41,5 @@ Then reference that environment variable in other Helm values using the special
Finally, make sure the Kubernetes secret actually exists. In this example, create a Secret named ``my-robusta-secrets``
with a ``secret_grafana_key`` value inside.

For Robusta RSA keys, you can define the ``existingSecret`` parameter. The secret must have the `pub` and `prv` keys.
8 changes: 5 additions & 3 deletions docs/tutorials/alert-custom-prometheus.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Deploy a broken Pod that will deliberately trigger the Prometheus alert we defin

.. code-block:: bash
kubectl apply -f <some example from our demo repo>
kubectl apply -f https://raw.githubusercontent.com/robusta-dev/kubernetes-demos/main/cpu_throttling/throttling.yaml
By default, Prometheus doesn't send alerts immediately. It waits X seconds to avoid sending flaky alerts that fire
temporarily and then immediately stop.
Expand All @@ -78,11 +78,13 @@ We can wait for the alert to fire or we can speed things up and simulate the ale

.. code-block:: bash
Show alert simulation
robusta playbooks trigger prometheus_alert alert_name=CPUThrottlingHigh pod_name=webapp-deployment-dcffd6bcc-qqs2k
Once the alert fires, a notification arrives in your configured sinks:

.. TODO example image
.. image:: /images/highcputhrottling.png
:width: 600
:align: center

Enriching the Alert
------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion helm/robusta/templates/auth-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.rsa }}
{{- if and .Values.rsa (not .Values.rsa.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
3 changes: 3 additions & 0 deletions helm/robusta/templates/forwarder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
{{- end }}
labels:
app: {{ .Release.Name }}-forwarder
{{- with .Values.kubewatch.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ .Release.Name }}-forwarder-service-account
automountServiceAccountToken: {{ .Values.automountServiceAccountToken }}
Expand Down
5 changes: 4 additions & 1 deletion helm/robusta/templates/runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ spec:
labels:
app: {{ .Release.Name }}-runner
robustaComponent: "runner"
{{- with .Values.runner.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or .Values.runner.annotations .Values.globalConfig.custom_annotations }}
annotations:
{{- if .Values.runner.annotations}} {{ toYaml .Values.runner.annotations | nindent 8 }}
Expand Down Expand Up @@ -142,7 +145,7 @@ spec:
optional: true
- name: auth-config-secret
secret:
secretName: robusta-auth-config-secret
secretName: {{ default "robusta-auth-config-secret" .Values.rsa.existingSecret }}
optional: true
{{- if .Values.playbooksPersistentVolume }}
- name: persistent-playbooks-storage
Expand Down
3 changes: 3 additions & 0 deletions helm/robusta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,9 @@ kube-prometheus-stack:
cpu: 10m

rsa: ~
# @param existingSecret Name of existing secret containing the rsa keys
# NOTE: Must contain the keys `pub` and `prv`
# existingSecret: my-robusta-rsa-keys

# custom parameters for OpenShift clusters
openshift:
Expand Down
2 changes: 1 addition & 1 deletion playbooks/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include_trailing_comma = true
python = "^3.7.1"
CairoSVG = "^2.5.2"
Flask = "^2.0.2"
prometheus-api-client = "^0.4.2"
prometheus-api-client = "^0.5.4"
pygal = "^3.0.0"
tinycss = "^0.4"
cssselect = "^1.1.0"
Expand Down
4 changes: 2 additions & 2 deletions playbooks/robusta_playbooks/job_actions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
from typing import List, Tuple

from hikaru.model.rel_1_26 import Container, Job, JobSpec, JobStatus, ObjectMeta, PodSpec, PodTemplateSpec
from hikaru.model.rel_1_26 import Container, EnvVar, Job, JobSpec, JobStatus, ObjectMeta, PodSpec, PodTemplateSpec

from robusta.api import (
ActionParams,
EnvVar,
EventEnricherParams,
FileBlock,
JobEvent,
Expand Down
2 changes: 1 addition & 1 deletion playbooks/robusta_playbooks/oom_killer.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def oomkilled_container_graph_enricher(event: PodEvent, params: OOMGraphEnricher
return
if params.delay_graph_s > 0:
time.sleep(params.delay_graph_s)
container_graph = create_container_graph(params, pod, oomkilled_container.container, show_limit=True)
container_graph = create_container_graph(params, pod, oomkilled_container, show_limit=True)
event.add_enrichment([container_graph])


Expand Down
8 changes: 4 additions & 4 deletions playbooks/robusta_playbooks/pod_enrichments.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ def pod_graph_enricher(pod_event: PodEvent, params: PodResourceGraphEnricherPara
if params.resource_type == "CPU":
if resource_limits.cpu > 0:
cpu_limit_in_bytes = resource_limits.cpu * 1024 * 1024
limit_line = XAxisLine(label="CPU Limit", value=cpu_limit_in_bytes)
limit_line = XAxisLine(label="Limit", value=cpu_limit_in_bytes)
limit_lines.append(limit_line)
if resource_requests.cpu > 0:
request_cpu_limit_in_bytes = resource_requests.cpu * 1024 * 1024
limit_line = XAxisLine(label="CPU Request", value=request_cpu_limit_in_bytes)
limit_line = XAxisLine(label="Request", value=request_cpu_limit_in_bytes)
limit_lines.append(limit_line)

elif params.resource_type == "Memory":
if resource_limits.memory > 0:
memory_limit_in_bytes = resource_limits.memory * 1024 * 1024
limit_line = XAxisLine(label="Memory Limit", value=memory_limit_in_bytes)
limit_line = XAxisLine(label="Limit", value=memory_limit_in_bytes)
limit_lines.append(limit_line)
if resource_requests.memory > 0:
request_memory_limit_in_bytes = resource_requests.memory * 1024 * 1024
limit_line = XAxisLine(label="Memory Request", value=request_memory_limit_in_bytes)
limit_line = XAxisLine(label="Request", value=request_memory_limit_in_bytes)
limit_lines.append(limit_line)

graph_enrichment = create_resource_enrichment(
Expand Down
Loading

0 comments on commit 7143c40

Please sign in to comment.