Skip to content

Commit 461aada

Browse files
authored
Merge pull request #1089 from cognifloyd/k8s-docs-refactor
Refactor Kubernetes docs to cover changes to our Helm Chart
2 parents 61df5d4 + 2557a6f commit 461aada

File tree

2 files changed

+99
-32
lines changed

2 files changed

+99
-32
lines changed

docs/source/install/k8s_ha.rst

Lines changed: 94 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
This document provides an installation blueprint for a Highly Available StackStorm cluster
55
based on `Kubernetes <https://kubernetes.io/>`__, a container orchestration platform at planet scale.
66

7-
The cluster deploys a minimum of 2 replicas for each component of StackStorm microservices for redundancy and reliability. It
8-
also configures backends like MongoDB HA Replicaset, RabbitMQ HA and Redis Sentinel cluster that st2 relies on for database,
9-
communication bus, and distributed coordination respectively. That raises a fleet of more than ``30`` pods total.
7+
A StackStorm HA cluster consists of 2 replicas for most StackStorm microservices for redundancy and reliability.
8+
The cluster must also have access to backend services like MongoDB HA Replicaset, RabbitMQ HA and a Redis Sentinel cluster
9+
that st2 relies on for database, communication bus, and distributed coordination respectively. These services are
10+
included in the default StackStorm HA cluster, but StackStorm can also use services provisioned separately.
11+
By default, the StackStorm HA cluster consists of a fleet of more than ``30`` pods.
1012

11-
The source code for K8s resource templates is available as a GitHub repo:
13+
The source code for K8s resource templates (part of our Helm chart) is available as a GitHub repo:
1214
`StackStorm/stackstorm-ha <https://github.com/StackStorm/stackstorm-ha>`_.
1315

1416
.. warning::
@@ -23,13 +25,13 @@ The source code for K8s resource templates is available as a GitHub repo:
2325
Requirements
2426
------------
2527
* `Kubernetes <https://kubernetes.io/docs/setup/pick-right-solution/>`__ cluster
26-
* `Helm <https://docs.helm.sh/using_helm/#install-helm>`__, the K8s package manager and `Tiller <https://docs.helm.sh/using_helm/#initialize-helm-and-install-tiller>`_
28+
* `Helm <https://helm.sh/docs/intro/install>`__ 3, the K8s package manager (Helm 2 is not supported)
2729
* Enough computing resources for production use, respecting :doc:`/install/system_requirements`
2830

2931
Usage
3032
-----
3133
This document assumes some basic knowledge of Kubernetes and Helm.
32-
Please refer to `K8s <https://kubernetes.io/docs/home/>`__ and `Helm <https://docs.helm.sh/>`__
34+
Please refer to `K8s <https://kubernetes.io/docs/home/>`__ and `Helm <https://helm.sh/docs/>`__
3335
documentation if you find any difficulties using these tools.
3436

3537
However, here are some minimal instructions to get started.
@@ -52,16 +54,17 @@ or ``st2`` CLI client:
5254
.. figure :: /_static/images/helm-chart-notes.png
5355
:align: center
5456
57+
.. todo:: Update this screenshot. It is out of date.
5558

5659
The installation uses some unsafe defaults which we recommend you change for production use via Helm ``values.yaml``.
5760

5861
Helm Values
5962
___________
6063
Helm package ``stackstorm-ha`` comes with default settings (see `values.yaml <https://github.com/StackStorm/stackstorm-ha/blob/master/values.yaml>`_).
61-
Fine-tune them to achieve desired configuration for the StackStorm HA K8s cluster.
64+
Fine-tune them to achieve desired configuration for your StackStorm HA K8s cluster.
6265

6366
.. note::
64-
Keep custom values you want to override in a separated yaml file so they won't get lost.
67+
Keep custom values you want to override in a separate YAML file so they won't get lost.
6568
Example: ``helm install -f custom_values.yaml`` or ``helm upgrade -f custom_values.yaml``
6669

6770
You can configure:
@@ -71,13 +74,22 @@ You can configure:
7174
- st2.conf settings
7275
- RBAC roles, assignments and mappings (enterprise only for StackStorm v3.2 and before, open source
7376
for StackStorm v3.4 and later)
74-
- custom st2 packs and its configs
77+
- custom st2 packs (in persistent volumes or via custom docker images) and their configs
7578
- SSH private key
76-
- K8s resources and settings to control pod/deployment placement
77-
- Mongo, RabbitMQ clusters
79+
- K8s resources, annotations, and settings to control pod/deployment placement
80+
- Image tag and repository settings to select the ST2 version or use customized/private component images
81+
- DNS and Ingress configuration
82+
- Miscellaneous other ST2 cluster customizations
83+
- Mongo, RabbitMQ, and Redis clusters
84+
85+
If not defined, these values are auto-generated on install and preserved across upgrades:
86+
87+
- SSH private key
88+
- st2 auth secrets (ie: the password for the st2admin user)
7889

7990
.. warning::
80-
It's highly recommended to set your own secrets as the file contains unsafe defaults like SSH keys, StackStorm access credentials and MongoDB/RabbitMQ passwords!
91+
It's highly recommended to set your own secrets to replace the unsafe defaults for for the MongoDB and RabbitMQ subhcarts!
92+
If you disable the subcharts, make sure to secure the services and add the relevant secrets to st2.conf.
8193

8294
Upgrading
8395
_________
@@ -121,16 +133,34 @@ Grab all logs only for stackstorm backend services, excluding st2web and DB/MQ/r
121133
122134
Custom st2 packs
123135
----------------
124-
To follow the stateless model, shipping custom st2 packs is now part of the deployment process.
125-
It means that ``st2 pack install`` won't work in a distributed environment and you have to bundle all the
126-
required packs into a Docker image that you can codify, version, package and distribute in a repeatable way.
127-
The responsibility of this Docker image is to hold pack content and their virtualenvs.
128-
So the custom st2 pack docker image you have to build is essentially a couple of read-only directories that
129-
are shared with the corresponding st2 services in the cluster.
130-
131-
For your convenience, we created a new ``st2-pack-install <pack1> <pack2> <pack3>`` utility
136+
There are two ways to install st2 packs in the k8s cluster.
137+
138+
1. The ``st2packs`` method is the default. This method will work for practically all clusters, but ``st2 pack install`` does not work. The packs are injected via ``st2packs`` images instead.
139+
140+
2. The other method defines shared/writable ``volumes``. This method allows ``st2 pack install`` to work, but requires a persistent storage backend to be available in the cluster. This chart will not configure a storage backend for you.
141+
142+
.. note::
143+
In general, we recommend using only one of these methods. See the NOTE under Method 2 below about how both methods can be used together with care.
144+
145+
Method 1: st2packs images (the default)
146+
_______________________________________
147+
148+
This method strives to follow the stateless model, so shipping custom st2 packs is part of the deployment process.
149+
Without persistent storage (ie without state), packs and their virtualenvs need to be installed in each pod.
150+
``st2 pack install`` does not work in this distributed model because it assumes that nodes have a shared filesystem
151+
(Method 2, below, uses a shared filesystem), so that only one node needs to download the pack files or setup the
152+
virtualenv and all other nodes will see those files right away.
153+
154+
In order to achieve this stateless model, you have to bundle all the required packs (and their virtualenvs)
155+
into one or more Docker images that you can codify, version, package and distribute in a repeatable way.
156+
The responsibility of these Docker images is to hold pack content and their virtualenvs.
157+
Effectively, the st2packs Docker image(s) you have to build are a couple of read-only directories that
158+
are shared with the corresponding st2 services in the cluster. When a new st2actionrunner
159+
pod starts up, those directories get copied into the pod.
160+
161+
For your convenience, we created an ``st2-pack-install <pack1> <pack2> <pack3>`` utility
132162
and included it in a container `stackstorm/st2packs <https://hub.docker.com/r/stackstorm/st2packs/>`_
133-
that will help to install custom packs during the Docker build process without relying on live DB and MQ connection.
163+
that will help to install custom packs during the Docker build process without relying on live MongoDB and RabbitMQ connections.
134164

135165
For more detailed instructions see `StackStorm/st2packs-dockerfiles <https://github.com/StackStorm/st2packs-dockerfiles/>`_
136166
on how to build your custom `st2packs` image.
@@ -139,9 +169,28 @@ Please refer to `StackStorm/stackstorm-ha#install-custom-st2-packs-in-the-cluste
139169
Helm chart repository with more information about how to reference custom st2pack Docker image in Helm values, providing packs configs,
140170
using private Docker registry and more.
141171

172+
Method 2: Shared Volumes
173+
________________________
174+
175+
Pack content can also be shared via ReadWriteMany volumes such as NFS (Network File System) as :doc:`/reference/ha` recommends.
176+
Using shared volumes sacrifices the stateless infrastructure model, but enables normal pack management features
177+
such as ``st2 pack install``.
178+
179+
Relying on shared volumes requires cluster-specific storage setup and configuration. As that storage setup varies
180+
widely, manging that storage is out-of-scope for this helm chart. For example, before you can install this chart to use NFS,
181+
you would have to create the NFS exports, and you might need ``PersistentVolume`` and ``PersistentVolumeClaim`` k8s objects.
182+
Then, you add some volume definitions to your ``values.yaml``, and install or upgrade StackStorm with Helm.
183+
Not every cluster uses NFS or PV/PVCs to manage the storage, so the chart treats your volume definitions as opaque data,
184+
merely including your volume definitions in the appropriate place in various ``Deployment`` and ``Job`` k8s objects.
185+
142186
.. note::
143-
There is an alternative approach, - sharing pack content via read-write-many NFS (Network File System) as :doc:`/reference/ha` recommends.
144-
As beta is in progress and both methods have their pros and cons, we'd like to hear your feedback and which way would work better for you.
187+
With care, ``st2packs`` images can be used with ``volumes``. Just make sure to keep the ``st2packs`` images up-to-date
188+
with any changes made via ``st2 pack install``. If a pack is installed via an ``st2packs`` image and then it gets updated
189+
with ``st2 pack install``, a subsequent ``helm upgrade`` will revert back to the version in the ``st2packs`` image.
190+
191+
Please refer to `StackStorm/stackstorm-ha#install-custom-st2-packs-in-the-cluster <https://github.com/stackstorm/stackstorm-ha#install-custom-st2-packs-in-the-cluster>`_
192+
Helm chart repository with more information about how to pass custom volume definitions for ``packs``, ``virtualenvs``
193+
and pack ``configs`` in Helm values.
145194

146195
Ingress
147196
-------
@@ -185,7 +234,7 @@ st2web
185234
______
186235
st2web is a StackStorm Web UI admin dashboard. By default, st2web K8s config includes a Pod Deployment and a Service.
187236
``2`` replicas (configurable) of st2web serve the web app and proxy requests to st2auth, st2api, st2stream.
188-
By default, st2web uses HTTP instead of HTTPS. We recommend you rely on ``LoadBalancer`` or ``Ingress`` to add HTTPS layer on top of it.
237+
By default, st2web uses HTTP instead of HTTPS. We recommend you rely on ``LoadBalancer`` (a ``Service`` type) or ``Ingress`` to add HTTPS layer on top of it.
189238

190239
.. note::
191240
By default, st2web is a NodePort Service and is not exposed to the public net.
@@ -209,7 +258,7 @@ if you are planning a high-volume environment.
209258

210259
st2stream
211260
_________
212-
StackStorm st2stream - exposes a server-sent event stream, used by the clients like WebUI and ChatOps to receive updates from the st2stream server.
261+
The StackStorm ``st2stream`` service exposes a server-sent event stream, used by the clients like WebUI and ChatOps to receive updates from the st2stream server.
213262
Similar to st2auth and st2api, st2stream K8s configuration includes Pod Deployment with ``2`` replicas for HA (can be increased in ``values.yaml``)
214263
and ClusterIP Service listening on port ``9102``.
215264

@@ -263,8 +312,8 @@ st2actionrunner
263312
_______________
264313
Stackstorm workers that actually execute actions.
265314
``5`` replicas for K8s Deployment are configured by default to increase StackStorm ability to execute actions without excessive queuing.
266-
Relies on ``redis`` for coordination. This is likely the first thing to lift if you have a lot of actions
267-
to execute per time period in your StackStorm cluster.
315+
Relies on ``redis`` for coordination. The ``st2actionrunner`` replicas count is likely the first thing to increase if you have
316+
a lot of actions to execute per time period in your StackStorm cluster.
268317

269318
st2scheduler
270319
____________
@@ -294,6 +343,14 @@ By default ``3`` nodes (1 primary and 2 secondaries) of MongoDB are deployed via
294343
For more advanced MongoDB configuration, refer to official `mongodb-replicaset <https://github.com/helm/charts/tree/master/stable/mongodb-replicaset>`_
295344
Helm chart settings, which might be fine-tuned via ``values.yaml``.
296345

346+
The deployment of MongoDB to the k8s cluster can be disabled by setting the mongodb-ha.enabled key in values.yaml to false.
347+
348+
.. note::
349+
Stackstorm relies heavily on connections to a MongoDB instance. If the in-cluster deployment of MongoDB is disabled,
350+
a connection to an external instance of MongoDB must be configured. The st2.config key in values.yaml provides a way
351+
to configure stackstorm.
352+
See `Configure MongoDB <https://docs.stackstorm.com/install/config/config.html#configure-mongodb>`_ for configuration details.
353+
297354
`RabbitMQ HA Cluster <https://docs.stackstorm.com/latest/reference/ha.html#rabbitmq>`_
298355
______________________________________________________________________________________
299356
RabbitMQ is a message bus StackStorm relies on for inter-process communication and load distribution.
@@ -302,6 +359,14 @@ By default ``3`` nodes of RabbitMQ are deployed via K8s StatefulSet.
302359
For more advanced RabbitMQ configuration, please refer to official `rabbitmq-ha <https://github.com/helm/charts/tree/master/stable/rabbitmq-ha>`_
303360
Helm chart repository, - all settings could be overridden via ``values.yaml``.
304361

362+
The deployment of RabbitMQ to the k8s cluster can be disabled by setting the rabbitmq-ha.enabled key in values.yaml to false.
363+
364+
.. note::
365+
Stackstorm relies heavily on connections to a RabbitMQ instance. If the in-cluster deployment of RabbitMQ is disabled,
366+
a connection to an external instance of RabbitMQ must be configured. The st2.config key in values.yaml provides a way
367+
to configure stackstorm.
368+
See `Configure RabbitMQ <https://docs.stackstorm.com/install/config/config.html#configure-rabbitmq>`_ for configuration details.
369+
305370
redis
306371
_____
307372
StackStorm employs redis as a distributed coordination backend, required for st2 cluster components to work properly in an HA scenario.
@@ -311,8 +376,9 @@ As any other Helm dependency, it's possible to further configure it for specific
311376
Feedback Needed!
312377
----------------
313378
As this deployment method new and beta is in progress, we ask you to try it and provide your feedback via
379+
314380
bug reports, ideas, feature or pull requests in `StackStorm/stackstorm-ha <https://github.com/StackStorm/stackstorm-ha>`_,
315-
and ecourage discussions in `Slack <https://stackstorm.com/community-signup>`_ ``#docker`` channel or write us an email.
381+
and encourage discussions in `Slack <https://stackstorm.com/community-signup>`_ ``#k8s`` channel.
316382

317383

318384
.. only:: community

docs/source/reference/ha.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ a reference to layer on some HA deployment-specific details.
1818
1919
.. note::
2020

21-
A reproducible blueprint of StackStorm HA cluster is available as a code based on Docker and Kubernetes, see :doc:`/install/k8s_ha`.
21+
A reproducible blueprint of StackStorm HA cluster is available as a helm chart, which is based on Docker and Kubernetes. See :doc:`/install/k8s_ha`.
2222

2323

2424
Components
@@ -122,9 +122,10 @@ You have to have exactly one active ``st2timersengine`` process running to sched
122122
Having more than one active ``st2timersengine`` will result in duplicate timer events and therefore
123123
duplicate rule evaluations leading to duplicate workflows or actions.
124124

125-
In HA deployments, external monitoring needs to setup and a new ``st2timersengine`` process needs
126-
to be spun up to address failover. Losing the ``st2timersengine`` will mean no timer events will be
127-
injected into |st2| and therefore no timer rules would be evaluated.
125+
To address failover in HA deployments, use external monitoring of the ``st2timersengine`` process to ensure
126+
one process is running, and to trigger spinning up a new ``st2timersengine`` process if it fails.
127+
Losing the ``st2timersengine`` will mean no timer events will be injected into |st2| and therefore
128+
no timer rules would be evaluated.
128129

129130
st2workflowengine
130131
^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)