Skip to content

Commit

Permalink
Merge pull request #47 from robusta-dev/helm-chart
Browse files Browse the repository at this point in the history
Helm chart
  • Loading branch information
arikalon1 authored Sep 9, 2021
2 parents 767ec31 + b6d53e3 commit f36330b
Show file tree
Hide file tree
Showing 52 changed files with 664 additions and 495 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,7 @@ jobs:
fixed-${{ github.sha }}
fixed-
- name: Build with skaffold
run: ./skaffold build -p prod --file-output=container-ids.json

# we disable the run-id so that if we do two identical builds then they will output the same YAML
# otherwise skaffold creates a different yaml because the run id changes
- name: Render yaml file
run: ./skaffold render -p prod --offline=true -l skaffold.dev/run-id=LEAVE_UNCHANGED > robusta.yaml

# upload robusta.yaml to gist
- name: Deploy gist
uses: arikalon1/actions-deploy-gist@v1
with:
token: ${{ secrets.GIST_TOKEN }}
gist_id: 6b809d508dfc3d8d92afc92c7bbbe88e
gist_file_name: robusta-${{ env.RELEASE_VER }}.yaml
file_path: ./robusta.yaml
run: ./skaffold build --file-output=container-ids.json

- name: Create robusta examples
run: |-
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test_robusta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
source $HOME/.poetry/env
cd src/
poetry install
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
helm repo add robusta https://robusta-charts.storage.googleapis.com
- name: Test Robusta
env:
PYTEST_SLACK_TOKEN: ${{ secrets.PYTEST_SLACK_TOKEN }}
Expand Down
12 changes: 7 additions & 5 deletions src/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ RUN apt-get update \
# disabled because of an issue with the libreadline7 dependency
#RUN wget https://launchpad.net/~ionel-mc/+archive/ubuntu/socat/+build/15532886/+files/socat_1.7.3.2-2ubuntu2ionelmc2~ppa1_amd64.deb
#RUN dpkg -i socat_1.7.3.2-2ubuntu2ionelmc2~ppa1_amd64.deb

ENV CUSTOM_PLAYBOOKS_ROOT=/etc/robusta/config
ENV ENV_TYPE=DEV

# we install the project requirements and install the app in separate stages to optimize docker layer caching
RUN mkdir /app
RUN pip3 install --upgrade pip
RUN pip3 install poetry==1.1.6
RUN poetry config virtualenvs.create false
COPY pyproject.toml /app
COPY poetry.lock /app
COPY src/pyproject.toml /app
COPY src/poetry.lock /app
WORKDIR /app
RUN bash -c "pip3 install --requirement <(poetry export --dev --format requirements.txt --without-hashes)"

COPY . /app
ADD src/ /app

RUN pip3 install --use-feature=in-tree-build .

COPY playbooks/ /etc/robusta/playbooks/defaults
RUN pip3 install -r /etc/robusta/playbooks/defaults/requirements.txt
# remove the requirements so that we don't reinstall them at runtime
RUN rm /etc/robusta/playbooks/defaults/requirements.txt
# -u disables stdout buffering https://stackoverflow.com/questions/107705/disable-output-buffering
CMD [ "python3", "-u", "-m", "robusta.runner.main"]
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ If you want to develop features for Robusta itself you'll need to install Robust

If you want to use the Slack integration:
1. Get a slack token from https://robusta.dev/integrations/slack/?id=xyz
2. Add it to `deployment/dev/set_slack_api_key.yaml` before running skaffold
3. Optional: reduce the chance you'll accidentally commit your Slack key to git by running `git update-index --skip-worktree deployment/dev/set_slack_api_key.yaml` (see [here](https://stackoverflow.com/a/40272289/495995) for details)
2. Create your private `active_playbooks.yaml` file.
You can use `robusta gen-config --base-config-file helm/robusta/active_playbooks.yaml` to do that.
3. Add the generated file content to `helm/robusta/active_playbooks.yaml` before running skaffold
4. Optional: reduce the chance you'll accidentally commit your Slack key to git by running `git update-index --skip-worktree helm/robusta/active_playbooks.yaml` (see [here](https://stackoverflow.com/a/40272289/495995) for details)

# Running Robusta runner locally as a developer
If you want to run the Robusta runner on your own computer (e.g. with telepresence):
Expand Down
File renamed without changes.
18 changes: 0 additions & 18 deletions deployment/base/kustomization.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions deployment/base/namespace.yaml

This file was deleted.

73 changes: 0 additions & 73 deletions deployment/base/runner.yaml
Original file line number Diff line number Diff line change
@@ -1,73 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: robusta-runner
labels:
app: robusta-runner
spec:
replicas: 1
selector:
matchLabels:
app: robusta-runner
template:
metadata:
labels:
app: robusta-runner
spec:
serviceAccountName: robusta-runner
containers:
- name: runner
image: us-central1-docker.pkg.dev/genuine-flight-317411/devel/robusta-runner
imagePullPolicy: Always
securityContext:
privileged: false
env:
- name: CUSTOM_PLAYBOOKS_ROOT
value: /etc/robusta/config
- name: ENABLE_MANHOLE
value: "true"
- name: ENABLE_COLORED_LOGS
value: "true"
- name: LOG_LEVEL
value: INFO
- name: INSTALLATION_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: playbooks-config
mountPath: /etc/robusta/config
lifecycle:
preStop:
exec:
command: ["bash", "-c", "kill -SIGINT 1"]
- name: grafana-renderer
image: us-central1-docker.pkg.dev/genuine-flight-317411/devel/grafana-renderer:4
imagePullPolicy: Always
securityContext:
privileged: false
lifecycle:
preStop:
exec:
command: ["bash", "-c", "kill -SIGINT 1"]
resources:
limits:
memory: "512Mi"
volumes:
- name: playbooks-config
configMap:
name: robusta-config
optional: true
---
apiVersion: v1
kind: Service
metadata:
name: robusta-runner
spec:
selector:
app: robusta-runner
ports:
- name: http
protocol: TCP
port: 80
targetPort: 5000
5 changes: 0 additions & 5 deletions deployment/dev/kustomization.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions deployment/dev/set_slack_api_key.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions deployment/prod/kustomization.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion docs/developer-guide/scheduled-playbooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Scheduled Playbook Example
logging.info(f"My scheduled playbook running {action_params.some_string_param}")
| Load the ``playbook`` code using ``robusta playbooks load ./playbooks``
| Now, configure the playbook in the ``active_playbooks.yaml`` :
.. code-block:: yaml
Expand All @@ -51,7 +52,7 @@ Scheduled Playbook Example
action_params:
some_string_param: "Scheduled Playbook - Hello World"
| Lastly, deploy the playbook: ``robusta playbooks deploy ./playbooks``
| Lastly, activate the playbook: ``robusta playbooks configure ./playbooks/active_playbooks.yaml``
| That's it!
| Now, this playbook will run every ``20`` seconds for ``10`` times.
| In the robusta-runner logs, you'll be able to see the log line printed on each execution.
16 changes: 9 additions & 7 deletions docs/getting-started/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ Lets see how we can customize the broad collection of builtin playbooks.

Setting up a playbooks directory
-------------------------------------------------------------
You will need a `playbooks` directory with default files before continuing. There are three ways to set one up:
Robusta comes with builtin `playbooks`
Each ``playbook`` is a python script. Once loaded, it can be activated by including it in the ``active_playbooks.yaml`` file.
The python defines the *available* playbooks and the yaml activates them.

1. If you installed Robusta using ``robusta install``, you already have a `playbooks` directory in the working directory.
2. You can download your `playbooks` directory from your cluster by running ``robusta playbooks pull``
3. You can setup a new playbooks directory by running ``robusta examples``
| To load a ``playbook`` script use ``robusta playbooks load my-custom-playbooks-dir``
| To activate a ``playbook``, add it to your ``active_playbooks.yaml`` file, and run ``robusta playbooks configure active_playbooks.yaml``
| You can download the builtin ``playbooks`` by running ``robusta examples``
| To get the custom `playbooks` loaded to the cluster run ``robusta playbooks pull``
.. warning::
If you use ``robusta examples`` then `playbooks/active_playbooks.yaml` wont contain your API keys. Make sure to copy them over using ``robusta playbooks show-config``

A playbooks directory contains python scripts and one file named ``active_playbooks.yaml``. The python defines the *available* playbooks
and the yaml activates them.

Enabling a new playbook
------------------------
Expand Down Expand Up @@ -44,7 +46,7 @@ From the playbooks directory run:

.. code-block:: python
robusta playbooks deploy .
robusta playbooks configure active_playbooks.yaml
The **deployment_babysitter** playbook is now running. You will get a notification in Slack every time a deployment's number of replicas changes.

Expand Down
26 changes: 21 additions & 5 deletions docs/getting-started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,32 @@ Try running ``robusta --help`` to see what the robusta cli can do.

Installing Robusta in a Kubernetes cluster.
-----------------------------------------------------
.. note:: ``robusta`` commands use your current kubectl context. Use ``kubectl config use-context`` to change it.
.. note:: ``robusta`` and ``helm`` commands use your current kubectl context. Use ``kubectl config use-context`` to change it.

To deploy Robusta to your cluster run:
Robusta is installed using ``helm``.

First, get a copy of Robusta's ``helm`` chart

.. code-block:: bash
helm repo add robusta https://robusta-charts.storage.googleapis.com
helm pull robusta/robusta --untar
Now, use the Robusta cli generate the initial configuration

.. code-block:: bash
robusta gen-config --base-config-file robusta/active_playbooks.yaml
Lastly, use that configuration to install robusta

.. code-block:: bash
robusta install
cp active_playbooks_generated.yaml robusta/active_playbooks.yaml
helm install robusta ./robusta
This will install two deployments in the ``robusta`` namespace. Robusta can be removed at any time by deleting that namespace. :ref:`Learn more about Robusta's architecture<Robusta Architecture>`.
You can install Robusta on a custom namespace by using ``robusta install --namespace my-custom-namespace``
This will install two deployments in the ``robusta`` namespace.
Robusta can be removed at any time by running ``helm uninstall robusta``. :ref:`Learn more about Robusta's architecture<Robusta Architecture>`.

Seeing Robusta in Action
------------------------------
Expand Down
9 changes: 9 additions & 0 deletions docs/getting-started/more-commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ More Robusta CLI Commands

The ``robusta`` cli has additional commands for managing playbooks in your cluster.

Initial configuration
------------------------------------------
To initially configure your ``active_playbooks.yaml`` file run

.. code-block:: python
robusta gen-config --base-config-file robusta/active_playbooks.yaml
Viewing active playbooks
------------------------------------------
To view the currently active playbooks in your cluster run:
Expand Down
3 changes: 1 addition & 2 deletions docs/getting-started/uninstallation.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Uninstalling Robusta
#####################

Everything Robusta installs is placed in the ``robusta`` namespace. To delete Robusta, just delete that namespace.
If you installed Robusta on a custom namespace, delete that one.
Robusta is installed using ``helm``. Running ``helm uninstall robusta`` removes all the installed components.
6 changes: 2 additions & 4 deletions docs/user-guide/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ Robusta CLI
-----------

The robusta cli is installed via ``pip install robusta-cli`` and contains wrappers around kubectl to simplify
robusta operations. For example, ``robusta install`` fetches Robusta's yaml manifests, customizes them with parameters
from the user, and then runs ``kubectl apply``.
robusta operations. For example, ``robusta playbooks configure`` loads the ``active_playbooks.yaml`` configuration into the cluster by creating a config-map.

Robusta Kubernetes Deployments
------------------------------

.. image:: ../images/arch.png


All of Robusta's Kubernetes resources are installed in the ``robusta`` namespace.
You can install robusta on a custom namespace, by using the ``namespace`` parameter on the ``robusta install`` command.
All of Robusta's Kubernetes resources are installed in the ``robusta`` namespace by default.

Robusta has two in-cluster Kubernetes deployments which trigger and execute playbooks.
The first deployment, ``robusta-forwarder`` connects to the Kubernete's API server and monitors changes to the Kubernetes
Expand Down
3 changes: 2 additions & 1 deletion docs/user-guide/playbook-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Here is the layout of an example playbook directory:
- other_playbook.py
- requirements.txt
This set of playbooks would be loaded into Robusta with the command ``robusta playbooks deploy example_playbooks/``
These playbooks code would be loaded into Robusta with the command ``robusta playbooks load example_playbooks/``
This activation of these playbooks will be enabled using ``robusta playbooks configure example_playbooks/active_playbooks.yaml``

At the moment, only one playbook directory can be loaded at a time. Loading another playbook directory will replace the previous one.

Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/slack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Recommended: Using Robusta's official Slack app
Robusta is an approved app in the Slack App Directory. For details on Robusta's permissions,
`see the Robusta page in the Slack App Directory <https://slack.com/apps/A0214S5PHB4-robusta?tab=more_info>`_

To install the official Robusta app, use the ``robusta install`` command and follow the prompts.
To install the official Robusta app, use the ``robusta gen-config`` command and follow the prompts.

This method is recommended as it supports multiple Kubernetes clusters and are easy to setup.
Please note that incoming Slack messages are routed through the official Robusta
Expand Down
24 changes: 24 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Robusta helm chart
Robusta's helm chart is served from our gcp bucket

# Upload a new chart version
If you want to upload a new chart version, follow these steps:
1. Update `Chart.yaml` file, with the updated `version` (Chart version) and `appVersion` (Robusta version)
2. Make sure `helm` and `gsutil` is installed on your machine.
3. From the directory, `helm`, run: `./upload_chart.sh`

# Installing robusta with the helm chart
1. Download the Robusta cli:
`pip3 install -U robusta-cli --no-cache`
2. Add Robusta's chart repo:
`helm repo add robusta https://robusta-charts.storage.googleapis.com`
3. Get a local copy of the Robusta chart
`helm pull robusta/robusta --untar`
This created a directory named `robusta` on your current directory
4. Create the initial configuration for Robusta:
`robusta gen-config --base-config-file robusta/active_playbooks.yaml`
Follow the instructions, and a file named `active_playbooks_generated.yaml` is created
5. Override the defaults file with the generated file:
`cp active_playbooks_generated.yaml robusta/active_playbooks.yaml`
6. Lastly, install Robusta:
`helm install robusta ./robusta`
Loading

0 comments on commit f36330b

Please sign in to comment.