DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Managing Multiple Environments With Weave GitOps

Managing Multiple Environments With Weave GitOps

This post explains how to use GitOps to manage a single application deployed into multiple environments, for example staging and production.

Steve Waterworth user avatar by
Steve Waterworth
·
Feb. 12, 22 · DevOps Zone · Tutorial
Like (2)
Save
Tweet
7.01K Views

Join the DZone community and get the full member experience.

Join For Free

My previous blog post provided an introduction to GitOps and a guide on how to get started with Weave GitOps Core. This follow-on post explains how to use GitOps to manage a single application deployed into multiple environments, for example, staging and production.

There are many ways application environments can be separated. Different namespaces within a single cluster, different clusters within a single cloud provider or different clusters across multiple cloud providers and/or bare metal. Managing multiple application instances across multiple environments is also known as Application Portability and it’s a non-trivial task to accomplish effectively. There are many challenges to overcome including configuration management, identity and access management, and networking. 

GitOps with its single source of truth simplifies configuration management. Because GitOps runs inside the Kubernetes clusters it significantly reduces the need for direct access to the clusters which simplifies identity and access management. Utilising a service mesh such as Linkerd enables policy control of network traffic.

Strategies

There are essentially two strategies for managing different configurations of the same application in different environments.

Branches

Probably the first one that springs to mind is using different Git branches for each environment. This alternative is supported by Weave GitOps, the branch to monitor can be set when the application is added.

Shell
 
$ gitops add app –branch=staging –name=my-app-staging


Using different branches is the easiest to implement, however, it can present some challenges when merging changes from one environment branch to the other e.g. staging to production. You do not want to accidentally merge into production the configuration for a staging data store. There are ways to avoid this for example by putting the data store configuration in a separate file and adding an entry to gitignore; it’s a bit of kludge though.

Kustomize

Kustomize uses a base configuration then applies overlays for different environments. It’s beyond the scope of this article to delve into finer points of Kustomize. Weave GitOps has native support for Kustomize, just as kubectl does. The overlay subdirectory can be specified when the application is added.

Shell
 
$ gitops add app –path=prod –name=my-app-prod


Using Kustomize requires a little more effort and complexity to implement but ultimately provides greater flexibility while reducing the risk of accidentally merging in a staging configuration into a production environment.

Color schemes

For my simple example, I modified the deployment manifest in both environments to change the background colour of the Podinfo sample application. Staging has a rather vibrant green background while production is a more sombre mid gray.

Under the Covers

There’s no magic smoke and mirrors required to get this working, it’s just a bunch of YAML files arranged in a structured hierarchy of directories. This is why it’s required to specify a unique name for each application and environment pairing, as shown in the examples above.

The structure above was created by Weave GitOps when adding the same application to two different environments. These files in the main branch of the Git repository are continually monitored and reconciled with Kubernetes.

The applications show up in the web dashboard under the names specified.

Watch a short video explaining this in more detail.

GitOps Is the Answer

This basic example shows how easy it is to manage the same application in different environments with different configurations using Weave GitOps. There’s no change to the day-to-day workflows of DevOps engineers, they continue to make changes, push them to Git and create a Pull Request for approval, and, ultimately, merging. Once merged into the monitored branch Weave GitOps will reconcile the changes in Kubernetes. Immediate and consistent deployments across multiple environments.

Find out more and get started with Weave GitOps today.

Weave (protocol) application Git Kubernetes cluster Branch (computer science) Production (computer science) Staging (data) IT Data store

Published at DZone with permission of Steve Waterworth. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Screen Sharing in Java
  • Java’s Encapsulation - When the Getter and Setter Became Your Enemy
  • MACH Architecture Explained
  • A Brief History of the DMCA

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo