Module 6 Lesson 4: Feature Flags (GitLab Unleash)
·DevOps

Module 6 Lesson 4: Feature Flags (GitLab Unleash)

Separate deployment from release. Learn how to use Feature Flags to toggle functionality on and off in your live application without redeploying your code.

Module 6 Lesson 4: Feature Flags (GitLab Unleash)

In traditional DevOps, "Deploying" code means the users see it. With Feature Flags, you can "Deploy" code but keep it Hidden until you are ready.

1. The Core Concept

Imagine an if statement that talks to a central server (GitLab):

// Inside your website code
if (unleash.isEnabled("new-payment-system")) {
  showNewPaymentButton();
} else {
  showOldPaymentButton();
}
  • Off: Code is on the server, but users see the old button.
  • On: You flip a switch in the GitLab UI, and everyone (instantly) sees the new button. No deployment needed!

2. Why Use Feature Flags?

  1. Safety: If the "new-payment-system" crashes your site, you flip the switch to "OFF" in GitLab. The bug is "Invisible" within 5 seconds without a 10-minute rollback.
  2. A/B Testing: You can turn the flag "ON" for 50% of users and "OFF" for the other 50% to see which group buys more products.
  3. Marketing Alignments: Deploy the "Christmas Theme" on December 1st, but don't enable the flag until exactly midnight on December 24th!

3. GitLab Unleash

GitLab includes a built-in server for Unleash (an open-source feature flag tool).

  • You manage your flags under Operate -> Feature Flags.
  • You define "Strategies" (e.g., "Only show to users in the UK" or "Only show to users with email @company.com").

4. "Dark Launching"

This is the practice of deploying code to production but not enabling the UI. This allows you to test if the backend can handle the database load before you actually show the button to users.


Exercise: The Toggle Test

  1. In your GitLab project, go to Operate -> Feature Flags and create a flag called test-feature.
  2. Search: How do you connect a Python or Node.js app to GitLab's Feature Flag API?
  3. What is the main danger of having 1,000 "Old" feature flags in your code? (Research: "Technical Debt and Feature Flags").
  4. Why is "Feature Flags" considered a better way to handle "Canary Releases" (Lesson 3) for small teams?

Summary

Feature Flags decouple Deployment (the technical act of moving code) from Release (the business act of exposing code). By mastering flags, you give your team the power to experiment safely in production.

Next Lesson: Emergency procedures: Rollbacks and Error Recovery.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn