Treat the infrastructure as code the same way as application code.
Infrastructure as Code hosted on Git repository.
Once merged into master changes will be automatically applied to master.
In GitOps, we have two ways to apply these changes:
We have version control on our code and changes in the repository are automatically synced to the environment, we can easily roll back the environment to any previous state in the code.
Instead of every developer managing the Infrastructure code, with GitOps, everything is stored centrally in a git repository and the environment is always synced with what's defined in the git repository and this means the git repository becomes the single source of truth which makes it easier to rollback or manage the infrastructure.
With GitOps, we now don’t have to give everyone in the team who needs to change something on the Infrastructure or in the k8s cluster direct access to execute the changes because it’s the CD pipeline that deploys the changes not individual developers from their laptop.
But anyone in the team can propose changes to the infrastructure in the git repository through a pull request and once its time to merge that pull request and apply those changes, we can have a limited set of people who are allowed to approve and merge those changes into the main branch so that it gets applied.
GitOps is Infrastructure as code with