Applying GitOps Principles to Your Development Environments

GitOps is the practice of using a Git repository as the single source of truth for your infrastructure: you declare the state you want, you version it, and automation makes the cluster match it. It changed how teams do continuous delivery. The same principles work just as well for the environments where your application runs before production.
The Problem: Environments Built by Hand
A modern application has many parts: several services, databases, queues, and cloud resources. Getting all of it running to work on a change is hard, and most teams solve it in one of two ways:
- Run it locally. Developers follow long READMEs or run scripts that somebody wrote years ago. The result is a simplified copy of the application that doesn't behave like production, so the feedback it gives isn't reliable.
- Build a production-like environment by hand. It works, but it takes hours, it requires knowing Kubernetes and the tools around it, and every environment ends up slightly different from the others.
In both cases, the knowledge of how to run the application lives in documents, scripts, and people's heads, not in a definition that a tool can apply. That is the problem GitOps solved for production.
GitOps Principles, Applied to Environments
The OpenGitOps principles say that the desired state of a system is declarative, versioned, pulled automatically, and continuously reconciled. For an environment where you develop, test, or review a change, this translates to:
- Declarative. A file describes how to build, deploy, and develop the application. Nobody follows steps by hand.
- Versioned. The file lives in the repository, next to the code it runs. A change to the environment is a pull request, with its review and its history.
- Applied automatically. A command or a pipeline creates the environment from the file, and the result is the same for everyone.
With Okteto, that file is the Okteto Manifest. It reuses the Helm charts, Kubernetes manifests, or Docker Compose files you already deploy with:
build:
api:
context: api
frontend:
context: frontend
deploy:
- helm upgrade --install movies chart --set api.image=${OKTETO_BUILD_API_IMAGE} --set frontend.image=${OKTETO_BUILD_FRONTEND_IMAGE}
dev:
api:
command: ["bash"]
sync:
- api:/usr/src/app
Anyone who clones the repository runs okteto up and gets the application running in their own namespace of a Kubernetes cluster, built from the current code, with the changes they make locally synchronized to it.
One Definition for Every Environment
The manifest isn't only for developers. Because the definition is in Git, everything that needs the application running starts from the same one:
- Developers create a Development Environment and code locally against it.
- Pull requests get a Preview Environment with a URL that reviewers can open.
- Coding agents deploy their changes to an environment and test them there before they open a pull request.
A bug found in one of them reproduces in the others, and nobody maintains a separate setup for each case.
Benefits
-
Developer experience. Nobody spends the start of a task setting up an environment. One command gets a developer to the point of writing code, and new team members contribute much sooner.
-
Consistency. Every environment comes from the same file, so they don't drift apart. When something fails, the team debugs the application, not the differences between two setups.
-
Reliability. The definition has the history of every change and who made it. If a change breaks the environments, you revert a commit.
-
Security. Fixing a problem for everyone is one pull request. For example, when the image of a Development Container has a vulnerability, you change one line, and every environment created from then on uses the fixed image:
okteto.yamldev:api:- image: registry.example.com/dev/api:1.4.1+ image: registry.example.com/dev/api:1.4.2
Platform teams already manage production this way. Applying it to the rest of the development cycle is a small step: write the manifest once, commit it, and let every developer, pull request, and agent start from it. The quickstart shows how.
