1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/website/docs/user_guide/environments.md
Thomas Heartman 5a3f418e13
docs: add feature toggle reference, new how-to (#1694)
* Docs: write down the currently available steps

* docs: quick updates to the projects page.

* docs: further scaffold the how-to guide

* docs: add feature-toggle.mdx (toggle reference doc)

* docs: Add note that feature toggle names must be unique

* docs: add API doc links

* docs: delete old content

* docs: delete old images

* docs: update variants text

* docs: update introduction

* docs: add new images, update api annotations

* docs: add links to context fields, improve link text for other links.

* docs: remove redundant wording.

* docs: fix default project for toggles

* docs: typo: singular -> plural

* docs: mention admin ui curl command

* docs: remove leftover words

* docs: improve linking to default project.

* Apply suggestions from code review

Co-authored-by: sighphyre <liquidwicked64@gmail.com>

* Apply suggestions from code review

Co-authored-by: sighphyre <liquidwicked64@gmail.com>

* docs: clarify constraint timing

* docs: apply suggestion from code review

* docs: add link to variants document

* docs: Add sections on environments and projects, link from ft docs

* docs: minor rewording into unleash context.

* docs: remove misleading section about "all strats evaluated"

* docs: evaluate -> resolve

Co-authored-by: sighphyre <liquidwicked64@gmail.com>
2022-06-17 12:36:19 +02:00

8.7 KiB

id title
environments Environments
Environments are available in Unleash v4.3.x and later. They can also be enabled from Unleash v4.2.x with a feature toggle.

Environments is a new way to organize activation strategy configurations for feature toggles into separate environments. In Unleash, a feature lives across all your environments — after all, the goal is to get the new feature released as soon as possible — but it makes sense to configure the activation differently per environment. You might want the feature enabled for everyone in development, but only for yourself in production, for instance.

Previously, Unleash Enterprise could use strategy constraints to control the rollout across environments. With the new environments feature, this is no longer necessary. Now all activation strategies belong to an explicit environment instead.

Further, connected applications will use environment-scoped API keys to make sure they only download feature toggle configurations for the environment they are running in.

Finally, metrics have also been upgraded to record the environment. This, in turn, means that Unleash can display usage metrics per environment.

Despite this being a shift in how Unleash works, everything will continue to work exactly how it did for existing users. For backwards compatibility, we have created an environment named "default" that will contain all of the existing toggles and API keys. Read more about that in the migration section.

A graph showing how environments work. Each project can have multiple features, and each feature can have different activation strategies in each of its environments.

Global and project-level environments

Environments exist on a global level, so they are available to all projects within Unleash. However, every project might not need to use every environment. That's why you can also choose which of the global environments should be available within a project.

How to start using environments

In order to start using environments you need to be on Unleash v4.2 or higher.

If you are on v4.2, you also need to have the environment feature enabled (if you are using Unleash Hosted, please reach out on contact@getunleash.io if you want to start using environments.

If you are on v4.3 or later, environments are already enabled for you.

Note that in order to enable an environment for a feature toggle, you must first add activation strategies for that environment. You cannot enable an environment without activation strategies.

Step 1: Enable new environments for your Project

Navigate to the project and choose the “environments” tab.

A project view showing the Environments tab. The UI displays three environment toggles: "default", "development", and "production". The "default" environment is enabled.

Step 2: Configure activation strategies for the new environment

From the “feature toggle view” you will now be able to configure activation strategies per environment. You can also enable and disable environments here. Remember that an environment must have activation strategies before you can enable it.

A feature toggle strategies tab showing three different environments, of which one is active. The UI displays data about the currently selected environment,

Step 3: Create environment specific API keys

In order for the SDK to download the feature toggle configuration for the correct environment you will need to create an API token for a defined environment.

An API key creation form. The form's fields are "username", "token type", "project", and, crucially, "environment". The development environment is selected.

Migration

To ease migration we have created a special environment called “default”. All existing activation strategies have been added to this environment. All existing Client API keys have also been scoped to work against the default environment to ensure zero disruption as part of the upgrade.

If you're currently using strategy constraints together with the “environment” field on the Unleash Context, you should be aware that the new environment support works slightly differently. With environments, the SDK API will use the client's API key to determine which environment the client is configured for. The API then sends only strategies belonging to the client's environment. This means that you might not need the "environment" property of the Unleash Context anymore.

A strategy constraint using the environment field of the unleash context.

Addons

We have made some slight changes to events related to feature toggles: there's one deprecation and several new event types. Most of the new events contain project and environment data.

To avoid missing important updates, you will also need to update your addon configuration to subscribe to the new events.

Deprecated events:

  • FEATURE_UPDATE - not used after switching to environments

New Events

  • FEATURE-METADATA-UPDATED - The feature toggle metadata was updated (across all environments).
  • FEATURE-STRATEGY-ADD¹ - An activation strategy was added to a feature toggle in an environment. The data will contain the updated strategy configuration.
  • FEATURE-STRATEGY-UPDATE¹ - An activation strategy was updated for a feature toggle. The data will contain the updated strategy configuration.
  • FEATURE-STRATEGY-REMOVE¹ - An activation strategy was removed for a feature toggle.
  • FEATURE-ENVIRONMENT-ENABLED¹ - Signals that a feature toggle has been enabled in a defined environment.
  • FEATURE-ENVIRONMENT-DISABLED¹ - Signals that a feature toggle has been disabled in a defined environment.
  • FEATURE-PROJECT-CHANGE¹ - The feature toggle was moved to a new project.
  1. These feature events will contain project and environment as part of the event metadata.

API

In order to support configuration per environment we had to rebuild our feature toggle admin API to account for environments as well. This means that we're making the following changes to the API:

  • /api/admin/features - deprecated (scheduled for removal in Unleash v5.0). The old feature toggles admin API still works, but strategy configuration will be assumed to target the “default” environment.
  • /api/admin/projects/:projectId/features - New feature API to be used for feature toggles which also adds support for environments. See the documentation to learn more.

Plan Differences

Open-Source (free)

  • Will get access to two preconfigured environments: “development” and “production”. Existing users of Unleash will also get an additional “default” environment to simplify the adoption of environments.
  • Will be possible to turn environments on/off for all projects.

Pro (commercial)

  • Will get access to two preconfigured environments: “development” and “production”. Existing users of Unleash will also get an additional “default” environment to simplify the adoption of environments.
  • Will be possible to turn environments on/off for the default project.

Enterprise (commercial)

  • Will get access to two preconfigured environments: “development” and “production”. Existing users of Unleash will also get an additional “default” environment to simplify the adoption of environments.
  • Will be possible to turn environments on/off for all projects
  • Will be allowed to update and remove environments.
  • Will be allowed to create new environments.

Rollout Plan

  • Unleash v4.2 will provide early access to environment support. This means that it can be enabled per customer via a feature flag.
  • Unleash v4.3 plans to provide general access to the environment support for all users of Unleash (Open-Source, Pro, Enterprise).