Guide

Feature gates: what they are and how to use them

What people mean by a feature gate, how it relates to feature flags, how to gate features by plan, role or region, and how the very different Kubernetes feature gates work.

A feature gate is a yes-or-no check that decides whether a user, an account or a system may use a feature. In product teams it is a feature flag that returns pass or fail. In infrastructure software such as Kubernetes, it is a switch, set at startup, that turns an alpha or beta feature on or off.

Two meanings of "feature gate"

The term is used in two communities, and search results mix them:

  • Product feature gates. In an application, a gate decides at runtime whether someone gets a feature: a beta program, the Pro plan's CSV export, an internal admin tool. Platforms such as Statsig call their boolean flags "feature gates". This is the meaning most of this guide covers.
  • Infrastructure feature gates. Projects such as Kubernetes, etcd and Consul ship new features behind named gates that operators switch on with a command-line flag or config file. They are about the maturity of the software itself, not about which user gets what. See Kubernetes feature gates below.

Feature gate vs feature flag

Technically a product feature gate is a feature flag: the same SDK call, the same targeting rules. The difference is the question it answers and how long it lives.

Feature gateFeature flag (general)Experiment
AnswersPass or fail: may they use it?Any value: on/off, a string, a number, JSONWhich of several variations?
Typical usePlans, roles, beta access, regions, internal toolsReleases, kill switches, remote configComparing variations on a metric
LifetimeAs long as the feature is gated, often yearsRelease flags: weeksLength of the test
Decided byWho the user or account isRollout percentage and rulesRandom but consistent assignment

In Pete Hodgson's classification of feature toggles, product feature gates are permissioning toggles: long-lived, and decided by who the user is. Railflag lets you mark such flags as permission flags, so nobody mistakes them for a release flag that should be cleaned up.

What feature gates are used for

  • Beta and early access. Let a list of customers or a segment try a feature before everyone.
  • Plans and entitlements. SSO for Enterprise, bulk export for Pro, more seats for Business. This is usually called feature gating.
  • Roles and permissions. Admin-only screens, support tooling, staff-only debug panels.
  • Regions and compliance. A payment method only where it is licensed, or data features only where storage is in-region.
  • Internal dogfooding. Your own company sees new work first, on production data.
  • Kill switches. A gate that is open by default and closed in an emergency.

How to implement a feature gate

A gate is a boolean flag checked with a context that describes who is asking. Gate on the capability, not on the plan name, so that pricing changes are configuration changes:

// One gate per capability. Rules decide which plans, accounts or roles pass.
const context = {
  targetingKey: user.id,
  accountId: account.id,
  plan: account.plan,
  role: user.role,
  region: account.region,
};

const canExport = await flags.getBooleanValue('bulk-export', false, context);
if (!canExport) throw new Forbidden('Bulk export is available on the Pro plan');

The rules for bulk-export might then read, top to bottom:

  1. accountId is one of acme, globex → pass (two customers in the beta)
  2. plan is one of pro, enterprise → pass
  3. role is staff → pass
  4. Everyone else → fail

Three rules matter more than any others:

  • Default to closed. The code default (false above) is used when the flag system cannot answer, so a gated feature stays gated.
  • Enforce on the server. Use the gate in the browser to hide buttons, but check it again in the API. Anything that runs in the browser can be changed by the user.
  • Evaluate locally. Gates are checked on almost every request. A server SDK that evaluates in memory keeps them fast and keeps working if the flag service is unreachable.

Feature gating by plan and entitlements

Using gates for pricing tiers works well with a few precautions:

  • Keep billing as the source of truth. The gate reads the plan from your context; it does not decide what someone paid for. Pass the plan from your billing data on every check.
  • One gate per capability. sso, bulk-export, audit-log, each with a rule like "plan is one of …". Moving a feature between plans becomes one rule change, reviewed and logged.
  • Gate per account in B2B. Target accountId, not individual users, so everyone in a company has the same features.
  • Document permanent gates. They are part of your product's behaviour; give them an owner and a description, and keep them out of flag cleanup sweeps.

Kubernetes feature gates

Kubernetes uses feature gates to ship features before they are stable. Each gate is a named switch inside a component such as kube-apiserver, kubelet or kube-scheduler, and every gate moves through stages:

StageDefaultMeaning
AlphaOffMay be buggy, may change or disappear without notice
BetaUsually onWell tested; details may still change
GA (stable)On, cannot be turned offThe gate is kept briefly, then removed

You set them when a component starts, either on the command line or in its configuration file:

# Command line
kube-apiserver --feature-gates=SomeAlphaFeature=true,AnotherFeature=false

# kubelet configuration file
featureGates:
  SomeAlphaFeature: true

Unlike product feature gates, these apply to the whole component, not to a user, and change only on restart. The authoritative list per version is on the Kubernetes feature gates reference.

Feature gate best practices

  1. Name gates after capabilities: sso, bulk-export, beta-dashboard.
  2. Default closed, enforce on the server.
  3. Mark gates as long-lived (Railflag: the permission kind) so cleanup tools leave them alone.
  4. Review production changes. Opening a gate for every account is a release; require an approval and keep an audit log.
  5. Keep the context complete. A gate can only be as precise as the attributes you send: user, account, plan, role, region.
  6. Close release gates for good. A gate used for a rollout becomes a normal flag to remove once the feature is open to everyone.

Frequently asked questions

Is a feature gate the same as a feature flag?
Mostly. A feature gate is a feature flag that answers a yes-or-no question: may this user, account or system use this feature? Some platforms, such as Statsig, use feature gate as their name for boolean flags. In Kubernetes and other infrastructure projects, feature gates are startup switches for alpha and beta features.
What does feature gating mean in SaaS?
Feature gating means making a capability available only to some plans, accounts or roles, for example CSV export on the Pro plan and SSO on Enterprise. Gates check the account's plan or entitlements at runtime instead of hard-coding them.
How do I enable a feature gate in Kubernetes?
Pass --feature-gates=GateName=true to the component that owns the feature, such as kube-apiserver or kubelet, or set featureGates in the component's configuration file, then restart it. Each component lists the gates it supports in its help output.
Should feature gates be checked in the frontend?
Use the gate in the frontend to hide what a user cannot use, but always enforce it on the server too. Anything that runs in the browser can be changed by the user.

Gate features by plan, role or region

Railflag evaluates gates in your process, so they cost nothing per check. Every production change has a reviewer and an audit log.

Start for free